开发者

PowerShell execution policy

开发者 https://www.devze.com 2023-04-03 17:30 出处:网络
I am running an EXE file from a mapped drive and supplying a few arguments while running it (it is an update/hotfix). However, the /q or silent operation switch is not honored when the EXE file is run

I am running an EXE file from a mapped drive and supplying a few arguments while running it (it is an update/hotfix). However, the /q or silent operation switch is not honored when the EXE file is run from the mapped network drive. If the same EXE file is copied over locally, it works fine.

I am running

Start-Process -Fi开发者_如何学Golepath "z:\abc.exe" -ArgumentList '/quiet /norestart' -Wait 

This pops up a dialog box to confirm my action, but I want to suppress it.

If I copy abc.exe locally and run,

Start-Process -Filepath "c:\abc.exe" -ArgumentList '/quiet /norestart' -Wait 

it just works fine.

I checked Execution policy and it is set to Unrestricted. How can I fix this?


The dialog may be a security warning that you are installing something over the network and not related to the quiet install of the EXE file.


I encountered the problem when I added a network path (letter or UNC - I don't remember) to $env:PSModulePath. Each time I wanted to load a module from the network, a warning message appeared. It may be the same thing if you want to . source a PS1 file from a network drive in the user's profile.

It was coming from an Internet Explorer policy: Some machines are configured to treat UNC paths as the same security zone as the Internet (as opposed to the intranet.) This is Internet Explorer’s "Enhanced Security Configuration". In this case, PowerShell responds the same as the Windows Explorer shell when it runs scripts from a UNC path:

“while scripts from the Internet can be useful, this script can potentially harm your computer. Do you want to run <script>?”

One way to fix this is by adding the source server to Internet Explorer’s Trusted Sites, or changing the “UncAsIntranet” configuration property.

You can also have a look to this: The EXE files coming from a download are locked.

And NTFS keeps track of that in the file extended attribute. Look in the properties of the EXE file (sorry, in French. Here the 'Débloquer' button is the 'Unlock' button):

PowerShell execution policy

0

精彩评论

暂无评论...
验证码 换一张
取 消