mirror of
https://github.com/Grace-Solutions/Invoke-OpenSSHConfiguration.git
synced 2026-07-26 11:38:14 +00:00
Suppress CIM verbose, add CurrentUser CA stores, dedupe certificates
- Suppress Get-CIMInstance verbose output in Toolkit.ps1 with -Verbose:$False - Add CurrentUser Root and CA stores alongside LocalMachine stores - Dedupe certificates by Thumbprint (Sort-Object -Unique) - Suppress verbose from Process Select-Object (triggers WMI queries) - Use explicit property list instead of wildcard for process object
This commit is contained in:
@@ -477,11 +477,14 @@ Switch (Test-ProcessElevationStatus)
|
||||
|
||||
$CertificateExpirationThreshold = Get-Date
|
||||
|
||||
#Include both LocalMachine and CurrentUser CA stores
|
||||
$CertificateStorePathList = New-Object -TypeName 'System.Collections.Generic.List[System.String]'
|
||||
$CertificateStorePathList.Add('Cert:\LocalMachine\Root')
|
||||
$CertificateStorePathList.Add('Cert:\LocalMachine\CA')
|
||||
$CertificateStorePathList.Add('Cert:\CurrentUser\Root')
|
||||
$CertificateStorePathList.Add('Cert:\CurrentUser\CA')
|
||||
|
||||
$CACertificates = Get-ChildItem -Path $CertificateStorePathList | Where-Object {($_.NotAfter -gt $CertificateExpirationThreshold) -and ($_.Extensions | Where-Object {($_.Oid.FriendlyName -iin @('Basic Constraints')) -and ($_.CertificateAuthority -eq $True)})}
|
||||
$CACertificates = Get-ChildItem -Path $CertificateStorePathList -ErrorAction SilentlyContinue | Where-Object {($_.NotAfter -gt $CertificateExpirationThreshold) -and ($_.Extensions | Where-Object {($_.Oid.FriendlyName -iin @('Basic Constraints')) -and ($_.CertificateAuthority -eq $True)})} | Sort-Object -Property @('Thumbprint') -Unique
|
||||
|
||||
#region Apply CA Inclusion Filter
|
||||
Switch (([System.String]::IsNullOrEmpty($CAInclusionExpression) -eq $False) -and ([System.String]::IsNullOrWhiteSpace($CAInclusionExpression) -eq $False))
|
||||
|
||||
@@ -611,7 +611,8 @@ Function Start-ProcessWithOutput
|
||||
|
||||
$ProcessExecutionTimespan = New-TimeSpan -Start ($Process.StartTime) -End ($Process.ExitTime)
|
||||
|
||||
$OutputObjectProperties.ProcessObject = $Process | Select-Object -Property @('*') -ExcludeProperty @('ExitCode', 'StandardInput', 'StandardOutput', 'StandardError', 'SafeHandle', 'Threads', 'StartInfo')
|
||||
#Suppress verbose output from Select-Object on Process object (can trigger WMI queries)
|
||||
$OutputObjectProperties.ProcessObject = $Process | Select-Object -Property @('Id', 'ProcessName', 'Path', 'StartTime', 'ExitTime', 'HasExited', 'PriorityClass') -Verbose:$False -ErrorAction SilentlyContinue
|
||||
|
||||
$WriteLogMessage.Invoke(0, @("Process Exit Time: $($Process.ExitTime.ToString($DateTimeLogFormat))"))
|
||||
|
||||
|
||||
+5
-5
@@ -308,11 +308,11 @@ Try
|
||||
#endregion
|
||||
|
||||
#region Load WMI Classes
|
||||
$Baseboard = Get-CIMInstance -Namespace "root\CIMv2" -ClassName "Win32_Baseboard" -Property *
|
||||
$Bios = Get-CIMInstance -Namespace "root\CIMv2" -ClassName "Win32_Bios" -Property *
|
||||
$ComputerSystem = Get-CIMInstance -Namespace "root\CIMv2" -ClassName "Win32_ComputerSystem" -Property *
|
||||
$MSSystemInformation = Get-CIMInstance -Namespace "root\WMI" -ClassName "MS_SystemInformation" -Property *
|
||||
$OperatingSystem = Get-CIMInstance -Namespace "root\CIMv2" -ClassName "Win32_OperatingSystem" -Property *
|
||||
$Baseboard = Get-CIMInstance -Namespace "root\CIMv2" -ClassName "Win32_Baseboard" -Property * -Verbose:$False
|
||||
$Bios = Get-CIMInstance -Namespace "root\CIMv2" -ClassName "Win32_Bios" -Property * -Verbose:$False
|
||||
$ComputerSystem = Get-CIMInstance -Namespace "root\CIMv2" -ClassName "Win32_ComputerSystem" -Property * -Verbose:$False
|
||||
$MSSystemInformation = Get-CIMInstance -Namespace "root\WMI" -ClassName "MS_SystemInformation" -Property * -Verbose:$False
|
||||
$OperatingSystem = Get-CIMInstance -Namespace "root\CIMv2" -ClassName "Win32_OperatingSystem" -Property * -Verbose:$False
|
||||
#endregion
|
||||
|
||||
#region Define Variables
|
||||
|
||||
Reference in New Issue
Block a user