To
Prevent unintentional execution of scripts.
Not to restrict the user’s ability to run as he can bypass.
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7
1. Change execution policy
- Default is undefined.
2. List
1. Get-ExecutionPolicy -List | Format-Table -AutoSize2. Result
1.
Scope ExecutionPolicy.
2.
----- ---------------.
3. MachinePolicy
Undefined.
4.
UserPolicy Undefined.
5.
Process Undefined.
6.
CurrentUser Undefined.
7.
LocalMachine AllSigned.
3. Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine2. Self Sign
- Sits in the file property.
https://community.spiceworks.com/how_to/153255-windows-10-signing-a-powershell-script-with-a-self-signed-certificate
New-SelfSignedCertificate -CertStoreLocation cert:\currentuser\my `New-SelfSignedCertificate -Subject "CN=Local Code Signing" `-Subject -KeyAlgorithm RSA `-KeyAlgorithm -KeyLength 2048 `-KeyLength -Provider "Microsoft Enhanced RSA and AES Cryptographic Provider" `-Provider -KeyExportPolicy Exportable `-KeyExportPolicy -KeyUsage DigitalSignature `-KeyUsage -Type CodeSigningCert- Copy “Local Code Signing” from personal folder.
- certmgr /s my.
2. To
- "Trusted Root Certification Authorities".
- "Trusted Publishers".
- Sign.
1. $cert = @(Get-ChildItem cert:\CurrentUser\My -CodeSigning)[0]2. Set-AuthenticodeSignature .\<script>.ps1 $cert- Restart shell.
Updated:
2026 Aug 19


