When a mailbox is automatically created in ARS, I want to add a simple powershell script in the ARS "Workflow" to change the calendar folder permissions of the "Default" user to "LimitedDetails".
If I test the "Workflow" on the server by e.g. manually changing an test-attribute of a user, the ARS "Workflow" starts and changes the rights to LimitedDetails... this works as planned.
If the same script is used inside an existing full automatic "Workflow" (so I did not manually had to change a test-attribute), the script doesn't work and I don't know why.
Any suggestions for this newbe? Thx!
The "Workflow activity script":
function onInit()
{
param($context)
# Include Workflow Activity Core script
$context.UseLibraryScript("Library-Core")
<# end of function onInit #> }
function onPostCreate($Request)
{
$CurrentUser = $Dirobj.get("userprincipalname")
$ExchangeServer = "ourmailserver"
$ExchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://$ExchangeServer/PowerShell/
Import-PSSession $ExchangeSession -AllowClobber
$user="default"
$rights="LimitedDetails"
$calendar=$CurrentUser+":\calendar"
set-MailboxFolderPermission -Identity $calendar -User $user -AccessRights $rights
<# end of function onPostCreate #> }