Ignore 'Security Warning' running script from command line
This is touched in "PowerShell Execution Policies in Standard Images" on Lee Holmes' Blog and "PowerShell’s Security Guiding Principles" on the Windows Power Shell Blog .
Summary
Some machines treat UNC paths as the big bad internet, so PowerShell treats them as remote files. You can either disable this feature on those servers (UncAsIntranet = 0,
) or add the remote machines to your trusted hosts.
If you want to do neither, PowerShell v2 supports an -ExecutionPolicy
parameter that does exactly what your pseudocode wants. PowerShell -ExecutionPolicy Bypass -File (...)
.
To avoid warnings, you can:
Set-ExecutionPolicy bypass