Execution policy

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

  1. Default is undefined.

2. List

1. Get-ExecutionPolicy -List | Format-Table -AutoSize

2. 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 LocalMachine

2. Self Sign

  1. 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
  1. Copy “Local Code Signing” from personal folder.
  1. certmgr /s my.

2. To

  1. "Trusted Root Certification Authorities".
  1. "Trusted Publishers".
  1. Sign.
1. $cert = @(Get-ChildItem cert:\CurrentUser\My -CodeSigning)[0]
2. Set-AuthenticodeSignature .\<script>.ps1 $cert
  1. Restart shell.
Updated: 2026 Aug 19