Hi all,
i want to set each VM with a different description.
ForEach ($VM in Get-Content D:\VM.txt) {
ForEach ($Purpose in Get-Content D:\Purpose.txt) {
Set-Annotation -Entity $VM -CustomAttribute "Purpose" -Value $Purpose
}
}
But now, each VM is getting all "purpose" descriptions, before the script start to edit the next VM in the VM.txt list
How will
VM1 get purpose description 1
VM2 get purpose description 2
VM3 get purpose description 3
The easiest would be if you combine those 2 files in 1 CSV file.
But with your files you could do
$vmNames = Get-Content D:\VM.txt
$purpose = Get-Content D:\Purpose.txt
0..($vmNames.Count - 1) | foreach {
Get-VM -Name $vmNames[$_] : Set-Annotation -CustomAttribute 'Purpose' -Value $purpose[$_]
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks!!!
Working!!!
You saved my life 😃
Have a nice weekend