"powershell script to get uptime of multiple servers" Code Answer's
You're definitely familiar with the best coding language C++ that developers use to develop their projects and they get all their queries like "powershell script to get uptime of multiple servers" answered properly. Developers are finding an appropriate answer about powershell script to get uptime of multiple servers related to the C++ coding language. By visiting this online portal developers get answers concerning C++ codes question like powershell script to get uptime of multiple servers. Enter your desired code related query in the search bar and get every piece of information about C++ code related question on powershell script to get uptime of multiple servers.
powershell script to get uptime of multiple servers
Function Get-Uptime {
<#
.Synopsis
This will check how long the computer has been running and when was it last rebooted.
For updated help and examples refer to -Online version.
.NOTES
Name: Get-Uptime
Author: theSysadminChannel
Version: 1.0
DateCreated: 2018-Jun-16
.LINK
https://thesysadminchannel.com/get-uptime-last-reboot-status-multiple-computers-powershell/ -
.PARAMETER ComputerName
By default it will check the local computer.
.EXAMPLE
Get-Uptime -ComputerName PAC-DC01, PAC-WIN1001
Description:
Check the computers PAC-DC01 and PAC-WIN1001 and see how long the systems have been running for.
#>
[CmdletBinding()]
Param (
[Parameter(
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]
[string[]]
$ComputerName = $env:COMPUTERNAME
)
BEGIN {}
PROCESS {
Foreach ($Computer in $ComputerName) {
$Computer = $Computer.ToUpper()
Try {
$OS = Get-WmiObject Win32_OperatingSystem -ComputerName $Computer -ErrorAction Stop
$Uptime = (Get-Date) - $OS.ConvertToDateTime($OS.LastBootUpTime)
[PSCustomObject]@{
ComputerName = $Computer
LastBoot = $OS.ConvertToDateTime($OS.LastBootUpTime)
Uptime = ([String]$Uptime.Days + " Days " + $Uptime.Hours + " Hours " + $Uptime.Minutes + " Minutes")
}
} catch {
[PSCustomObject]@{
ComputerName = $Computer
LastBoot = "Unable to Connect"
Uptime = $_.Exception.Message.Split('.')[0]
}
} finally {
$null = $OS
$null = $Uptime
}
}
}
END {}
}
Source: thesysadminchannel.com
All those coders who are working on the C++ based application and are stuck on powershell script to get uptime of multiple servers can get a collection of related answers to their query. Programmers need to enter their query on powershell script to get uptime of multiple servers related to C++ code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about powershell script to get uptime of multiple servers for the programmers working on C++ code while coding their module. Coders are also allowed to rectify already present answers of powershell script to get uptime of multiple servers while working on the C++ language code. Developers can add up suggestions if they deem fit any other answer relating to "powershell script to get uptime of multiple servers". Visit this developer's friendly online web community, CodeProZone, and get your queries like powershell script to get uptime of multiple servers resolved professionally and stay updated to the latest C++ updates.