Created
October 13, 2022 01:40
-
-
Save SteveL-MSFT/c9774da31c1f7c7bb717f75981f1eb9d 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
[cmdletbinding()] | |
param( | |
[Parameter(Mandatory=$true,Position=0)] | |
[string]$command, | |
[Parameter(Position=1)] | |
[string]$class | |
) | |
if ($command -eq 'path') { | |
if ($null -eq $class) { | |
throw 'Class is required for PATH command' | |
} | |
Get-CimInstance $class -Namespace root/cimv2 | |
} | |
else { | |
$alias = Get-CimInstance msft_clialias -namespace root/cli -Filter "FriendlyName = '$command'" | |
if ($null -eq $alias) { | |
throw "Alias '$command' not found" | |
} | |
Get-CimInstance -Query $alias.target -Namespace root/cimv2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment