Some important command to get server uptime and Service status matching the text.
To get server Uptime
================
Invoke-Command -ScriptBlock {
$dt = Get-Date
$tz = [System.TimeZone]::CurrentTimeZone
Write-Host "`r`nHostname:" $(hostname)
Write-Host "Timezone:" $tz.StandardName " / " $tz.DaylightName
Write-Host "Date: " $dt
}
============================
Expected output
===================================================
Get Service status matching the text
===============================
Get-Service | Where-Object {$_.Name -Match "windows" -or $_.DisplayName -Match "window" }
Expected Output
Start a service
Start-Service -Name "ServiceName"
Stop a service
Stop-Service -Name "ServiceName"
PS C:\Windows\system32> get-service -name wuauserv
Status Name DisplayName
------ ---- -----------
Stopped wuauserv Windows Update
PS C:\Windows\system32> start-service wuauserv
PS C:\Windows\system32> get-service -name wuauserv
Status Name DisplayName
------ ---- -----------
Running wuauserv Windows Update
PS C:\Windows\system32> stop-service wuauserv
PS C:\Windows\system32> get-service -name wuauserv
Status Name DisplayName
------ ---- -----------
Stopped wuauserv Windows Update
No comments:
Post a Comment