1. 前提设置
对于Windows 10、Windows 7、Windows 8、Windows Server 2008 R2或Windows Server 2012,以管理员身份运行以下命令:
x86(32位) 打开C:\Windows\SysWOW64\cmd.exe 运行命令powershell Set-ExecutionPolicy RemoteSigned
x64(64位) 打开C:\Windows\system32\cmd.exe 运行命令powershell Set-ExecutionPolicy RemoteSigned
2. 样例
test.ps1
Param( $name, $age )
Write-Host "name: $name"
Write-Host "age: $age"
CMD执行:
./test.ps1 -name "xiaoming" -age 20