PowerShell for SCSM: Portal Requests on Behalf of Another User
The out of the box HTML 5 Portal does not support submitting a request on behalf of another user. This blog post outlines one way that you could implement this functionality.
It uses the Xapity PowerShell Activity task as the first activity on the Service Request template. This could also be implemented as a custom workflow or Orchestrator runbook, but the trigger point and timing can be more difficult to work with.
Another option to consider is the Cireson community (free) Self Service Portal that does have this functionality.
The Request Offering that this was based on was very simple, a password reset request. In this case a user has forgotten their password and a work colleague will submit a Portal request on their behalf to have the password reset.
The User is the person who needs their password reset. This should be the Affected User, but the Portal will automatically put the person submitting the request (who I am calling the Requestor) as the Affected User, ie the work colleague. The User is added to the related config items. The PowerShell script will reverse these so that the User is the affected user and the job is logged against their account.
In this password reset example, the Request Offering only has one user query on the request, and so it is only storing one user in the related config items and it is easy to find target them in PowerShell. If you have two user queries on the Request Offering, it is harder to know which is the submit on behalf of user and you would need to get the data from the user input.
The script first gets the SCSM objects for both the User and the Requestor. It then clears the related config items User and sets the Affected User. It then adds the Requestor to the related Config Items.
I have used the Action Log function from a previous post to record the details in the SR action log.
As this PowerShell Activity runs as the first activity on the Service Request template workflow, the SR is only logged against the Requestor for a short period of time. The rest of the template activity workflow and any notifications from this point, can now use the real user in the Affected User field.
Download script form this link.
Full text of script (HTML formatted):