Mark Zocher Formation Lap

As part of our account deletion, I configured a custom script to run against the username (under Admin->Delete/Disable Policy).  However, the command isn't being passed the username or department when I use the %username% and %department% variables (they work for all other custom scripts I've implemented with ADManager).  Is this functionality not available when an account is deleted?  Or is there something I'm missing?

Custom script I'm running:

powershell c:\AcctScripts\RemoveFDrive.ps1 -Username %userName% -Department '%department%'


Custom Script Result :C:\AcctScripts\RemoveFDrive.ps1 : Missing an argument for parameter 'username'. Specify a parameter of type 'System.String' and try again. At line:1 char:33 + c:\AcctScripts\RemoveFDrive.ps1 -Username -Department '' + ~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [RemoveFDrive.ps1], Paramet erBindingException + FullyQualifiedErrorId : MissingArgument,RemoveFDrive.ps1

Topic Linked:
This topic has been linked to : Pass the newly created user account.... Please refer this topic for further details.

Replies (3)

Scott Employee
Hi Mark,

The custom script option under Admin-->Delete Policy allows you to execute a custom script whenever an account is deleted using ADManager Plus. The script requires an argument to pass value to the variable. Define an Argument in the script and the syntax. Also, request you to try executing the script separately in PowerShell and check whether the script executes fine.

For Ex:

powershell c:\AcctScripts\RemoveFDrive.ps1 -Arg1 %userName%

The Result would be C:\AcctScripts\RemoveFDrive.ps1 -ARG1 username of the user

ADManager Plus Team
ADManager Plus - Active Directory Management & Reporting Software
Mark Zocher Formation Lap
Hi Scott, I tried that earlier - I even used the exact same syntax as other custom scripts that work fine.  If this command:

      powershell c:\AcctScripts\RemoveFDrive.ps1 -Username %userName% -Department '%department%'

is still supplying a blank Username, do I need to engage support?

Nenad Bojovic Formation Lap
hi Mark

try passing %SamACcountName% instead of %username% that worked for me