I'm in need of a script that will tag all of the VMs that we have with "_replica" in the name. I am just getting familiar with PowerCLI and don't know enough to create the script but we have an immediate need for it so I'm hoping someone here can get me started. I plan to schedule the script to run periodically (assuming this can be done) to ensure that all replica VMs are tagged properly so they are excluded from backup and replication jobs (we exclude them by tag in Veeam).
Thanks for the help.
Matt
How about something like this?
$mytag = Get-Tag -Name "MyTag"
$vmlist = get-vm | Where-Object {$_.name -like '*_Replica*'}
foreach ($vm in $vmlist) {
New-TagAssignment -Tag $mytag -Entity $vm
}
How about something like this?
$mytag = Get-Tag -Name "MyTag"
$vmlist = get-vm | Where-Object {$_.name -like '*_Replica*'}
foreach ($vm in $vmlist) {
New-TagAssignment -Tag $mytag -Entity $vm
}
That did the trick! Thank you very much.