I got this little code in PowerShell for O365:
$dispname = Read-Host 'Displayname of room'
$alias = read-Host 'Alias of name (no spaces, no domain)'
$capacity = read-host 'Capacity of room'
$loc = read-host 'Location of room (site)'
$smtp = $alias + "@test.com"
$group = "cr." + $loc + "[email protected]"
New-Mailbox -Name $alias -DisplayName $dispname -Room -office $loc
Set-Mailbox $alias -ResourceCapacity $capacity
Set-CalendarProcessing $alias -ScheduleOnlyDuringWorkHours $false -AutomateProcessing AutoAccept -AllowRecurringMeetings $True -AllowConflicts $False -ConflictPercentageAllowed 30 -MaximumConflictInstances 10 -BookingWindowInDays 365 -MaximumDurationInMinutes 1440
Set-MailboxCalendarConfiguration -identity $alias -WorkingHoursTimeZone "W. Europe Standard Time" -WorkingHoursStartTime 07:00:00 -WorkingHoursEndTime 18:00:00
Set-MailboxFolderPermission -Identity ${smtp}:\Calendar -User Default -AccessRights Reviewer
echo "Lokation is $loc"
echo "SMTP is $smtp"
echo "Gruppe is $group"
Add-DistributionGroupMember –Identity "$group" –Member "$smtp"
and I'm desperate because only the last line is getting me an error and I have absolutely no clue why.
The error is:
A positional parameter cannot be found that accepts argument '[email protected]'. CategoryInfo : InvalidArgument: (:) [Add-DistributionGroupMember], ParameterBindingException FullyQualifiedErrorId : PositionalParameterNotFound,Add-DistributionGroupMember PSComputerName : outlook.office365.com
So the variable $smtp is correctly set as the email address of the new ressource as well as the variable $group for the group name but somehow it does not work properly for PowerShell.
The thing is, when I do all the steps manually, so paste it in line for line in PowerShellit works. I got the error only when I run it as a script.
robdyfound the problem & the fix. good to know that you got it working as needed. ///// the usual source of that sort of thing [em/en-dash instead of hyphen; typographic quote instead of straight quote] is copying from a web page. it's worth checking on everything that you copy & paste. - Lee_Dailey–Identity "$group" –Member "$smtp"<<<. that forces the object into a string ... and you USUALLY want the object to be a full object, not a "stringified" version of the object. [grin] - Lee_Dailey