$PSVersionTable
PS F:\work> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.14393.223
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.223
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
F:\Work>type .\test.ps1
exit 2
F:\Work>powershell .\test.ps1
F:\Work>echo %ERRORLEVEL%
1
powershell <スクリプトファイル>;exit $LASTEXITCODE
F:\Work>type .\test.ps1
exit 2
F:\Work>powershell .\test.ps1;exit $LASTEXITCODE
F:\Work>echo %ERRORLEVEL%
2
PS F:\Work> .\test.ps1 .\test.ps1 : このシステムではスクリプトの実行が無効になっているため、ファイル F:\Work\test.ps1 を読み込むことができません。詳細については、「about_Execution_Policies」(http://go.microsoft.com /fwlink/?LinkID=135170) を参照してください。
発生場所 行:1 文字:1 + .\test.ps1 + ~~~~~~~~~~ + CategoryInfo : セキュリティ エラー: (: ) []、PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
powershell.exe -Command "Get-ExecutionPolicy"
「Restricted」が表示されたら権限がついていないため、以降の手順を行う。powershell.exe -Command "Set-ExecutionPolicy RemoteSigned"
powershell.exe -Command "Get-ExecutionPolicy"
最新記事
プロフィール