以下の内容のファイルtranscript-test.ps1があります
$log="TestLog{0:yyyyMMdd-HHmm}" -f (Get-Date) $logfile = 'C:\logs\'+$log+'.txt' Start-transcript -path $logfile -force Write-host "このメッセージがログに記録されるかどうかをテストするには" Stop-transcript
Lets say "box1" からスクリプトを実行しようとしましたが、ログ ファイルには以下の内容が含まれています。
** * ** * ** * * Windows PowerShell Transcript Start Start time: 20110105114050 Username : domain\user Machine : BOX1 (Microsoft Windows NT 5.2.3790 Service Pack 2) * ** * ** * ** * Transcript started,出力ファイルは C:\logs\TestLog20110105-1140.txt です
このメッセージがログに記録されるかどうかをテストするには
** * ** * ** * * Windows PowerShell トランスクリプト終了終了時刻: 20110105114050
以下のスクリプトを使用して別のマシンから同じスクリプトを実行すると、ログ ファイルにメッセージが表示されません。
Invoke-command {powershell.exe -ExecutionPolicy Unrestricted -NoProfile -File C:\in ll\transcript-test.ps1} -computername box1 -credential $credential get-credential
ログファイルの内容:
** * ** * ** * * Windows PowerShell Transcript Start 開始時刻: 20110105114201 ユーザー名: DOMAIN\user マシン: BOX1 (Microsoft Windows NT 5.2.3790 Service Pack 2)
** * ** * ** * * Windows PowerShell トランスクリプト終了終了時刻: 20110105114201
リモートで呼び出されたときにスクリプトからログファイルにメッセージを記録する方法はありますか?
ありがとう!サンジーブ