-
Notifications
You must be signed in to change notification settings - Fork 89
removing multiple security tags from VMs #590
Comments
Hi, i think the returned value is not the same between there is one or multiple tags. i will check |
Thanks for checking. When I run this script against VMs with one security tag applied to them it works great. If I add multiple security tags to the VM it errors out and doesn't remove the tags. Please let me know what you find. I have been trying to work on a work around and I can't come up with anything that works. So if you have an idea that would be great! |
i have make some try and working for me... What PowerNSX release do you are using ? and NSX ? What the output of $VM = Get-VM | Where-Object { $_.Name -like 'ERIC' }
get-vm $VM | Get-NsxSecurityTagAssignment |
PowerNSX version is 3.0.1125 Here is the output: {APP-OTHER, APP-A-STAGING} ERICTESTEDC01 This is where I am running into trouble, running this: $VM = Get-VM | Where-Object { $_.Name -like 'ERIC' } In the example above, when the VM has more then a single Security Tag this fails. To remove any security tag. If I manually remove one of the security tags and then run the above commandlet it works fine. It just doesn't seem to like when the VM has more then one security tag attached. |
if you try with only one VM ? |
PS C:> get-vm -name ERICTEST10 | Get-NsxSecurityTagAssignment | Remove-NsxSecurityTagAssignment -confirm:$false
|
git master branch??? Sorry I don't know what that is. |
Hi, Use last dev release available on github (not yet push on PS Gallery) |
Hello,
I am trying to remove multiple security tags from VMs with a certain name. Here is my code:
$VM = Get-VM | Where-Object { $_.Name -like 'ERIC' }
get-vm $VM | Get-NsxSecurityTagAssignment | Remove-NsxSecurityTagAssignment -confirm:$false
When I run this I get the following error:
Remove-NsxSecurityTagAssignment : Cannot validate argument on parameter 'TagAssignment'. Specify a valid Security Tag Assignment.
At line:2 char:45
The VM in question has two security tags: {APP-OTHER, APP-A-STAGING} ERICTEST04
If I remove one of the security tags manually, so there is only one security tag assigned it works great. But it will not remove multiples.
I am using the PowerNSX Document for Remove-NsxSecurityTagAssignment
This cmdlet is used to remove NSX Security Tags assigned to a virtual machine
A NSX Security Tag is a arbitrary string. It is used in other functions of
NSX such as Security Groups match criteria. Security Tags are applied to a
Virtual Machine.
This cmdlet assigns is used to remove NSX Security Tags assigned to a virtual machine
Get-VM Web01 | Get-NsxSecurityTagAssigment | Remove-NsxSecurityTagAssignment
Any ideas?
The text was updated successfully, but these errors were encountered: