4 Replies Latest reply on Jan 19, 2018 2:21 PM by Landon Winburn

    PowerShell Custom Action Fails

    jmbecker Rookie

      Hey everyone,

       

      We're trying to set up a custom action on our Citrix XenDesktop servers which adds an Active Directory Domain Group to the local "Remote Desktop Users" group.  Before EM, we had a script that we used to do this, but we would like to import it into our Environment Manager policy so that it runs on the machine when it starts up.  Here's the custom action:

       

       $DomainGroup = "GroupToAddTo"
       $LocalGroup  = "Remote Desktop Users"
       $Computer    = $env:computername
       $Domain      = $env:userdomain
      
       ([ADSI]"WinNT://$Computer/$LocalGroup,group").psbase.Invoke("Add",([ADSI]"WinNT://$Domain/$DomainGroup").path)
      

       

      If I go into the server and execute these actions, it runs without any issues.  If I put it into the Computer->Network Available trigger, however, I get the following event in the management console:

       

       

      Any chance one of you gurus out there has an idea of what's going on here?  I've attempted to run it as both system and a user account, and I get the same error both times.  Thanks in advance!