I have a csv with 2 columns. First column is a list of vmguest names and the second is an annotation I want to add to those vmguests. I basically want to add a unique key for each vmguest. So I'm using this script.
csv file
vmguestname,vmguestkey
name1,key1
name2,key2
name3,key3
script
$csv = (Import-Csv "annotations.csv")
$vmguestkey = ($csv.vmguestkey)
$vmguestname = ($csv.vmguestname)
foreach ($computer in $vmguestname){
Set-Annotation-Entity $computer -CustomAttribute "Key" -Value $vmguestkey
}
When I run the script I get a message
Set-Annotation : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'Value'. Specified method is not supported.
Any idea what could I be doing wrong?
Try like this
foreach ($computer in (Import-Csv "annotations.csv")){
Set-Annotation-Entity $computer.vmguestname -CustomAttribute "Key" -Value $computer.vmguestkey
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try like this
foreach ($computer in (Import-Csv "annotations.csv")){
Set-Annotation-Entity $computer.vmguestname -CustomAttribute "Key" -Value $computer.vmguestkey
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
it worked. thanks!