In a co-operate environment checking Drive space is challenging job when it comes to patching. like i said in the previous blog checking one machine could be a easy job but checking in a bulk could be challenging.
Majority of the patches that gets failed – primary reason could be not enough space in the C Drive to it to be installed.
having a clear picture of this issue would give an upper hand. Script below will be able to let you know the free space in the drive.
To show the result in the screen
$Computername = [System.IO.File]::OpenText("machines name in a file.txt")
while($null -ne ($Computer= $Computername.ReadLine())) {
if($?){
Get-WmiObject –ComputerName $Computer–Class Win32_Volume `
|ft –auto $line,`
DriveLetter,`
Computer,`
Label,`
@{Label=”Free(GB)”;Expression={'{0:N0}’ –F ($_.FreeSpace/1GB)}}
}
}
$Computername.Close()
To export to the result to a file use the below.
$Computername = [System.IO.File]::OpenText("machines name in a file.txt")
while($null -ne ($Computer= $Computername.ReadLine())) {
if($?){
Get-WmiObject –ComputerName $Computer–Class Win32_Volume `
|ft –auto $line,`
DriveLetter,`
Computer,`
Label,`
@{Label=”Free(GB)”;Expression={'{0:N0}’ –F ($_.FreeSpace/1GB)}} >> "Output path .txt"
}
}
$Computername.Close()
