Page 1 of 1

Looking for a little help

Posted: Mon Nov 10, 2014 5:41 pm
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'
}

Re: Looking for a little help

Posted: Mon Nov 10, 2014 6:05 pm
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.

Re: Looking for a little help

Posted: Wed Nov 12, 2014 9:08 am
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?

Re: Looking for a little help

Posted: Wed Nov 12, 2014 9:25 am
by jvierra
I suspect that there is no calendar.

Re: Looking for a little help

Posted: Wed Nov 12, 2014 11:25 am
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

Re: Looking for a little help

Posted: Wed Nov 12, 2014 12:17 pm
by jvierra
Try "$($_.Alias)"

Re: Looking for a little help

Posted: Wed Nov 19, 2014 5:37 am
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