Run a action with variables and exectute a PS1 script on a server

// Set variables
parameter “user” = “Domain\user”
parameter “password” = “password”
parameter “scriptPath” = “D:\Commvalut script\system-integration-scripts-dev\system-integration-scripts-dev\pre_patch.ps1”
parameter “commVault” = “redactedhost”

// Run the PowerShell script as the specified user
wait runas /user={parameter “user”} /password={parameter “password”} powershell.exe -ExecutionPolicy Bypass -File “{parameter “scriptPath”}” “{paramter “commVault”}”

the action fails as shown below from log file. so where is the problem in the script

Report posted successfully
At 12:37:33 -0600 - mailboxsite (http://redactedhost:52311/cgi-bin/bfgather.exe/mailboxsite1090245703)
Relevant - BAAS Stage 0 - Pre PS 1 Action (fixlet:104399)
At 12:37:33 -0600 -
ActionLogMessage: (action:104399) Action signature verified for Execution
ActionLogMessage: (action:104399) starting action
At 12:37:34 -0600 - actionsite (http://redactedhost:52311/cgi-bin/bfgather.exe/actionsite)
Command succeeded parameter “user” = “domain\user” (action:104399)
Command succeeded parameter “password” = “password” (action:104399)
Command succeeded parameter “scriptPath” = “D:\Commvalut script\system-integration-scripts-dev\system-integration-scripts-dev\pre_patch.ps1” (action:104399)
Command succeeded parameter “commVault” = “redactedhost” (action:104399)
Command failed (Relevance substitution failed) waithidden runas /user={parameter “user”} /password={parameter “password”} powershell.exe -ExecutionPolicy Bypass -File “{parameter “scriptPath”}” {paramter “commVault”} (action:104399)
At 12:37:34 -0600 -
ActionLogMessage: (action:104399) ending action
At 12:37:34 -0600 - mailboxsite (http://redactedhost:52311/cgi-bin/bfgather.exe/mailboxsite1090245703)
Not Relevant - BAAS Stage 0 - Pre PS 1 Action (fixlet:104399)

In your wait command you mistyped it as paramter instead of parameter

wait runas /user={parameter “user”} /password={parameter “password”} powershell.exe -ExecutionPolicy Bypass -File “{parameter “scriptPath”}” “{paramter “commVault”}”

2 Likes

and don’t worry that happens to the best of us.

I am now getting failed code = 1 Here is the setup

// Enter your action script here

// Set variables
parameter “user” = “Domain\username”
parameter “password” = “password”
parameter “scriptPath” = “D:\Commvalut script\system-integration-scripts-dev\system-integration-scripts-dev\pre_patch.ps1”
parameter “commVault” = “Hostname.domain.com
// Run the PowerShell script as the specified user
wait runas /user={parameter “user”} /password={parameter “password”} powershell.exe -ExecutionPolicy Bypass -File “{parameter “scriptPath”}” “{parameter “commVault”}”

log file

Relevant - BAAS Stage 0 - Pre PS 1 Action (fixlet:104905)
At 10:26:45 -0600 -
ActionLogMessage: (action:104905) Action signature verified for Execution
ActionLogMessage: (action:104905) starting action
Command succeeded parameter “user” = “domain\username” (action:104905)
Command succeeded parameter “password” = “password” (action:104905)
Command succeeded parameter “scriptPath” = “D:\Commvalut script\system-integration-scripts-dev\system-integration-scripts-dev\pre_patch.ps1” (action:104905)
Command succeeded parameter “commVault” = “host.domain.com” (action:104905)
Command started - wait runas /user=domain.com\username /password=password powershell.exe -ExecutionPolicy Bypass -File “D:\Commvalut script\system-integration-scripts-dev\system-integration-scripts-dev\pre_patch.ps1” “host.domain.com” (action:104905)
Command succeeded (Exit Code=1) wait runas /user=domain.com\username /password=password powershell.exe -ExecutionPolicy Bypass -File “D:\Commvalut script\system-integration-scripts-dev\system-integration-scripts-dev\pre_patch.ps1” "host.domain
ActionLogMessage: (action:104905) ending action
Not Relevant - BAAS Stage 0 - Pre PS 1 Action (fixlet:104905)

google showed this option

runas (parameter “username”, parameter “password”) wait same failed exit code 1

Not sure what OS you’re running, but I’ve never encountered ‘/password’ as an allowed parameter on the ‘runas’ command. It’s not supported on my Win11 or Win2022.

was not expecting it to run just saw example on google search. The other was expected to complete. Is there a way to add debug without using the 1000 option as it writes out lots of redundant info of no importance to this type of issue. i just don’t know what is wrong based on code. His there a tool can show me what the action is running to see why it exits

Well the first thing to try is just to find a command that works on the plain-old command line. Open a command prompt and try the command you’re executing -

runas /user=domain.com\username /password=password powershell.exe -ExecutionPolicy Bypass -File "D:\Commvalut script\system-integration-scripts-dev\system-integration-scripts-dev\pre_patch.ps1" "http://host.domain.com”

That already won’t work because runas.exe does not accept a ‘password=’ parameter. Runas does not provide a way to supply the password on the command line, as far as I know. And also I think you misspelled ‘commvault’.

Next, once you have figured out the right command line that does what you want it to do, without prompting for any user info, you should test it in an environment similar to what BigFix is using. That means running the command as the LocalSystem account. Download psexec from www.microsoft.com/sysinternals , and use the command psexec -i -s cmd.exe to launch an interactive command prompt running as LocalSystem. Check that your command line works in that environment too.

Finally, you’ll want BigFix to execute your command in the native/64-bit mode. By default when we launch commands we run them in 32-bit mode, for backward compatibility, but that’s almost never what you want with new content. add the line
action uses wow64 redirection false to your actionscript, anywhere before the ‘wait’ command.

Hope this helps