If we want to extend our disk checking to multiple machines we can input the computer names via an array.
Script Center Home > Microsoft Windows 2000 Scripting Guide > Scripting Concepts and Technologies for System Administration > VBScript Primer > VBScript Overview Arrays
## listing 2.12
cls
$convert = 1MB
$computers = "pcrs2", "pcrs3", "pcrs4"
$threshold = 100
foreach ($computer in $computers) {
$disks = Get-WmiObject -ComputerName $computer -Class Win32_LogicalDisk
foreach ($disk in $disks) {
$free = [int]($disk.Freespace/$convert)
if ($free -lt $threshold){Write-Host "$computer $($disk.DeviceID) is low on diskspace"}
}
}
We then do a simple foreach loop for each computer in the array and substitute its name into Get-WMIObject. Note that the -Computername parameter of Get-WMIObject does not accept pipeline input so we need a foreach of some kind
Share this post : | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |