|
|
When the script is setup to run as a Scheduled Task on a Server 2008R2, it returns all columns empty, except the Freespace % column as NaN and in red. I don't see NaN in the code anywhere. The script executes fine when run directly from the ps1 or when running from a batch that points to powershell.exe C:\CheckDiskSpace_post.ps1 What are the correct settings to have this run as a scheduled task on an hourly interval. Thank you!
I found that to get the Task to run I need to place the location of files in the start in location for the Task.
Hey Mike, Rookie to scripting, testing your script and got it to work great but after the last server on the list it comes up with error and repeats the disk space like 3 times EXSNGBRK2 C: percentage free space = 57.76 Get-WmiObject : Cannot validate argument on parameter 'ComputerName'. The argument is null or empty. Supply an argument that is not null or empty and then try the command again. At line:3 char:38 + $disks = Get-WmiObject -ComputerName $computer -Class Win32_LogicalDisk -Filter ... + ~~~~~~~~~ + CategoryInfo : InvalidData: (:) [Get-WmiObject] , ParameterBindin gValidationExce ption + FullyQualifiedE rrorId : ParameterArgume ntValidationErr or,Microsoft.Po werShell.Comman ds.GetWmiObject Command C: percentage free space = 57.76 Get-WmiObject : Cannot validate argument on parameter 'ComputerName'. The argument is null or empty. Supply an argument that is not null or empty and then try the command again. At line:3 char:38 + $disks = Get-WmiObject -ComputerName $computer -Class Win32_LogicalDi sk -Filter ... + ~~~~~~~~~ + CategoryInfo : InvalidData: (:) [Get-WmiObject] , ParameterBindin gValidationExce ption + FullyQualifiedE rrorId : ParameterArgume ntValidationErr or,Microsoft.Po werShell.Comman ds.GetWmiObject Command C: percentage free space = 57.76 Get-WmiObject : Cannot validate argument on parameter 'ComputerName'. The argument is null or empty. Supply an argument that is not null or empty and then try the command again. At line:3 char:38 + $disks = Get-WmiObject -ComputerName $computer -Class Win32_LogicalDi sk -Filter ... + ~~~~~~~~~ + CategoryInfo : InvalidData: (:) [Get-WmiObject] , ParameterBindin gValidationExce ption + FullyQualifiedE rrorId : ParameterArgume ntValidationErr or,Microsoft.Po werShell.Comman ds.GetWmiObject Command any help would be appreciated Thanks
Hi, I am a rookie at scripting, I have ran this script and it is great but I only need report for the C Drive on all my servers, How could I change this script to only display C Drive in the report? Thanks In Advance
Hello, thanks for this great script. but I tested on several servers, most of them can't be shown all of their logical drivers from this script. But if I just use: Get-WmiObject -Class Win32_LogicalDisk -Filter "DriveType = 3" from powershell, it shows all of the logical drivers. In plus, some of the commands in this script seem to be not compatible with windows server 2011 SBS. Thank you again
Hi there.. I'm getting following error while sending mail: Exception calling "Send" with "1" argument(s): "Failure sending mail." At F:\OSR\ToolDev\DiskCleanupNewD ev\DeleteOldFil es_Notification .ps1:44 char:13 + $smtp.Send <<<< ($msg) + CategoryInfo : NotSpecified: (:) [], MethodInvocatio nException + FullyQualifiedE rrorId : DotNetMethodExc eption My e-mail sending script is something like this. Am I missing anything here? Write-Host "Sending Email notification to $user" $smtpServer = "smtprelay.xxxx .com:25" $smtp = New-Object Net.Mail.SmtpCl ient($smtpServe r) $cred = New-Object System.Net.Netw orkCredential $cred.Domain = "xxxxx" $cred.Username = "xxxx" $cred.Password = "xxxx" $smtp.Credentia ls=$cred $msg = New-Object Net.Mail.MailMe ssage $msg.From = "myfirstname.my lastname@mycomp any.com" $msg.To.Add("my firstname.mylas tname@mycompany .com") $msg.Body = "1" $smtp.Send($msg ) Please help?
Hi there This is a very nice script and exactly what I needed. However, we have a large number of Server VMs with swap drives stored on S: Drive. Is there a way to ignore this particular drive? Thanks for your help. Regards Steve
Nice report Mike. how can we run this so it will get trigger at the space level.
Hi Mike, I have run the Script on a Windows 2008 Server, but the HTML file is created ,but the report is Blank. Regards Balaji
GSenanayake, The only way that I am aware of doing that is in Windows Server 2008 R2/Windows 7. You have to set a trigger using scheduled tasks that detects when the disk space is low and then runs the report. -Rich
Balaji, you will most likely need to modify the following line to a folder that exists. $reportPath = "D:\Jobs\DiskSpaceQuery\Report s\";
Balaji, The code is on the page has a smallest error. Mike forgot a } in the "# Set background color to Orange if just a warning if($percentFree -lt $percentWarning) { $color = $orangeColor #####Here##### put a } This script is marvelous. Thanks, Mike!
Hello all, I found this power shell script which works perfectly fine....here is the script...But how can i modify the script so this works on a clustered server....reason being....lets say i have a drive letter I: But it only shows up about 1GB totaly capicity and used it 0.35G but when i go inside I drive it has more folder saying as data logs and they are mounted on a different disk....which dose not show up in the report ??? if you know what i mean...how can i over come this ?? looks like the I drive is logical and once we go inside I drive ...the data, logs folder is mounted on a different disk...which might be physical....