VMware Cloud Community
thewizard954
Contributor
Contributor

Set-VM -Notes field to the current date .

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

Reply
0 Kudos
22 Replies
LucD
Leadership
Leadership

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

DD_DeenDayal
Contributor
Contributor

Thank you so much

Reply
0 Kudos
DD_DeenDayal
Contributor
Contributor

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
}

Reply
0 Kudos