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
}
}