Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Export CSV not writing complete information to file

$
0
0

Hi,

I'm unable to export the results for the follwing code. It is Just exporting only one Server information but not all.

When I remove Export-csv comdelet it is showing all Servers informtion on the screen. Could anybody help me out?

$computers = Get-Content -Path C:\servernames.txt

foreach ($computer in $computers)


{

if ($computer)
    {
        $page = Get-WmiObject Win32_PageFileUsage -computername $computer
        $page1 = $page.currentUsage
        $page2 = $page.AllocatedBaseSize
        $page3 = $page.name
        $page4 = $page.peakusage
      
   
      
            New-Object psobject -Property @{
            ComputerName = $computer
            PageFileCurrentusage = $page1
            PagefileSize = $page2
            PagefileName = $page3
            PagefilePeakusage = $page4
          
           
                  
        }  | Select-Object ComputerName,PagefileCurrentusage,PagefileSize,PagefileName,Pagefilepeakusage | Export-Csv  -path  'c:\myresults.csv' -notype

}


}




Viewing all articles
Browse latest Browse all 21975

Trending Articles



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