From f466495638a94e4ecaa9937efba1eb24f801bde0 Mon Sep 17 00:00:00 2001 From: Charley Wu Date: Wed, 1 Feb 2023 14:12:45 +0800 Subject: [PATCH] Improved legacy OS compatibility --- README.md | 2 +- README.zh-TW.md | 2 +- SecureAuditor.psd1 | 2 +- rules/DiskSpace.psm1 | 5 +++++ rules/LocalUser/DefaultAccount.psm1 | 2 +- rules/LocalUser/IdleAccount.psm1 | 2 +- rules/LocalUser/PasswordExpires.psm1 | 2 +- rules/WinEvent/EventLogs.psm1 | 2 +- rules/WinEvent/Login.psm1 | 2 +- rules/WinEvent/Shutdown.psm1 | 2 +- rules/WinEvent/SoftwareInstallation.psm1 | 2 +- rules/WinEvent/UserAccountManagement.psm1 | 2 +- 12 files changed, 16 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 8c48f78..7c2fd4e 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ git pull Sample output ````markdown -# Windows Secure Auditor: 0.13.4 +# Windows Secure Auditor: 0.13.5 ## System Information diff --git a/README.zh-TW.md b/README.zh-TW.md index 43ccb39..e7adff0 100644 --- a/README.zh-TW.md +++ b/README.zh-TW.md @@ -50,7 +50,7 @@ git pull 範例輸出 ````markdown -# Windows Secure Auditor: 0.13.4 +# Windows Secure Auditor: 0.13.5 ## 系統資訊 diff --git a/SecureAuditor.psd1 b/SecureAuditor.psd1 index a3738d4..d49ea61 100644 --- a/SecureAuditor.psd1 +++ b/SecureAuditor.psd1 @@ -6,7 +6,7 @@ # RootModule = '' # Version number of this module. - ModuleVersion = '0.13.4' + ModuleVersion = '0.13.5' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/rules/DiskSpace.psm1 b/rules/DiskSpace.psm1 index aac706f..556bd3b 100644 --- a/rules/DiskSpace.psm1 +++ b/rules/DiskSpace.psm1 @@ -13,6 +13,11 @@ if ($PSUICulture -ne 'en-US') { } function Test($config) { + if (-not (Get-Command 'Get-PSDrive' -ErrorAction SilentlyContinue)) { + $ruleName = [System.IO.Path]::GetFileNameWithoutExtension($PSCommandPath) + Write-UnsupportedPlatform($ruleName) + return + } # https://learn.microsoft.com/powershell/module/microsoft.powershell.management/get-psdrive $drives = Get-PSDrive -PSProvider FileSystem | Where-Object { $null -ne $_.Used -and $_.Used -gt 0 } $exclude = $config.DiskSpace.Exclude diff --git a/rules/LocalUser/DefaultAccount.psm1 b/rules/LocalUser/DefaultAccount.psm1 index b1de587..8a78048 100644 --- a/rules/LocalUser/DefaultAccount.psm1 +++ b/rules/LocalUser/DefaultAccount.psm1 @@ -12,7 +12,7 @@ if ($PSUICulture -ne 'en-US') { } function Test($config) { - if ($PSVersionTable.PSEdition -eq 'Core' -and $PSVersionTable.Platform -ne 'Win32NT') { + if (-not (Get-Command 'Get-LocalUser' -ErrorAction SilentlyContinue)) { $ruleName = [System.IO.Path]::GetFileNameWithoutExtension($PSCommandPath) Write-UnsupportedPlatform($ruleName) return diff --git a/rules/LocalUser/IdleAccount.psm1 b/rules/LocalUser/IdleAccount.psm1 index 286a552..8839467 100644 --- a/rules/LocalUser/IdleAccount.psm1 +++ b/rules/LocalUser/IdleAccount.psm1 @@ -11,7 +11,7 @@ if ($PSUICulture -ne 'en-US') { } function Test($config) { - if ($PSVersionTable.PSEdition -eq 'Core' -and $PSVersionTable.Platform -ne 'Win32NT') { + if (-not (Get-Command 'Get-LocalUser' -ErrorAction SilentlyContinue)) { $ruleName = [System.IO.Path]::GetFileNameWithoutExtension($PSCommandPath) Write-UnsupportedPlatform($ruleName) return diff --git a/rules/LocalUser/PasswordExpires.psm1 b/rules/LocalUser/PasswordExpires.psm1 index d6c9f39..58e4ba3 100644 --- a/rules/LocalUser/PasswordExpires.psm1 +++ b/rules/LocalUser/PasswordExpires.psm1 @@ -11,7 +11,7 @@ if ($PSUICulture -ne 'en-US') { } function Test($config) { - if ($PSVersionTable.PSEdition -eq 'Core' -and $PSVersionTable.Platform -ne 'Win32NT') { + if (-not (Get-Command 'Get-LocalUser' -ErrorAction SilentlyContinue)) { $ruleName = [System.IO.Path]::GetFileNameWithoutExtension($PSCommandPath) Write-UnsupportedPlatform($ruleName) return diff --git a/rules/WinEvent/EventLogs.psm1 b/rules/WinEvent/EventLogs.psm1 index 8873e0a..1a43714 100644 --- a/rules/WinEvent/EventLogs.psm1 +++ b/rules/WinEvent/EventLogs.psm1 @@ -17,7 +17,7 @@ if ($PSUICulture -ne 'en-US') { function Test($config) { $ruleName = [System.IO.Path]::GetFileNameWithoutExtension($PSCommandPath) - if ($PSVersionTable.PSEdition -eq 'Core' -and $PSVersionTable.Platform -ne 'Win32NT') { + if (-not (Get-Command 'Get-WinEvent' -ErrorAction SilentlyContinue)) { Write-UnsupportedPlatform($ruleName) return } diff --git a/rules/WinEvent/Login.psm1 b/rules/WinEvent/Login.psm1 index 9192f9a..a1b7535 100644 --- a/rules/WinEvent/Login.psm1 +++ b/rules/WinEvent/Login.psm1 @@ -14,7 +14,7 @@ if ($PSUICulture -ne 'en-US') { function Test($config) { $ruleName = [System.IO.Path]::GetFileNameWithoutExtension($PSCommandPath) - if ($PSVersionTable.PSEdition -eq 'Core' -and $PSVersionTable.Platform -ne 'Win32NT') { + if (-not (Get-Command 'Get-WinEvent' -ErrorAction SilentlyContinue)) { Write-UnsupportedPlatform($ruleName) return } diff --git a/rules/WinEvent/Shutdown.psm1 b/rules/WinEvent/Shutdown.psm1 index fe1ff8f..f960db0 100644 --- a/rules/WinEvent/Shutdown.psm1 +++ b/rules/WinEvent/Shutdown.psm1 @@ -11,7 +11,7 @@ if ($PSUICulture -ne 'en-US') { function Test($config) { $ruleName = [System.IO.Path]::GetFileNameWithoutExtension($PSCommandPath) - if ($PSVersionTable.PSEdition -eq 'Core' -and $PSVersionTable.Platform -ne 'Win32NT') { + if (-not (Get-Command 'Get-WinEvent' -ErrorAction SilentlyContinue)) { Write-UnsupportedPlatform($ruleName) return } diff --git a/rules/WinEvent/SoftwareInstallation.psm1 b/rules/WinEvent/SoftwareInstallation.psm1 index 051d662..ed3e517 100644 --- a/rules/WinEvent/SoftwareInstallation.psm1 +++ b/rules/WinEvent/SoftwareInstallation.psm1 @@ -11,7 +11,7 @@ if ($PSUICulture -ne 'en-US') { function Test($config) { $ruleName = [System.IO.Path]::GetFileNameWithoutExtension($PSCommandPath) - if ($PSVersionTable.PSEdition -eq 'Core' -and $PSVersionTable.Platform -ne 'Win32NT') { + if (-not (Get-Command 'Get-WinEvent' -ErrorAction SilentlyContinue)) { Write-UnsupportedPlatform($ruleName) return } diff --git a/rules/WinEvent/UserAccountManagement.psm1 b/rules/WinEvent/UserAccountManagement.psm1 index a569178..02d2517 100644 --- a/rules/WinEvent/UserAccountManagement.psm1 +++ b/rules/WinEvent/UserAccountManagement.psm1 @@ -13,7 +13,7 @@ if ($PSUICulture -ne 'en-US') { function Test($config) { $ruleName = [System.IO.Path]::GetFileNameWithoutExtension($PSCommandPath) - if ($PSVersionTable.PSEdition -eq 'Core' -and $PSVersionTable.Platform -ne 'Win32NT') { + if (-not (Get-Command 'Get-WinEvent' -ErrorAction SilentlyContinue)) { Write-UnsupportedPlatform($ruleName) return }