Can someone assist me I'm trying to add the current date to the Notes Field in a vm using power shell script.
Get-VM -Name CHISETMCS64282 | Set-VM -Notes "$($_.Notes )" -Confirm:$false
Try like this
Import-Csv -Path .\vmnotes.csv -UseCulture -PipelineVariable row |
ForEach-Object -Process {
Set-VM -VM $row.VMName -Notes ($row.Notes.Split('|') -join "`n") -Confirm:$false
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you so much
I used / for new line as need | also
Import-Csv -Path C:\xxxxx\vmnotes.csv -UseCulture -PipelineVariable row |
ForEach-Object -Process {
Set-VM -VM $row.VMName -Notes ($row.Notes.Split('/') -join "`n") -Confirm:$false
}
to check notes updated below is code
Import-Csv -Path C:\xxxxx\vmnotes.csv -UseCulture -PipelineVariable row |
ForEach-Object -Process {
$vmd1=get-view -viewtype virtualmachine -filter @{"name"= $row.VMName}
$row.VMname
$vmd1.Config.Annotation
}
