0
1

More than 3 years have passed since last update.

Windowsでlessみたいにログ監視

Posted at

hoge.ps1

$targetFolderを元にフォルダー一覧をメニュー表示して

入力されたディレクトリ/$targetPathのテキストを表示する

$targetFolder = 'C:\var\log\tomcat';
$targetPath = '\hoge\hoge.log';

cd $targetFolder;

$itemList = Get-ChildItem * | ? { $_.PSIsContainer };
foreach($item in $itemList) {
    Write-Output ([string]$itemList.IndexOf($item) + ':' + $item.Name);
}

$input = Read-Host ('監視対象を入力してください(0~' + ([string]$itemList.Length - 1) + ')');
Write-Output $itemList[[int]$input].Name;

Get-Content -Path ([string]$itemList[$input] + $targetPath) -Tail 0 -Wait;

Read-Host "続けるには Enter キーを押してください..." ;
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1