Export CSV not writing complete information to file


hi,

i'm unable export results follwing code. exporting 1 server information not all.

when remove export-csv comdelet showing servers informtion on screen. 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

}


}



you can pipe through select fix (just doing in script):

get-content .\computerlist.txt | foreach {      $pagefile = get-wmiobject win32_pagefileusage -computername $_      $props = @{         computername = $_         pagefilecurrentusage = $pagefile.currentusage         pagefilesize = $pagefile.allocatedbasesize         pagefilename = $pagefile.name         pagefilepeakusage = $pagefile.peakusage     }      new-object psobject -property $props  } | select computername,pagefilecurrentusage,pagefilesize,pagefilename,pagefilepeakusage | export-csv .\pagefilestats.csv -notypeinformation


don't retire technet! - (don't give yet - 12,830+ strong , growing)



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

CRL Revocation always failed

Failed to query the results of bpa xpath

0x300000d errors in Microsoft Remote Desktop client