Powershell script execution on Windows Modern Device

Solved

I created a simple package that includes a simple powershell script.

I set the property on the file (in the package) as auto execute.

The script is installed ok, but the script is simply "opened" with notepad.

I even tried changing the app associate with the script file type from notepad to powershell but that made no difference.

Any suggestions?

A.

4 years ago
Windows
ANSWERS
J
JSMOD@SOTI
4 years ago

Hi Andy,

Thank you for posting on SOTI Central.

After adding the Powershell script file to the Package, add a Post-Install Script to the package and put in the full path to the Powershell Executable, as well as parameters to bypass execution policy and the noexit parameter (if you want the console window to persist after execution) and then add the path to the script.

Example:

c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe -noexit -executionpolicy Bypass & "c:\temp\TestScript.ps1"

Kind regards,

Solution

This will work I think! Nice command with bypass and it is need to work!

AM
Andy Murdock
4 years ago

Hi,

Thanks for that.

c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe -executionpolicy Bypass "c:\temp\EASFileShare.ps1" -exit

Worked as we needed - many thanks

Andy