-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathwindows-policy-checks.ps1
More file actions
66 lines (47 loc) · 2.06 KB
/
Copy pathwindows-policy-checks.ps1
File metadata and controls
66 lines (47 loc) · 2.06 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#! /c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit
}
function WriteMessage($message, $color = "Yellow", $pad = $true) {
if ($pad) {
Write-Host ""
}
Write-Host $message -ForegroundColor $color
}
# windows updates
WriteMessage "checking for available windows updates..." "White"
$updateSession = New-Object -ComObject Microsoft.Update.Session -ErrorAction silentlycontinue
$searcher = $updateSession.CreateUpdateSearcher()
$nonInstalledUpdates = $searcher.Search("IsInstalled=0")
WriteMessage " > there are $($nonInstalledUpdates.Updates.Count) windows updates available."
if ($nonInstalledUpdates.Updates.Count -gt 0) {
Write-Host ""
$nonInstalledUpdates.Updates | Format-Table -Property @{Expression=" "}, Title -AutoSize -HideTableHeaders
}
# bitlocker
WriteMessage "checking bitlocker status..." "White" $false
$bitlockerStatus = manage-bde -status
$encryptedDrives = ([regex]::Matches($bitlockerStatus, "Fully Encrypted" )).Count
$discs = (Get-Disk | measure)
WriteMessage " > $encryptedDrives / $($discs.Count) drives are encrypted."
# windows defender
WriteMessage "ensuring windows defender is active..." "White"
$computerStatus = Get-MpComputerStatus
$servicesToCheck = (
$computerStatus.AMServiceEnabled,
$computerStatus.AntispywareEnabled,
$computerStatus.AntivirusEnabled,
$computerStatus.BehaviorMonitorEnabled,
$computerStatus.IoavProtectionEnabled,
$computerStatus.NISEnabled,
$computerStatus.OnAccessProtectionEnabled,
$computerStatus.RealTimeProtectionEnabled
)
$totalServiceCount = $servicesToCheck.Count
$totalServiceEnabledCount = 0
foreach ($serviceEnabled in $servicesToCheck) {
if ($serviceEnabled) {
$totalServiceEnabledCount++
}
}
WriteMessage " > $totalServiceEnabledCount / $totalServiceCount windows defender services are enabled. `n"