Created
August 10, 2017 04:46
-
-
Save botmtl/3a25cc75538d8b2498ee6bf983d87b5b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-ComObject { | |
<# | |
.Synopsis | |
Returns a list of ComObjects | |
.DESCRIPTION | |
This function has two parameter sets, it can either return all ComObject or a sub-section by the filter parameter. This information is gathered from the HKLM:\Software\Classes container. | |
.NOTES | |
Name: Get-ComObject | |
Author: Jaap Brasser | |
Version: 1.0 | |
DateUpdated: 2013-06-24 | |
.LINK | |
http://www.jaapbrasser.com | |
.PARAMETER Filter | |
The string that will be used as a filter. Wildcard characters are allowed. | |
.PARAMETER ListAll | |
Switch parameter, if this parameter is used no filter is required and all ComObjects are returned | |
.EXAMPLE | |
Get-ComObject -Filter *Application | |
Description: | |
Returns all objects that match the filter | |
.EXAMPLE | |
Get-ComObject -Filter ????.Application | |
Description: | |
Returns all objects that match the filter | |
.EXAMPLE | |
Get-ComObject -ListAll | |
Description: | |
Returns all ComObjects | |
#> | |
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 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment