powershell
PowerShell
Tips
自作のスクリプトを動かしたい
$ Set-ExecutionPolicy RemoteSigned -Scope Process
特定の文字列を含むファイルを再帰的に探す
$searchString = "SEATCH TARGET" $directory = "C:\Path\To\Directory" $searchPattern = @("*.txt", "*.csv", "*.log") $searchPattern | ForEach-Object { Get-ChildItem -Path $directory -Recurse -Filter $_ | Select-String -Pattern $searchString }
再帰的にファイルを探す
Get-ChildItem -Name -Recurse | Select-String -Pattern "FILE_NAME"
1秒ごとに1ずつ増やして表示する
while ($i -ne 0) { echo $i; Start-Sleep 1; $i++ }
- CPUへの負荷テスト用のコマンドに1秒の待ちを設定したもの
-ne
は Not Equal
1)
『【負荷テスト】パソコンのCPUに負荷をかける方法』, ばったんの技術系ブログ, https://blackbird-blog.com/cpu-fuka, 2022-12-27
2)
『PowerShellの演算子』, MURA の Home Page, http://www.vwnet.jp/windows/PowerShell/Ope/OpeListg.htm, 2022-12-27
3)
『【PowerShell】指定した期間動作を一時停止する』, ほそぼそプログラミング日記, https://hosopro.blogspot.com/2017/01/powershell-start-sleep.html, 2022-12-27
powershell.txt · 最終更新: 2023/07/26 13:45 by ponzu