This is the script I use right now to kick out the size of the pagefile and the drive it's on. It writes this info directly to the console. I've got to run this against 900+ vm's so I need it to output to an excel sheet. Any help would be appreciated.
gc 'd:\Powershell Scripts\servers.txt' | % {
$server = $_
$pagefile = gwmi -computer $server Win32_PageFile
foreach($pgf in $pagefile){
$sz += $pgf.FileSize}
$fm = $sz/1GB
Write-Host $fm
Write-Host $pagefile.Drive
}
I need the following colums: VM Name | Pagefile Drive Letter | Pagefile Size.
Some vm's have a pagefile on c:\ AND another one on another drive. I need to account for that in the script so it doesn't screw up the formatting.