Request Custom Menu running PowerShell script from HTML

Request Custom Menu running PowerShell script from HTML

Firstly thanks to 'P Seshadri' for help in this post with out him this would not happen as Manage Engine told me multiple times that this is not possible.

What is it:
A way to present the technician working on a ticket a HTML form which they can fill out and on submit the server will run a PowerShell script to preform some action.

Why:
Presents a simple way to run PowerShell scripts to service desk and ensure that they are running the correct scripts.
Scripts have access to contents of tickets such as requester, ticket number etc so that script can take advantage of API calls to update.

How does it work:
Sample will allow user to input samAccountName and Add\Remove and the script will check to see if there are spare licenses for Zoom and update the security group if required.

Users select the drop down 'Custom Actions' in the ticket and run the required script.

This HTML form is presented to the technician to update


On submit the Action and samAccountName are passed to powershell script and processed.
Using API the script will update the notes in the ticket with the result.

Setup:


Custom HTML File: Sample_Custom_Menu.html
Action Type: Execute script
Script file to run: Powershell.exe -f Sample_Powershell.ps1 $HTML_DATA_JSON_FILE -ExecutionPolicy ByPass

Results: (Note will be added with one of these results)
Success: User has been added to group.
Success: User has been removed from group.
FAILED: Application Access - Zoom Addon - Webinar 500 has reached its maximum of 50 users.
FAILED: Unable to add user to group. Cannot find an object with identity: 'first.last' under: 'DC=domain1,DC=local'.

Files can be found here on GitHub. I opted to use bootstrap to make the HTML easier as i had never leant to code it before.

Please be aware that the admin page says the following

Custom Html File: To load Custom Html File when menu is invoked, you need to place the html file in "[SDP_Home]/Integration/resources/" directory. Files with htt/htx/htm/html/htmls extensions are only supported for invocation. Also, dependency files like JavaScript and CSS have to be placed in the same location.

However from my testing the CSS will not load so you can put any custom CSS into the style tags in the header. CDN's work fine for Java and Bootstrap though.

                  New to ADSelfService Plus?