Run a Powershell script from Keybreeze

Is there a way to run a Powershell script from Keybreeze?

If I try this it doesn't work from Keybreeze but it does work from the Windows Run box.

powershell.exe C:\Powershell\AWS.ps1

 


4 comments.




ecarr   1 year ago

Use the full path where powershell.exe is located, then the path of the script.  

Brian Henke   1 year ago

I tried C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe C:\Powershell\AWS.ps1 and that launched Powershell but it closed right away. The script has prompts and should wait for input from me. Pasting the comand into run still works with this.

Andrew Langford   1 year ago

Hi Brian,

Good to hear from you! I tried ecarr's suggestion with a test Powershell script, and the prompt appeared in my environment. The target of my keyword is:

C:\windows\system32\windowspowershell\v1.0\powershell.exe c:\test\test.ps1

The text of this Powershell script is:

$User = Read-Host -Prompt 'What is your name?'
Write-Host "You entered, '$User'"

When I run this from the Start > Run dialog box, I get the prompt, enter my name, and then it closes. When I run this from Keybreeze, I get the same behavior, which appears to be expected when running Powershell scripts from outside the console -- https://stackoverflow.com/questions/16739322/how-to-keep-the-shell-window-open-after-running-a-powershell-script.

I was able to keep the Powershell script window open by changing my target to the following.

C:\windows\system32\windowspowershell\v1.0\powershell.exe -NoExit "c:\test\test.ps1"

Let me know if the -NoExit switch works for your script.

Thanks,

Andrew

 

Brian Henke   1 year ago
Thanks Andrew, the noExit showed me that I needed to set the execution policy. https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.2 I set the current user to unrestricted and it is working now. Thanks for the help.