forked from j0eyv/ProactiveRemediations
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDetect_W32TimeService.ps1
More file actions
38 lines (38 loc) · 1.01 KB
/
Copy pathDetect_W32TimeService.ps1
File metadata and controls
38 lines (38 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
=============================================================================================================================
#
Script Name: DetectW32TimeService.ps1
Description: Purpose of this script is to detect if "Windows Time Service" is running
Notes: No variable substitution should be necessary
#
=============================================================================================================================
Define Variables
$curSvcStat,$svcCTRSvc,$errMsg = "","",""
Main script
$svcCTRSvc = w32tm /resync
Try{
$svcCTRSvc = w32tm /resync
$svcCTRSvc = Get-Service "W32Time"
$curSvcStat = $svcCTRSvc.Status
}
Catch{
$errMsg = $_.Exception.Message
Write-Error $errMsg
exit 1
}
If ($curSvcStat -eq "Running"){
Write-Output $curSvcStat
exit 0
}
Else{
If($curSvcStat -eq "Stopped"){
Write-Output $curSvcStat
exit 1
}
Else{
Write-Error "Error: " + $errMsg
exit 1
}
}
SIG # Begin signature block
#Signature Removed - But will be available in the Intune portal.
SIG # End signature block