Public/Com/ComObj.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<#
.SYNOPSIS
Returns all ComObjects
 
.DESCRIPTION
Returns all ComObjects
 
.LINK
https://osd.osdeploy.com/module/functions/comobj
https://www.powershellmagazine.com/2013/06/27/pstip-get-a-list-of-all-com-objects-available/
 
.NOTES
21.2.3 Initial Release
I'm not quite sure this works as it is not listing the Microsoft Update stuff
#>

function Get-ComObjects {
    [CmdletBinding()]
    Param(
        [Parameter(Mandatory=$true,
        ParameterSetName='FilterByName')]
        [string]$Filter,
 
        [Parameter(Mandatory=$true,
        ParameterSetName='ListAllComObjects')]
        [switch]$ListAll
    )
 
    $ListofObjects = Get-ChildItem HKLM:\Software\Classes -ErrorAction SilentlyContinue | Where-Object {
        $_.PSChildName -match '^\w+\.\w+$' -and (Test-Path -Path "$($_.PSPath)\CLSID")
    } | Select-Object -ExpandProperty PSChildName
 
    if ($Filter) {
        $ListofObjects | Where-Object {$_ -like $Filter}
    } else {
        $ListofObjects
    }
}
<#
.SYNOPSIS
Returns (New-Object -ComObject Microsoft.Update.AutoUpdate).Settings
 
.DESCRIPTION
Returns (New-Object -ComObject Microsoft.Update.AutoUpdate).Settings
 
.LINK
https://osd.osdeploy.com/module/functions/update
https://twitter.com/byteben/status/1356893619811155968
 
.NOTES
Credit Ben Whitmore | byteben.com | @byteben
#>

function Get-ComObjMicrosoftUpdateAutoUpdate{
    [CmdletBinding()]
    param ()

    Return (New-Object -ComObject Microsoft.Update.AutoUpdate).Settings
}
<#
.SYNOPSIS
Returns New-Object -ComObject Microsoft.Update.Installer
 
.DESCRIPTION
Returns New-Object -ComObject Microsoft.Update.Installer
 
.LINK
https://osd.osdeploy.com/module/functions/update
https://twitter.com/byteben/status/1356893619811155968
 
.NOTES
Credit Ben Whitmore | byteben.com | @byteben
#>

function Get-ComObjMicrosoftUpdateInstaller {
    [CmdletBinding()]
    param ()

    Return New-Object -ComObject Microsoft.Update.Installer
}
<#
.SYNOPSIS
Returns (New-Object -ComObject Microsoft.Update.ServiceManager).Services
 
.DESCRIPTION
Returns (New-Object -ComObject Microsoft.Update.ServiceManager).Services
 
.LINK
https://osd.osdeploy.com/module/functions/update
https://twitter.com/byteben/status/1356893619811155968
 
.NOTES
Credit Ben Whitmore | byteben.com | @byteben
#>

function Get-ComObjMicrosoftUpdateServiceManager {
    [CmdletBinding()]
    param ()

    Return (New-Object -ComObject Microsoft.Update.ServiceManager).Services
}