Looking for a little help

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 9 years and 4 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
island_guy
Posts: 14
Last visit: Thu Feb 02, 2017 6:12 am

Looking for a little help

Post by island_guy »

I am working with a couple new items here, hash tables and the new-object. Seems I can't store the collection in $results for some reason. Any help would be appreciated. Thanks

PowerShell Code
Double-click the code block to select all.
$Results = @()
$RoomName = get-mailbox -recipienttypedetails RoomMailbox | Where { $_.displayname -match "ABC" }
      
      
       foreach ($item in $RoomName)
       {
             $RoomName = $item.Alias
             $RoomProcessing = Get-CalendarProcessing $RoomName
             $RoomPermissions = Get-MailboxFolderPermission $RoomName
             $RoomCalendarConfig = Get-MailboxCalendarConfiguration $RoomName
            
             $Properties = @{
                    Name = $RoomName
                    WorkDays = $RoomCalendarConfig.WorkDays
                    WorkingHoursStartTime = $RoomCalendarConfig.WorkingHoursStartTime
                    WorkingHoursEndTime = $RoomCalendarConfig.WorkingHoursEndTime
                    Alias = $item.alias
             }
            
             $Results += New-Object -TypeName psobject -Property $properties
            
            
            
       }
       $Results = Select-Object Name, WorkDays, WorkingHoursStartTime, WorkingHoursEndTime | Export-Csv -NoTypeInformation -Path 'C:\Users\admin\Desktop\results.csv'
}
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Looking for a little help

Post by jvierra »

Start with this:
PowerShell Code
Double-click the code block to select all.
Get-MailBox -recipienttypedetails RoomMailbox | 
     Where { $_.displayname -match "ABC" } |
     ForEach-Object{
             
             $RoomCalendarConfig = Get-MailboxCalendarConfiguration $_.Alias
             
             $Properties = [ordered]@{
                    Name=$_.Alias
                    WorkDays=$RoomCalendarConfig.WorkDays
                    WorkingHoursStartTime = $RoomCalendarConfig.WorkingHoursStartTime
                    WorkingHoursEndTime = $RoomCalendarConfig.WorkingHoursEndTime
                    Alias = $_.alias
             }
             
             New-Object -TypeName psobject -Property $properties
       } | 
       Export-Csv -NoTypeInformation -Path 'C:UsersadminDesktopresults.csv'
Once you understand how it works the rest will be easy.
User avatar
island_guy
Posts: 14
Last visit: Thu Feb 02, 2017 6:12 am

Re: Looking for a little help

Post by island_guy »

Thank you.

Running it through debug mode, I do not show any thing being returned on this line.

$RoomCalendarConfig = Get-MailboxCalendarConfiguration $_.Alias

The $. shows the name of the room but it's not storing anything in $roomcalendarconfig variable.

Thoughts?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Looking for a little help

Post by jvierra »

I suspect that there is no calendar.
User avatar
island_guy
Posts: 14
Last visit: Thu Feb 02, 2017 6:12 am

Re: Looking for a little help

Post by island_guy »

No, it has a calendar. I can run just that line with the first calendar name and it returns the information.

The only difference is , when I run it manually I put the room in double quotes?

I thought powershell would take care of this for me.. maybe not.

how would I put $._alias in double quotes? I tried ""$._alias"" and '$._alias' and `"$._alias" with no success.

Thanks
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Looking for a little help

Post by jvierra »

Try "$($_.Alias)"
User avatar
island_guy
Posts: 14
Last visit: Thu Feb 02, 2017 6:12 am

Re: Looking for a little help

Post by island_guy »

I ended up doing this to fetch a report (.csv) on Room and equipment mailboxes with "ABC" in the name.

PowerShell Code
Double-click the code block to select all.
$holdrooms = Get-MailBox -ResultSize Unlimited -recipienttypedetails RoomMailbox,EquipmentMailbox | Where { $_.displayname -match "ABC" }
 
$holdrooms | ForEach-Object{
             
             $RoomCalendarConfig = Get-MailboxCalendarConfiguration $_.Alias
             $getcalprocessing = Get-CalendarProcessing $_.Alias
            $rescaltemp = '{0}:\Calendar' -f $_.Alias
               $acl = Get-MailboxFolderPermission $rescaltemp | Select User, @{ n = "AccessRights"; e = { $_.AccessRights } }
      
           
 
 
 
             $Properties = [ordered]@{
                    Name=$_.Alias
                    AutomateProcessing = $getcalprocessing.AutomateProcessing
                    ResourceDelegates = $getcalprocessing.ResourceDelegates
                    ForwardRequestsToDelegates = $getcalprocessing.ForwardRequestsToDelegates
                    ScheduleOnlyDuringWorkHours = $getcalprocessing.ScheduleOnlyDuringWorkHours
                    BookingWindowInDays = $getcalprocessing.BookingWindowInDays
                    WorkDays=$RoomCalendarConfig.WorkDays
                    WorkingHoursStartTime = $RoomCalendarConfig.WorkingHoursStartTime
                    WorkingHoursEndTime = $RoomCalendarConfig.WorkingHoursEndTime
                    CalendarAccess = ($acl | Out-String).trim()
                   
             }
            
             
              
             New-Object -TypeName psobject -Property $properties
       } | Export-Csv -NoTypeInformation -Path 'c:\Users\Admin\Desktop\EXPORT.csv'
Thanks
This topic is 9 years and 4 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked