Automation Policy Powershell to clear Manager field and hide Exchange account from GAL

Automation Policy Powershell to clear Manager field and hide Exchange account from GAL

Hello,

I was hoping to get some guidance as to what I'm doing wrong with my custom script in an Automation Policy.  I am by no means a script/powershell expert, but I'm hoping I'm on the right track.

Basically I have an automation policy that disables the user, resets the password, and removes all group membership.  I also want it to clear the users Manager field and hide their Exchange account from the GAL.  

I created a powershell to do this, which runs successfully when I specify a specific user and run it manually, but I get an error when the Automation runs.  Here is my setup:

Custom Script:  powershell d:\ManageEngine\Scripts\Manager.ps1 %username%

Manager.ps1 command:

Set-ADUser -manager $null
Set-Mailbox -HiddenFromAddressListsEnabled $true


Error messages received:

Custom Script Result :Set-ADUser : The term 'Set-ADUser' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At D:\ManageEngine\Scripts\Manager.ps1:1 char:1 + Set-ADUser %username% -manager $null + ~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Set-ADUser:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException 

Set-Mailbox : The term 'Set-Mailbox' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At D:\ManageEngine\Scripts\Manager.ps1:2 char:1 + Set-Mailbox -HiddenFromAddressListsEnabled $true + ~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Set-Mailbox:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException


Thank you in advance for your help.

                New to ADManager Plus?

                  New to ADSelfService Plus?