Can anybody help me out?
I need script that will show me what tag is assigned to a machine but only on machines that are powered off.
So far I have:
Get-VM |
Select-Object Name,
@{N = 'Tags'; E = {(Get-TagAssignment -Entity $_).Tag -join '|'}} |
Export-Csv c:\PoweredOffTag.csv
This brings back the tags for all machines I am not sure where to place the "And" so that it queries just powered off VM's.
TIA.
Just add a Where-clause after the Get-VM, something like this.
Get-VM |
where{$_.PowerState -eq 'PoweredOff'} |
Select-Object Name,
@{N = 'Tags'; E = {(Get-TagAssignment -Entity $_).Tag -join '|'}} |
Export-Csv c:\PoweredOffTag.csv
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Just add a Where-clause after the Get-VM, something like this.
Get-VM |
where{$_.PowerState -eq 'PoweredOff'} |
Select-Object Name,
@{N = 'Tags'; E = {(Get-TagAssignment -Entity $_).Tag -join '|'}} |
Export-Csv c:\PoweredOffTag.csv
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Perfect, Thanks Luc!