Quantcast
Channel: VMware Communities : Unanswered Discussions - vCenter™ Server
Viewing all articles
Browse latest Browse all 3506

Report script help request

$
0
0

Morning all

 

I'm trying to get the below 3 commands into the same CSV, would any kind powershell soul care to help?

 

The below gives an out put of all the associated Tags a VM has:

$tagCat = @()

$tagTab = @{}

foreach($tag in (Get-VM | Get-TagAssignment)){

    $tagCat += $tag.Tag.Category.Name

    $key = $tag.Entity.Name

    if($tagTab.ContainsKey($key)){

    ` $val = $tagTab.Item($key) 

    }

    else{

        $val = @{}

    }

    $val.Add($tag.Tag.Category.Name,$tag.Tag.Name)

    $tagTab[$key] = $val

}

$tagCat = $tagCat | Sort-Object -Unique

$tags = foreach($row in ($tagTab.GetEnumerator() | Sort-Object -Property Key)){

    $obj = New-Object PSObject -Property @{

        VM = $row.Key

    }

    $tagCat | %{

        $obj | Add-Member -Name $_ -Value $row.Value[$_] -MemberType NoteProperty

    }

    $obj

}

$tags | Export-Csv c:\temp\tags.csv -NoTypeInformation -UseCulture

I'd like this merging with the below two:

get-vm | % { get-view $_.id } | select Name, @{ Name="ToolsVersion"; Expression={$_.config.tools.toolsVersion}},@{ Name="ToolStatus"; Expression={$_.Guest.ToolsVersionStatus}}

get-vm -Name pxgbssc1vmc001 | select version

So ultimatley I have a CSV with VM name, associated tags, VMware tools version/status and VM hardware version.

 

Thanks in advance!

Ollie


Viewing all articles
Browse latest Browse all 3506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>