VMware Cloud Community
AlbertWT
Virtuoso
Virtuoso
Jump to solution

How to combine the result of two PowerShell script into one script ?

Hi,

I've got the two lines of PowerShell script that I use to get some ESXi server information, so I wonder how do I combine these two into the single result in a CSV file ?

Get-VMHost | Get-VMHostNetwork | Select Hostname, DomainName, Name, VMHost, DNSAddress | ft -AutoSize

Get-VMHost | Select Name, Version, Manufacturer, Model | ft -AutoSize

Thanks in advance,

/* Please feel free to provide any comments or input you may have. */
1 Solution

Accepted Solutions
kwhornlcs
Enthusiast
Enthusiast
Jump to solution

Something like this should work (Note: for some reason PS will throw a syntax error on this one if you don't remove the extra line breaks when you copy and paste from the post):

Get-VMHost | Get-VMHostNetwork |`

Select `

    @{N='Host';E={$_.VMHost.Name}},`

    @{N='Version';E={$_.VMHost.Version}},`

    @{N='Manufacturer';E={$_.VMHost.Manufacturer}},`

    @{N='Model';E={$_.VMHost.Model}}, DomainName, Name,`

    @{N="DNSAddresses";E={[string]::join(";",($_.DNSAddress))}}|`

Export-Csv c:\vmtntest.csv -NoTypeInformation -UseCulture

View solution in original post

2 Replies
kwhornlcs
Enthusiast
Enthusiast
Jump to solution

Something like this should work (Note: for some reason PS will throw a syntax error on this one if you don't remove the extra line breaks when you copy and paste from the post):

Get-VMHost | Get-VMHostNetwork |`

Select `

    @{N='Host';E={$_.VMHost.Name}},`

    @{N='Version';E={$_.VMHost.Version}},`

    @{N='Manufacturer';E={$_.VMHost.Manufacturer}},`

    @{N='Model';E={$_.VMHost.Model}}, DomainName, Name,`

    @{N="DNSAddresses";E={[string]::join(";",($_.DNSAddress))}}|`

Export-Csv c:\vmtntest.csv -NoTypeInformation -UseCulture

AlbertWT
Virtuoso
Virtuoso
Jump to solution

many thanks, kwhornlcs, it is working as expected and I learn something new too from your script.

/* Please feel free to provide any comments or input you may have. */
Reply
0 Kudos