Custom Script to write to Description field

Custom Script to write to Description field

Hello All,

Just sharing in the event anyone else needs to do this and is having trouble.

As part of our disable user policy, we run a custom powershell script to write "Diasabled -Month -Year" in the user's description field.  ie: DISABLED July 2019 

To call the script place this in the custom script command line/box:
powershell .\scriptname %userName%  for example: powershell .\disableDescription.ps1 %userName%

The script itself:
  1. $admgr_user = $args[0]
  2. #Importing Module
  3. Import-Module Activedirectory
  4. $Month = get-date -UFormat %B
  5. $Year = Get-Date -UFormat %Y
  6. Set-ADUser -Identity $admgr_user -Description "DISABLED - $Month $Year"
The script is in the bin folder of the ADManager server ie: C\ManageEngine\ADManager PLus\bin\disableDescription.ps1

Hope this helps someone as I was having issues with IO Exception error and it had to do with how you call the script within ADManager: powershell .\script.pst %variable%

Cheers!

                  New to ADSelfService Plus?