Is there a way to take the tags from <VM NAME> and copy them to <VM NAME>_replica?
I meant like this
Get-VM | Get-TagAssignment |
ForEach-Object -Process {
New-TagAssignment -Entity "$($_.Entity.Name)_replica" -Tag $_.Tag
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
lol any advice on how to conquer this? I am at a loss on how to do this today.
Use the TagAssignment cmdlets.
Something like this for example.
$vmName = 'MyVM'
$copyVm = "$($vmName)_replica"
Get-VM -Name $vmName | Get-TagAssignment |
ForEach-Object -Process {
New-TagAssignment -Entity $copyVm -Tag $_.Tag
}
.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
That is simple, can I point this at all my VMs and somehow array through all them?
Sure, just leave out the Name parameter on the Get-VM
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I am running this:
$vmName = Get-VM
$copyVm = "$($vmName)_replica"
Get-VM -Name $vmName | Get-TagAssignment | ForEach-Object -Process { New-TagAssignment -Entity $copyVm -Tag $_.Tag }
And when I get to the $copyVm = "$($vmName)_replica" part it combines all the VMs together in one line. The next part then looks for a VM named everything.
I meant like this
Get-VM | Get-TagAssignment |
ForEach-Object -Process {
New-TagAssignment -Entity "$($_.Entity.Name)_replica" -Tag $_.Tag
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference