Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to CIM cmdlets #8

Open
exchange12rocks opened this issue Dec 21, 2019 · 10 comments · May be fixed by #13
Open

Switch to CIM cmdlets #8

exchange12rocks opened this issue Dec 21, 2019 · 10 comments · May be fixed by #13
Assignees

Comments

@exchange12rocks
Copy link

Hi Brian! As far as I know, WMI cmdlets are considered deprecated. Do you think it's worth to switch to CIM cmdlets? Or implement both and let users to choose which one to use via a switch parameter?

@bcwilhite
Copy link
Owner

Actually this was on my to-do list at one point. I think it's a good idea to switch over given that v3 should be the least version widely used. I suppose a switch parameter could be used in order to leverage WMI, although I'd just prefer to go one way or the other and not have to support both.

@bcwilhite bcwilhite self-assigned this Jan 29, 2020
@alayac
Copy link

alayac commented Mar 12, 2020

This is a great module and we use it extensively in our organization (along with it's predecessor from Technet Gallery).
I just tried this module in PowerShell 7 and it doesn't like the WMI cmdlets. Migrating to the CIM cmdlets should make this work in the latest version of PowerShell natively. No need to use a switch operator to support both. The CIM cmdlets are comparable and better optimized anyway.
Thanks!

@dennisl68-castra
Copy link

Since PoSH 7.1 is 99% compatbile with PoSH 5.1, it's a shame that the WMI-dependency still exists in this module...
Why not just drop the WMI-support and move to a v2 release?

@realslacker
Copy link

@bcwilhite if you merge this and someone needs WMI support they can just install the last release before switching to CIM. The current version has been working for people for years, so they should be able to just keep using it. Maybe just putting some explicit install instructions so people understand that to use WMI they use 0.9.0.6, anything after that uses CIM.

@DennisL68
Copy link

DennisL68 commented Aug 3, 2023

It seems that CIM itself is supported in PowerShell since v3...

I.e. natively in Windows 8 and later.

So who is actually bound to using WMI if not using an unsupported Windows version?

https://devblogs.microsoft.com/scripting/what-is-cim-and-why-should-i-use-it-in-powershell/

https://devblogs.microsoft.com/powershell/introduction-to-cim-cmdlets/

@realslacker
Copy link

@DennisL68 CIM uses WinRM (WSMAN) where WMI uses native WMI calls. I've come across a few scenarios where WMI is enabled, but WinRM is not, and vice-versa.

@DennisL68
Copy link

DennisL68 commented Aug 3, 2023

@DennisL68 CIM uses WinRM (WSMAN) where WMI uses native WMI calls. I've come across a few scenarios where WMI is enabled, but WinRM is not, and vice-versa.

Yes, WMI uses RPC where as CIM uses a more controlled protocol as a carrier :)

@SamErde
Copy link

SamErde commented Oct 6, 2023

It shouldn't be hard to include an option to use WMI as a fallback method.

@ShaneJ7769
Copy link

Why not just do a regkey check?

Check for pending reboot that might be required after a domain join

if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired") {
Write-Output "Pending reboot detected. Domain join might not be complete."
}

Check for pending computer rename

if (Test-Path -Path "HKLM:\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName") {
$newName = (Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName").ComputerName
$currentName = $env:COMPUTERNAME
if ($newName -ne $currentName) {
Write-Output "Pending computer rename detected. Domain join might not be complete."
}
}

@ShaneJ7769
Copy link

Those looking for a work around:

$RebootFlags = Test-PendingReboot -Detailed -WarningAction SilentlyContinue -ErrorAction SilentlyContinue
$JoinFlag = (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired")
$PendingRename = ((Test-Path -Path "HKLM:\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName") -and ((Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName").ComputerName -ne $env:COMPUTERNAME))

if ($RebootFlags.IsRebootPending -eq $true) {
if (($RebootFlags.ComponentBasedServicing -eq $True) -or #($RebootFlags.PendingComputerRenameDomainJoin -eq $True) -or
($RebootFlags.PendingFileRenameOperations -eq $True) -or ($RebootFlags.SystemCenterConfigManager -eq $True) -or
($RebootFlags.WindowsUpdateAutoUpdate -eq $True) -or ($JoinFlag -eq $true) -or
($PendingRename -eq $True)) {
Write-Host "There is a pending reboot needed." -ForegroundColor Red
}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants