PowerShell Genie

Microsoft.PowerShell.Security module: setup and commands

Module 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn

Inspect execution policy, signatures and secure strings with security cmdlets while treating execution policy as a safety feature, not a boundary.

Getting it

Included with PowerShell, although the Cert: provider and the execution policy cmdlets only do meaningful work on Windows.

Examples

1PS> Get-ExecutionPolicy -List
Show reference output
1 Scope ExecutionPolicy
2 ----- ---------------
3 MachinePolicy Undefined
4 UserPolicy Undefined
5 Process Undefined
6 CurrentUser RemoteSigned
7 LocalMachine RemoteSigned
1PS> Get-ChildItem Cert:\LocalMachine\My | Get-Member
Show reference output
1 TypeName: System.Management.Automation.PSCustomObject
2
3 Name MemberType Definition
4 ---- ---------- ----------
5 Equals Method bool Equals(System.Object obj)
6 ToString Method string ToString()
7 Name Property string Name {get;}
8 Status Property object Status {get;}

What it is for

Come here to find out why a script refuses to run, or to check who signed one. It also backs the Cert: drive, which makes it the starting point for certificate expiry audits on a Windows host.

Typical tasks

  • List execution policy by scope
  • Verify an Authenticode signature on a script
  • Enumerate certificates in the LocalMachine store
  • Find certificates close to expiry
  • Prompt for a credential object
  • Sign a script with Set-AuthenticodeSignature

Check the installed version

1PS> Get-Module -ListAvailable Microsoft.PowerShell.Security | Select-Object Name, Version, Path
2PS> Get-Command -Module Microsoft.PowerShell.Security

Compare the module path and version with the session used by your scheduled task or automation account. Come here to find out why a script refuses to run, or to check who signed one. It also backs the Cert: drive, which makes it the starting point for certificate expiry audits on a Windows host.

Primary documentation

Get-Member reference · Get-ChildItem reference

Continue
Genie guideMicrosoft.PowerShell.Security module: setup and commands

Inspect execution policy, signatures and secure strings with security cmdlets while treating execution policy as a safety feature, not a boundary.