get-vmhost の出力をタイムスタンプ付きの csv ファイルに出力したいと思います。Get-vmhost コマンドにはタイムスタンプ出力がありません。timestamp=(get-date) を実行しようとしましたが、パイプを使用しようとするとエラーが発生します。そのcsvファイルに値を含むタイムスタンプ列を挿入する方法はありますか?
if ( (Get-PSSnapin -Name VMware.VimAutomation.Core -ErrorAction SilentlyContinue) -eq $null )
{
Add-PSsnapin VMware.VimAutomation.Core
}
$Server="dc1-vc.example.com"
Connect-VIServer -server $Server -User <id> -Password <pass>
$Timestamp=(get-date)
Get-VMHost | Where-Object {$_.PowerState -eq "PoweredOn"} | Select-Object Timestamp, Name, NumCpu, CpuUsageMhz, CpuTotalMhz, MemoryUsageGB, MemoryTotalGB |
ConvertTo-Csv -NoTypeInformation |Out-File -Append -Encoding ascii -FilePath "c:\output\new_dc1.csv"
Disconnect-VIServer -Server $Server -Confirm:$false
エラー:
The term 'Timestamp=' is not recognized as the name of a cmdlet, function, scri
pt file, or operable program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try again.