Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 232869

Re: PowerCLI script to find disconnected VMs

$
0
0

That might be a problem with the foreach loop, that normally doesn't place objects in the pipeline.

Execute the code as a block and pipe that to the Export-Csv

 

&{Get-VM|?{$_.PowerState-eq"PoweredOn"} |%{    $strVMName=$_.Name;Get-NetworkAdapter-VM$_|
       
select@{n="VMName";e={$strVMName}},Name,NetworkName,ConnectionState} |
        ?
{$_.ConnectionState.Connected-eq$false}} |Export-CsvC:\report.csv-NoTypeInformation-UseCulture

Viewing all articles
Browse latest Browse all 232869

Trending Articles



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