Probably a dumb question but, I'm just curious.
Is there a difference between Get-CIMInstance
and Get-WMIObject
when Invoking an Uninstall for an application under the Win32_Product
class? Only reason I ask is because:
- Using
Get-CIMInstance
to uninstall an application, will reboot my computer with certain programs. - Using
Get-WMIObject
to uninstall an application just runs without rebooting.
Also, piping a Get-Member
to any Get-CIMInstance
product, doesn't give me a method to uninstall but, it does using Get-WMIObject
. Is this just how the developers wrote it? Although, Invoke-CIMMethod -Name Uninstall
still works.
Get-CIMInstance / Uninstall
Heres what I was doing to uninstall multiple apps using Get-CIMInstance
/Invoke-CIMMethod -Name Uninstall
:
Get-CimInstance -ClassName win32_product | Where-Object Name -Match "Visual" |
ForEach-Object -Process {
Invoke-CimMethod -InputObject $_ -Name Uninstall
}
#Methods Returned
<#
Get-CimInstance -ClassName win32_product | Where-Object Name -Match "Visual" | Get-Member -MemberType Method
TypeName: Microsoft.Management.Infrastructure.CimInstance#root/cimv2/Win32_Product
Name MemberType Definition
---- ---------- ----------
Clone Method System.Object ICloneable.Clone()
Dispose Method void Dispose(), void IDisposable.Dispose()
Equals Method bool Equals(System.Object obj)
GetCimSessionComputerName Method string GetCimSessionComputerName()
GetCimSessionInstanceId Method guid GetCimSessionInstanceId()
GetHashCode Method int GetHashCode()
GetObjectData Method void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Ser...
GetType Method type GetType()
ToString Method string ToString()
#>
Get-WMIObject / Uninstall
Get-WMIObject -ClassName win32_product | Where-Object Name -Match "Visual" |
ForEach-Object -Process {
Invoke-WMIMethod -InputObject $_ -Name Uninstall
}
#Methods Returned
<#
Get-WMIObject -Class win32_product | Where-Object Name -Match "Visual" | Get-Member -MemberType Method
TypeName: System.Management.ManagementObject#root\cimv2\Win32_Product
Name MemberType Definition
---- ---------- ----------
Configure Method System.Management.ManagementBaseObject Configure(System.UInt16 InstallState, System.UInt16 InstallLevel, S...
Reinstall Method System.Management.ManagementBaseObject Reinstall(System.UInt16 ReinstallMode)
Uninstall Method System.Management.ManagementBaseObject Uninstall()
Upgrade Method System.Management.ManagementBaseObject Upgrade(System.String PackageLocation, System.String Options)
#>
Pardon the long post, just a curious mind.
Please delete/close if not allowed.