VMware Cloud Community
COS
Expert
Expert
Jump to solution

CSV or Tab Seperated output for my script...

My script below.

How can I get this to have comma separated or Tab separated values and output to text file?

$myCol = @()

foreach ($cluster in Get-Cluster)

    {

        foreach($vmhost in ($cluster | Get-VMHost))

        {

            foreach($vm in (Get-VM -Location $vmhost)){

                $VMView = $vm | Get-View

                $VMSummary = "" | Select ClusterName,VMName,VMSockets,VMCores

                $VMSummary.ClusterName = $cluster.Name

                $VMSummary.VMName = $vm.Name

                $VMSummary.VMSockets = $VMView.Config.Hardware.NumCpu

                $VMSummary.VMCores = $VMView.Config.Hardware.NumCoresPerSocket

                $myCol += $VMSummary

            }

        }

    }

Data is in the variable $myCol but when I add the "Export-Csv C:\Temp\Test.txt" to the end, no data.

0 Kudos
1 Solution

Accepted Solutions
COS
Expert
Expert
Jump to solution

lol........duh the syntax is this....

$myCol | Export-Csv C:\Temp\Test.txt

View solution in original post

0 Kudos
1 Reply
COS
Expert
Expert
Jump to solution

lol........duh the syntax is this....

$myCol | Export-Csv C:\Temp\Test.txt

0 Kudos