Changed to Get-CimInstance where it can be done
parent
ec348eca2c
commit
4f8afd7314
|
@ -20,7 +20,7 @@ $LogFile = "$WorkingDir\logs\updates.log"
|
||||||
|
|
||||||
if ($IsSystem) {
|
if ($IsSystem) {
|
||||||
#Check if any connected user when running as system
|
#Check if any connected user when running as system
|
||||||
$explorerprocesses = @(Get-WmiObject -Query "Select * FROM Win32_Process WHERE Name='explorer.exe'" -ErrorAction SilentlyContinue)
|
$explorerprocesses = @(Get-CimInstance -Query "SELECT * FROM Win32_Process WHERE Name='explorer.exe'" -ErrorAction SilentlyContinue)
|
||||||
#Check if ServiceUI exists
|
#Check if ServiceUI exists
|
||||||
$ServiceUI = Test-Path "$WorkingDir\ServiceUI.exe"
|
$ServiceUI = Test-Path "$WorkingDir\ServiceUI.exe"
|
||||||
If ($explorerprocesses.Count -gt 0 -and $ServiceUI) {
|
If ($explorerprocesses.Count -gt 0 -and $ServiceUI) {
|
||||||
|
@ -349,8 +349,7 @@ if (Test-Network) {
|
||||||
$UserContextTask = Get-ScheduledTask -TaskName 'Winget-AutoUpdate-UserContext' -ErrorAction SilentlyContinue
|
$UserContextTask = Get-ScheduledTask -TaskName 'Winget-AutoUpdate-UserContext' -ErrorAction SilentlyContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
#User check routine from: https://stackoverflow.com/questions/23219718/powershell-script-to-see-currently-logged-in-users-domain-and-machine-status
|
$explorerprocesses = @(Get-CimInstance -Query "SELECT * FROM Win32_Process WHERE Name='explorer.exe'" -ErrorAction SilentlyContinue)
|
||||||
$explorerprocesses = @(Get-WmiObject -Query "Select * FROM Win32_Process WHERE Name='explorer.exe'" -ErrorAction SilentlyContinue)
|
|
||||||
If ($explorerprocesses.Count -eq 0) {
|
If ($explorerprocesses.Count -eq 0) {
|
||||||
Write-ToLog "No explorer process found / Nobody interactively logged on..."
|
Write-ToLog "No explorer process found / Nobody interactively logged on..."
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ function Test-PendingReboot {
|
||||||
if (($WMI_Reg.EnumKey($HKLM, "SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\")).sNames -contains 'RebootPending') { $PendingReboot = $true }
|
if (($WMI_Reg.EnumKey($HKLM, "SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\")).sNames -contains 'RebootPending') { $PendingReboot = $true }
|
||||||
if (($WMI_Reg.EnumKey($HKLM, "SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\")).sNames -contains 'RebootRequired') { $PendingReboot = $true }
|
if (($WMI_Reg.EnumKey($HKLM, "SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\")).sNames -contains 'RebootRequired') { $PendingReboot = $true }
|
||||||
|
|
||||||
#Checking for SCCM namespace
|
#Checking for SCCM namespace (can't get it done with Get-CimInstance, using deprecated Get-WmiObject)
|
||||||
$SCCM_Namespace = Get-WmiObject -Namespace ROOT\CCM\ClientSDK -List -ComputerName $Computer -ErrorAction Ignore
|
$SCCM_Namespace = Get-WmiObject -Namespace ROOT\CCM\ClientSDK -List -ComputerName $Computer -ErrorAction Ignore
|
||||||
if ($SCCM_Namespace) {
|
if ($SCCM_Namespace) {
|
||||||
if (([WmiClass]"\\$Computer\ROOT\CCM\ClientSDK:CCM_ClientUtilities").DetermineIfRebootPending().RebootPending -eq $true) { $PendingReboot = $true }
|
if (([WmiClass]"\\$Computer\ROOT\CCM\ClientSDK:CCM_ClientUtilities").DetermineIfRebootPending().RebootPending -eq $true) { $PendingReboot = $true }
|
||||||
|
|
|
@ -11,6 +11,7 @@ Function Update-StoreApps {
|
||||||
Write-ToLog $force_string "yellow"
|
Write-ToLog $force_string "yellow"
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
# Can't get it done with Get-CimInstance, using deprecated Get-WmiObject
|
||||||
$namespaceName = "root\cimv2\mdm\dmmap"
|
$namespaceName = "root\cimv2\mdm\dmmap"
|
||||||
$className = "MDM_EnterpriseModernAppManagement_AppManagement01"
|
$className = "MDM_EnterpriseModernAppManagement_AppManagement01"
|
||||||
$wmiObj = Get-WmiObject -Namespace $namespaceName -Class $className
|
$wmiObj = Get-WmiObject -Namespace $namespaceName -Class $className
|
||||||
|
|
Loading…
Reference in New Issue