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
|
$CertificateExpirationThreshold = Get-Date
|
||||||
|
|
||||||
|
#Include both LocalMachine and CurrentUser CA stores
|
||||||
$CertificateStorePathList = New-Object -TypeName 'System.Collections.Generic.List[System.String]'
|
$CertificateStorePathList = New-Object -TypeName 'System.Collections.Generic.List[System.String]'
|
||||||
$CertificateStorePathList.Add('Cert:\LocalMachine\Root')
|
$CertificateStorePathList.Add('Cert:\LocalMachine\Root')
|
||||||
$CertificateStorePathList.Add('Cert:\LocalMachine\CA')
|
$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
|
#region Apply CA Inclusion Filter
|
||||||
Switch (([System.String]::IsNullOrEmpty($CAInclusionExpression) -eq $False) -and ([System.String]::IsNullOrWhiteSpace($CAInclusionExpression) -eq $False))
|
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)
|
$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))"))
|
$WriteLogMessage.Invoke(0, @("Process Exit Time: $($Process.ExitTime.ToString($DateTimeLogFormat))"))
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -308,11 +308,11 @@ Try
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Load WMI Classes
|
#region Load WMI Classes
|
||||||
$Baseboard = Get-CIMInstance -Namespace "root\CIMv2" -ClassName "Win32_Baseboard" -Property *
|
$Baseboard = Get-CIMInstance -Namespace "root\CIMv2" -ClassName "Win32_Baseboard" -Property * -Verbose:$False
|
||||||
$Bios = Get-CIMInstance -Namespace "root\CIMv2" -ClassName "Win32_Bios" -Property *
|
$Bios = Get-CIMInstance -Namespace "root\CIMv2" -ClassName "Win32_Bios" -Property * -Verbose:$False
|
||||||
$ComputerSystem = Get-CIMInstance -Namespace "root\CIMv2" -ClassName "Win32_ComputerSystem" -Property *
|
$ComputerSystem = Get-CIMInstance -Namespace "root\CIMv2" -ClassName "Win32_ComputerSystem" -Property * -Verbose:$False
|
||||||
$MSSystemInformation = Get-CIMInstance -Namespace "root\WMI" -ClassName "MS_SystemInformation" -Property *
|
$MSSystemInformation = Get-CIMInstance -Namespace "root\WMI" -ClassName "MS_SystemInformation" -Property * -Verbose:$False
|
||||||
$OperatingSystem = Get-CIMInstance -Namespace "root\CIMv2" -ClassName "Win32_OperatingSystem" -Property *
|
$OperatingSystem = Get-CIMInstance -Namespace "root\CIMv2" -ClassName "Win32_OperatingSystem" -Property * -Verbose:$False
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Define Variables
|
#region Define Variables
|
||||||
|
|||||||
Reference in New Issue
Block a user