Run parts of PS-Script as other user
we have a workflow-user who has no permissions for the Active Directory and is only used to run workflows within SCSM. For AD actions we have an ad-connector-user. My goal is to run PS-Scripts executed by the workflow-user and perform some AD actions within the script as the ad-connector-user.
I performed following steps on my SCSM machine:
- logged on as workflow-user
- saved the ad-connector-user credentials with "cmdkey" in the credential manager
- successfully executed a test script as workflow-user with following lines included:
$cred = Get-StoredCredential -Target ad-connector-user | ConvertTo-SecureString
Invoke-Command -Computer scsm-machine -Credential $cred -Authentication CredSSP -ScriptBlock $script -ArgumentList $user_name, $printer_Name
We integrated the PS-Script within an Service Request but there are problems with the "Credential" Parameter (see attached file). Do you have a proper solution to run parts of a script as other user?