Looking for a little help

Ask your Windows 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.
Locked
User avatar
island_guy
Posts: 14
Joined: Wed Aug 14, 2013 11:07 am

Looking for a little help

Post by island_guy » Mon Nov 10, 2014 5:41 pm

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'
}

User avatar
jvierra
Posts: 13807
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Looking for a little help

Post by jvierra » Mon Nov 10, 2014 6:05 pm

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
Joined: Wed Aug 14, 2013 11:07 am

Re: Looking for a little help

Post by island_guy » Wed Nov 12, 2014 9:08 am

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?

User avatar
jvierra
Posts: 13807
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Looking for a little help

Post by jvierra » Wed Nov 12, 2014 9:25 am

I suspect that there is no calendar.

User avatar
island_guy
Posts: 14
Joined: Wed Aug 14, 2013 11:07 am

Re: Looking for a little help

Post by island_guy » Wed Nov 12, 2014 11:25 am

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

User avatar
jvierra
Posts: 13807
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Looking for a little help

Post by jvierra » Wed Nov 12, 2014 12:17 pm

Try "$($_.Alias)"

User avatar
island_guy
Posts: 14
Joined: Wed Aug 14, 2013 11:07 am

Re: Looking for a little help

Post by island_guy » Wed Nov 19, 2014 5:37 am

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

Locked