I am trying to apply a tag based on a combination of cpu and memory. Here is what I have:
$mytag = Get-Tag -Name "Standard"
$vmlist = get-vm | Where ($numcpu -le 2 -And $memoryGB -le 4)
foreach ($vm in $vmlist) {
New-TagAssignment -Tag $Standard -Entity $vm
I am getting no result from the $vmlist variable.
Thanks
Made some changes and here is where I am at:
$mytag = Get-Tag -Name "Standard"
$vmlist = Get-VM | Where-Object { $_.numcpu -le 2 -and $_.memoryGB -le 4} Select Name
foreach ($vm in $vmlist) {
New-TagAssignment -Tag $mytag -Entity $vm
Now I am getting this error when the last line runs:
Never mind.
Here is what worked:
$vmlist = Get-VM | Where-Object { $_.numcpu -le 2 -and $_.memoryGB -le 4}
foreach ($vm in $vmlist) {
New-TagAssignment -Tag Standard -Entity $vm