Hey Guys,
time to admit defeat and post on the forum..
($RoomsAndMember.Users).Split(";")
seemed to work for all but the last command:
Add-MailboxPermission -Identity $RoomsAndMember.Alias -User ($RoomsAndMember.Users).Split(";") -AccessRights FullAccess
it gets the below error:
Cannot process argument transformation on parameter 'User'. Cannot
convert the "System.Collections.ArrayList" value of type "System.Collections.ArrayList" to type
"Microsoft.Exchange.Configuration.Tasks.SecurityPrincipalIdParameter".
+ CategoryInfo : InvalidData: (:) [Add-MailboxPermission], ParameterBindin...mationException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,Add-MailboxPermission
+ PSComputerName : SERVERNAME
Ive done some googling and some people have mentioned Loops to fix this issue but I haven't figured out how to apply any of the scripts to my situation.
Full script below, I have copied other people scripts, haven't yet found a way to find the time to pick up a PS book and study the fundamentals:
$ExchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://SERVERNAME/powershell
Import-PSSession $ExchangeSession
Set-Location "C:\DATA\OneDrive\Work\Tech_Support\Scripts\Exchange - Create Exchange Room Add members"
$ExcelWB = new-object -comobject excel.application
$Workbook = $ExcelWB.Workbooks.Open("C:\DATA\OneDrive\Work\Tech_Support\Scripts\Exchange - Create Exchange Room Add members\RoomsAndMembers.xlsx")
$Workbook.SaveAs("C:\DATA\OneDrive\Work\Tech_Support\Scripts\Exchange - Create Exchange Room Add members\RoomsAndMembers.csv",6)
$Workbook.Close($false)
$ExcelWB.quit()
$RoomsAndMembers = import-csv .\RoomsAndMembers.csv
ForEach ($RoomsAndMember in $RoomsAndMembers) {
$RoomsAndMember
New-Mailbox -Database "EXDB-06" -Name $RoomsAndMember.DisplayName -DisplayName $RoomsAndMember.DisplayName -UserPrincipalName $RoomsAndMember.UserPrincipalName -PrimarySmtpAddress $RoomsAndMember.PrimarySmtpAddress -Room -OrganizationalUnit "OU=Resource Mailboxes,OU=Production,DC=water,DC=internal" -Alias $RoomsAndMember.Alias -Office $RoomsAndMember.OfficeLocation
Start-Sleep 15
Set-CalendarProcessing -Identity $RoomsAndMember.Alias -ResourceDelegates ($RoomsAndMember.Users).Split(";") -BookInPolicy ($RoomsAndMember.Users).Split(";") -AutomateProcessing AutoAccept -MaximumDurationInMinutes "50400" -BookingWindowInDays "180" -DeleteSubject $false
Start-Sleep 5
Set-Mailbox -Identity $RoomsAndMember.Alias -GrantSendOnBehalfTo ($RoomsAndMember.Users).Split(";")
Start-Sleep 5
Add-MailboxPermission -Identity $RoomsAndMember.Alias -User ($RoomsAndMember.Users).Split(";") -AccessRights FullAccess
}
Thank you very much in advance :) even pointing me to an explanation will suffice hopefully :)