cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

call powershell script within shell execute

richard_pietsch
Active Contributor
0 Likes
2,387

Hi all,

hope you can help me with this one as I am totally new to powershell...
I am trying to use a shell execute path with a "start script" A to call another powershell script B.
So, here is the command in IDM:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe A.ps1 -ADuser $FUNCTION.getADcredentials(LDAP_LOGIN)$$ -ADpw $FUNCTION.getADcredentials(LDAP_PASSWORD)$$ -Accountname $FUNCTION.getUserID(%MSKEY%)$$ -Accountpw $FUNCTION.getUserPW(%MSKEY%)$$


Within script A I create a credential object (for the user context script B is executed with):

$credentials = New-Object System.Management.Automation.PSCredential $ADuser,(ConvertTo-SecureString $ADpw -AsPlainText -Force)

The argument/parameter for script B is set:

$psscript = "\\host\idm$\B.ps1 -Username $Accountname -Passwort $Accountpw"

Then, I use a start-process command to execute script B:

$ps = Start-Process powershell -Credential $credentials -argument "$psscript" -PassThru

It does not work... BUT When I run script A with all the parameters in PowerShell application it is executed without issues, also I receive the transciption from script B. What is wrong here?

Regards, Richard


View Entire Topic
richard_pietsch
Active Contributor
0 Likes

Finally ^^

First, noticed that powershell does not like some special characters like & or ( ) when calling a script. Second, no need for the credential object if the separate dispatcher is running under the right useraccount *facepalm