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
island_guy
Posts: 14
Last visit: Thu Feb 02, 2017 6:12 am
Post
by island_guy » Mon Nov 10, 2014 4: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'
}
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times
Post
by jvierra » Mon Nov 10, 2014 5: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.
island_guy
Posts: 14
Last visit: Thu Feb 02, 2017 6:12 am
Post
by island_guy » Wed Nov 12, 2014 8: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?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times
Post
by jvierra » Wed Nov 12, 2014 8:25 am
I suspect that there is no calendar.
island_guy
Posts: 14
Last visit: Thu Feb 02, 2017 6:12 am
Post
by island_guy » Wed Nov 12, 2014 10: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
island_guy
Posts: 14
Last visit: Thu Feb 02, 2017 6:12 am
Post
by island_guy » Wed Nov 19, 2014 4: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
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