Skip to content

Commit

Permalink
Silence null error in audit_windows.ps1.
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-unwin committed May 12, 2024
1 parent 78b2432 commit 8bb65c9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions other/audit_windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1800,7 +1800,7 @@ $result.server = @()
$result.server_item = @()
$item = @{}
$test = Get-Service -name "W3SVC" -ErrorAction Ignore
if ($test.Status.ToString() -eq "Running") {
if ($test.Status -ne $null -and $test.Status.ToString() -eq "Running") {
$itimer = [Diagnostics.Stopwatch]::StartNew()
# Get IIS details
Clear-Variable -name item
Expand Down Expand Up @@ -1852,7 +1852,7 @@ if ($test.Status.ToString() -eq "Running") {
}

$test = Get-Service -name "MSSQLSERVER" -ErrorAction Ignore
if ($test.Status.ToString() -eq "Running") {
if ($test.Status -ne $null -and $test.Status.ToString() -eq "Running") {
$itimer = [Diagnostics.Stopwatch]::StartNew()
# Get MSSQL details
Clear-Variable -name item
Expand Down

0 comments on commit 8bb65c9

Please sign in to comment.