PowerShell
2022-04-04 (月) 13:16:16
PowerShell とは †
PowerShell のIDE †
- PowerShell ISE
PowerShellの実行ポリシー †
- 実行ポリシーを確認
Get-ExecutionPolicy
- 実行ポリシーを設定
Set-ExecutionPolicy
実行ポリシーの種類 †
- Restricted (デフォルト)
- AllSigned
- RemoteSigned
- Unrestricted
- Bypass
- Undefined
スコープ †
- Set-ExecutionPolicy にScopeオプションとして指定する
- Scopeの種類
- Process
- CurrentUser
- LocalMachine
PowerShell スクリプト †
- スクリプトファイルのファイル名
- 拡張子:.ps1
- スクリプトファイルの実行
- パス指定が必要
./<script-file.ps1>
- パス指定が必要
- スクリプトの実行ポリシーの変更
Set-ExecutionPolicy RemoteSigned
もろもろ †
- PowerShellのバージョン確認
$PSVersionTable
- PowerShell ISE
便利な使い方 †
- Grep
Select-String -Pattern "<keyword-正規表現>" <file-name> | % {$_.ToString()} > <out-file-name>
- Diff(UTF-8)
$a=Get-Content -Encoding UTF8 <file-name1> $b=Get-Content -Encoding UTF8 <file-name2> Compare-Object $a $b
関連サイト †
- PowerShell 開発のための Visual Studio Code の使用
https://docs.microsoft.com/ja-jp/powershell/scripting/components/vscode/using-vscode