Hello,
I need to update all of the VM Notes (about 300 VMs), and I have the info in a CSV file, two columns are in the file, one for VM name, the other for the Note, no column heads in present.
You didn't include a sample entry from your CSV file, but I assume the two columns are separated by a comma.
Then you could do
Get-Content -Path vm-notes-update.csv | ConvertFrom-Csv -Header VMName,Notes | %{
Get-VM -Name $_.VMName | Set-VM -Notes $_.Notes -Confirm:$false
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You didn't include a sample entry from your CSV file, but I assume the two columns are separated by a comma.
Then you could do
Get-Content -Path vm-notes-update.csv | ConvertFrom-Csv -Header VMName,Notes | %{
Get-VM -Name $_.VMName | Set-VM -Notes $_.Notes -Confirm:$false
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hello again, the data is in two columns, do you want me to add a comma in between? , or concatenate the data of two columns into one and add a comma in between?
Can you just check if the following is reading the two columns on each row correctly.
Get-Content -Path vm-notes-update.csv | ConvertFrom-Csv -Header VMName,Notes
You can do a quick test by placing a couple of the lines into an inline string construct.
Something like this
$test = @"
vm1,new note
vm2,new note2
"@
$test | ConvertFrom-Csv -Header VMName,Notes
For the earlier script to work this should return two properties for each line.
Like this
VMName Notes
------ -----
vm1 new note
vm2 new note2
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Worked as smooth as a knife in a piece of butter
Thanks,