Unlock AD Account through ServiceDesk Plus custom menu with PowerShell script
Hi everyone,
Played a bit around with and tried to learn how to use PowerShell scripts triggered by SD Plus. Result of this is the attached script which we now use, triggered by a custom request menu visible when using our "AD account locked" service request template, to unlock AD accounts.
Will also use this as a template to create other scripts in the future. If you've got any scripts you already use, I'd be quite keen to learn what you're doing...
Prerequisites to get SD Plus to run PowerShell scripts:
- SD Plus service needs to run with a user account and not the default system account
- PowerShell execution policy needs to be set so unsigned local scripts can run
- You need to pick a technician to use in the scripts and generate an API key (if you want the script to be able to talk back to SD Plus)
Prerequisites for this particular script:
- User with which the SD Plus service runs, needs to have the necessary rights in Active Directory to unlock accounts
- The "AD DS and AD LDS Tools" Windows Server feature under "Remote Server Administration Tools" > "Role Administration Tools" must be enabled/installed
How we configured it:
- Modify the script with your SD Plus URL and the technician API key
- Store script in .\ManageEngine\ServiceDesk\integration\custom_scripts\
- Create new item under "Request Custom Menu"
- Action Executor : cmd /c start /wait "" powershell.exe -WindowStyle Hidden -file D:\ManageEngine\ServiceDesk\integration\custom_scripts\UnlockADaccount.ps1 $COMPLETE_JSON_FILE
- Html File :
- Associated Templates : User Account locked out - Active Directory
- Associated Roles : All Roles
- Done
What the script does:
- Check, if the account is locked
- If yes, unlock it
- Add a note to the request from which it was triggered about what was done
How to use it:
- Log a request with the template you've specified
- Trigger the script via the Actions menu
- Wait 5 to 10 sec for the script to finish (till you see pop-up that a new note was added)
- Check the notes section
Hope that benefits some of you.
Cheers,
Peter
New to ADSelfService Plus?