Powershell script for disk space - pssession

jb65

New Member
I need some help getting the below to work. I must use WinrM witrh a server list.. can anyone help ?

$sessions = get-content D:\Powershell\Space\Allservers.txt | New-PSSession
$block = {
function Get-DriveSpace
{
[cmdletbinding()]
param( [Parameter(Mandatory=$true)]$computer , [int]$thresholdMultiplier=.20 )
[string]$filter = "DriveType = '3'"
try{
Get-WmiObject -class win32_logicaldisk -filter $filter -comp $computer |
Select-Object Name,@{label="SizeMB";Expression={[Math]::Truncate($_.Size / 1MB)}},
@{label="FreeMB";Expression={[Math]::Truncate($_.FreeSpace / 1MB)}},
@{label="WarningMB";Expression={[Math]::Truncate(($_.Size * $thresholdMultiplier) /1MB)}}|
Where-Object{$_.FreeMB -le $_.WarningMB}
} catch {
Write-Verbose "Error $Error in getting disk space for $computer"
}
}
}
[string]$body = Invoke-Command -ScriptBlock $block -Session $sessions | Select sizeMB,freeMB,WarningMB | Sort WarningMB | ConvertTo-Html
Send-MailMessage -SmtpServer " " -From " " -To " " -Subject "Servers Less Than 20% Free" -Body $body -BodyAsHtml
 

My Computer

Hello and welcome to the forum.

I think I know the member who can help you I will forward this to him.
 

My Computer

System One

  • Manufacturer/Model
    a6530f Desktop
    CPU
    HP-PAVILION
    Motherboard
    M2N68-LA (Narra3)
    Memory
    8 Gigs of Ram/DDR2 PC2-6400 MB/sec
    Graphics Card(s)
    NVIDIA GeForce 6150SE nForce 430
    Sound Card
    Intergrated Realtex ALC888S Audio
    Monitor(s) Displays
    LG W40 series widescreen
    Screen Resolution
    1600 X 900
    Hard Drives
    1 640 GB Sata transfer rating: 3.0 Gb/sec speed: 7200 RPM
    PSU
    300W
    Case
    Mid-Size ATX
    Keyboard
    HP Multimedia Keyboard
    Mouse
    Microsoft Wireless Mouse 5000
    Other Info
    Processor: AMD Phenom X3 8450 Operating speed: Up to 2.1 GHz, Number of cores: 3, Socket: AM2+, Bus speed: 3600 MHz HT3 (clocked down to 2000 MHz)

    Modem: 56K WinModem/

    Supermulti: 16X DVD(+/-)R/RW 12X Ram (+/-)R DL Lightscribe SATA Drive

    Menory Card Reader: 15-in-1 Multimedia Card Reader

    Media Drive
Back
Top