Hi,
here is the script I would like,
I would like to list the vms that are on windows in the DMZ cluster and have the following 2 tags:
1_Tt_le_tps and criticite_moyenne
but I have nothing on the file out
can you help please ?
Connect-viserver vcenter01 -user vcenter -pass password
(Get-Cluster "DMZ" | Get-VM | where{$_.Guest.OSFullName -match "Windows"} |
Get-TagAssignment | where{$_.Tag -like '1_Tt_le_tps*' -and $_.Tag -like 'criticite_moyenne*' }).Entity.Name |
Out-File -FilePath C:\Scripts\Tags_patch\resultats\vms-tag-1_Tt_le_tps_DMZ_criticite_moyenne.txt
Try like this
Get-Cluster "DMZ" | Get-VM | where{$_.Guest.OSFullName -match "Windows"} |
Get-TagAssignment | where{$_.Tag.Name -like '1_Tt_le_tps*' -and $_.Tag.Name -like 'criticite_moyenne*' } |
Select @{N='VM';E={$_.Entity.Name}} |
Out-File -FilePath C:\Scripts\Tags_patch\resultats\vms-tag-1_Tt_le_tps_DMZ_criticite_moyenne.txt
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
no error but no result, while I must have
Can you show what a Get-TagAssignment produces as output?
With no While-clauses active?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
PowerCLI C:\> Get-TagAssignment | where{$_.Tag.Name -like '1_Tt_le_tps*' -and $_
.Tag.Name -like 'criticite_forte*' }
Get-TagAssignment : 13/03/2018 13:31:26 Get-TagAssignment
com.vmware.vapi.std.errors.internal_server_error {'messages':
[com.vmware.vapi.std.localizable_message {'id':
vapi.bindings.method.impl.unexpected, 'default_message': Provider method
implementation threw unexpected exception: Read timed out, 'args': [Read timed
out]}], 'data':}
At line:1 char:1
+ Get-TagAssignment | where{$_.Tag.Name -like '1_Tt_le_tps*' -and $_.Ta ...
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-TagAssignment], CisExcept
ion
+ FullyQualifiedErrorId : VMware.VimAutomation.ViCore.Impl.V1.Service.Tagg
ing.Cis.TaggingServiceCisImpl.GetTagAssignment.Error,VMware.VimAutomation.
ViCore.Cmdlets.Commands.Tagging.GetTagAssignment
Do you also get that error when you just do a Get-TagAssignment without anything else?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes
Are you already using PowerCLI 10?
There were some Tag related issues fixed in 10.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I use PowerCLI 6.5 release1.
I did not succeed to download the version 10
What exactly is the download problem you have?
If you have at least one station with an Internet connection, you can use the Offline Install of PowerCLI to a Computer Without an Internet Connection from
Welcome PowerCLI to the PowerShell Gallery – Install Process Updates
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
As an alternative (at least when you are on Vsphere 6.5) you can use my rCisTag module.
It has the same Tag cmdlets, but uses the REST API, and doesn't have the known issues from earlier PowerCLI releases.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference