Skip to content

Commit 95f0fe7

Browse files
committed
Clean out remaining Get-CimInstance calls throughout module.
Remaining calls are purely for niche SCCM functionality where there's no other option. However, all agnostic pathways are CIM-free.
1 parent ac79cb5 commit 95f0fe7

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/PSAppDeployToolkit/Public/ConvertTo-ADTNTAccountOrSID.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ function ConvertTo-ADTNTAccountOrSID
179179
{
180180
try
181181
{
182-
[System.Security.Principal.SecurityIdentifier]::new([System.DirectoryServices.DirectoryEntry]::new("$LdapUri$((Get-CimInstance -ClassName Win32_ComputerSystem).Domain.ToLowerInvariant())").ObjectSid[0], 0)
182+
[System.Security.Principal.SecurityIdentifier]::new([System.DirectoryServices.DirectoryEntry]::new("$LdapUri$([PSADT.DeviceManagement.DeviceUtilities]::GetDomainStatus().DomainOrWorkgroupName.ToLowerInvariant())").ObjectSid[0], 0)
183183
}
184184
catch
185185
{

src/PSAppDeployToolkit/Public/Get-ADTPendingReboot.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ function Get-ADTPendingReboot
9797
$IsFileRenameRebootPending = !!($PendingFileRenameOperations = Get-ItemProperty -LiteralPath 'Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager' | Select-Object -ExpandProperty PendingFileRenameOperations -ErrorAction Ignore)
9898

9999
# Determine SCCM 2012 Client reboot pending status.
100-
$IsSCCMClientRebootPending = if ((Get-CimInstance -Namespace root -ClassName __NAMESPACE -Verbose:$false).Name.Contains('ccm'))
100+
$IsSCCMClientRebootPending = if ((Get-CimInstance -Namespace root -ClassName __NAMESPACE -Verbose:$false -ErrorAction Ignore | Select-Object -ExpandProperty Name) -match 'ccm')
101101
{
102102
try
103103
{

src/PSAppDeployToolkit/Public/Test-ADTMutexAvailability.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ function Test-ADTMutexAvailability
134134
Write-ADTLogEntry -Message "Mutex [$MutexName] is available for an exclusive lock."
135135
}
136136
}
137-
elseif (($MutexName -eq 'Global\_MSIExecute') -and ($msiInProgressCmdLine = Get-CimInstance -ClassName Win32_Process -Filter "(Name = 'msiexec.exe') AND (CommandLine like '*.msi*')" | Select-Object -ExpandProperty CommandLine))
137+
elseif (($MutexName -eq 'Global\_MSIExecute') -and ($msiInProgress = Get-ADTRunningProcesses -ProcessObjects msiexec | Where-Object { $_.ArgumentList -match '\.msi' }))
138138
{
139-
Write-ADTLogEntry -Message "Mutex [$MutexName] is not available for an exclusive lock because the following MSI installation is in progress [$($msiInProgressCmdLine.Trim())]." -Severity 2
139+
Write-ADTLogEntry -Message "Mutex [$MutexName] is not available for an exclusive lock because the following MSI installation is in progress [$($msiInProgress.FilePath) $([System.String]::Join(' ', $msiInProgress.ArgumentList))]." -Severity 2
140140
}
141141
else
142142
{

0 commit comments

Comments
 (0)