Scripting Creation and Configuration of Exchange 2007 Resource Mailboxes
I'm pretty green with powerhsell in terms of scripting. I'm trying to write a basic script that takes input from a semi-colon delimited CSV file and creates/configures resource mailboxes in Exchange 2007. My semi-colon delimited csv file is as follows Name;MaxCapacity;ResourcesinRoom;CalendarIncrementOption;Calendarworkweek;Maxdays;MaxMeetingDuration;HybridPerms;AutomaticPerms;ManualPerms;Delegates;FullAccess;CustomText Example-x1;35;"VTCEquipment, LCDProjector";15;M-F 7-5;365;7200;email.addy@example.com,another.email@example.com;j.g@example.com;ex@example.com;ex@example.com;"This is the exact text as it will be displayed in the reply to the meeting organizer" My script is as follows, although keep in mind I intended this to be called from the Exchange Managment Shell so the Exchange cmdlets were pre-loaded. $rooms = import-csv c:\temp\room-import2.csv -delimiter ';' $rooms | ForEach-Object -Process {New-Mailbox -name $_.name -alias $_.name -database "server\database" -userprincipalname "$_.name@example.com" -OrganizationalUnit "conference rooms" -DisplayName $_.name -Room} $rooms | ForEach-Object -Process {set-mailbox -identity $_.name -resourcecustom $_.resourcesinroom -resourcecapacity $_.maxcapacity} $rooms | ForEach-Object -Process {Add-MailboxPermission –Identity $_.name -User $_.fullaccess -AccessRights Fullaccess -InheritanceType all} $rooms | ForEach-Object -Process {Set-MailboxCalendarSettings -identity $_.name -AutomateProcessing:AutoAccept -addadditionalresponse:$true -additionalresponse $_.customtext -addnewrequeststentatively:$true -addorganizertosubject:$true -allbookinpolicy:$true -allowrecurringmeetings:$true -AllRequestOutOfPolicy:$true -AllRequestinPolicy:$true -bookingwindowindays $_.maxdays -bookinpolicy $_.automaticperms -deleteattachments:$true -deletenoncalendaritems:$true -enableresponsedetails:$true -enforceschedulinghorizon:$true -forwardrequeststodelegates:$true -maximumdurationinminutes $_.maxmeetingduration -organizerinfo:$true -removeforwardedmeetingnotifications:$true -removeoldmeetingmessages:$true -requestinpolicy $_.manualperms -requestoutofpolicy $_.hybridperms -resourcedelegates $_.delegates -scheduleonlyduringworkhours:$true -tentativependingapproval:$true} I'm having two issues with the script. During the set-mailbox command, there are some rooms that have multiple resources in the room (VTCEquipment and an LCDProjector). The cmdlet needs a specific format when multiple resources are to be input. For the parameter -resourcecustom, the cmdlet is expecting an input as follows: -resourcecustom ("VTCEquipment","LCDProjector") . The problem I am having is that when the string from the array is passed to the command, it is enclosed in double quotes. So I end up with something like -resourcecustom "("VTCEquipment","LCDProjector")" . The cmdlet returns an error stating it is an invalid input for that parameter. How can I edit my code to pass the string properly to the parameter? During the Set-MailboxCalendarSettings command, if I input one email address for any of the permissions fields (automaticperms, hybridperms, manualperms), it runs fine, if I input two or more it returns this error: Set-MailboxCalendarSettings : Object "email.addy@example.com, another.email@example.com" could not be found. Please make sure that it was spelled correctly or specify a different object. At C:\temp\test.ps1:9 char:62+ $rooms | ForEach-Object -Process {Set-MailboxCalendarSettings <<<< -identity $_.name -AutomateProcessing:AutoAccept -addadditionalresponse:$true -additionalresponse $_.customtext -addnewrequeststentatively:$true -addorganizertosubject:$true -allbookinpolicy:$true -allowrecurringmeetings:$true -AllRequestOutOfPolicy:$true -AllRequestinPolicy:$true -bookingwindowindays $_.maxdays -bookinpolicy $_.automaticperms -deleteattachments:$true -deletenoncalendaritems:$true -enableresponsedetails:$true -enforceschedulinghorizon:$true -forwardrequeststodel egates:$true -maximumdurationinminutes $_.maxmeetingduration -organizerinfo:$true -removeforwardedmeetingnotifications:$true -removeoldmeetingmessages:$true -requestinpolicy $_.manualperms -requestoutofpolicy $_.hybridperms -resourcedelegates $_.delegates -scheduleonlyduringworkhours:$true -tentativependingapproval:$true} + CategoryInfo: NotSpecified: (0:Int32) [Set-MailboxCalendarSettings], ManagementObjectNotFoundException + FullyQualifiedErrorId : D05EA68E,Microsoft.Exchange.Management.Recipient Tasks.SetMailboxCalendarSettings Can anyone help me iron out the last wrinkles in this code? Alternatively, if you already have a script that does this, I am open to it. I would however like to know what I am doing wrong just for my reference. On a tangent, can anyone recommend a good book or online resource for teaching yourself Powershell scripting? Thanks, Jon
April 20th, 2011 5:24pm

1. Either enclose the entire string in single quotes: -resourcecustom '("VTCEquipment","LCDProjector")' or escape the double quotes: -resourcecustom "(`"VTCEquipment`",`"LCDProjector`")" The escape character is the back-tick, or unshifted tilda ("~") on most keyboards. 2. What did you set $Rooms to? It doesn't look like it's the right collection to pipe to a ForEach-Lbject. I can't comment further without seeing what it is you're trying to do.Ed Crowley MVP "There are seldom good technological solutions to behavioral problems."
Free Windows Admin Tool Kit Click here and download it now
April 20th, 2011 5:47pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics