David Sechler
asked on
IF statement to PowerShell Script
I have a Powershell script that gets uptime from servers that I pieced together from bits and pieces from written code on the net. What I have works great, however I've been asked to modify it for some output based on how long the servers have been up.
Here is what I've been asked to add to the script:
An "if" statement to check if the $UptimeSeconds variable is less than 600 to Write-output the value "rebooted" and and if $UptimeSeconds is greater than 2592000 (30 days) to Write-output "rebootneeded"
I appreciate any help I can get. I'm just leaning Powershell and am digging in where I can.
David
Uptime.txt
Here is what I've been asked to add to the script:
An "if" statement to check if the $UptimeSeconds variable is less than 600 to Write-output the value "rebooted" and and if $UptimeSeconds is greater than 2592000 (30 days) to Write-output "rebootneeded"
I appreciate any help I can get. I'm just leaning Powershell and am digging in where I can.
David
Uptime.txt
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
It's because none of the servers have uptime below 600 seconds and above 30 days..
If you want to test change the threshold to one day.. Change line 13 to..
If you want to test change the threshold to one day.. Change line 13 to..
If ($uptime.TotalDays -gt 1){
ASKER
I just bounced one of my workstations in the list and your right! Good to go! Thanks so much for the help Subsun!
ASKER
Thanks again for the help. This was my first question here and I'm quite pleased!
ASKER