Skip to content

Instantly share code, notes, and snippets.

@SteveL-MSFT
Created October 13, 2022 01:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save SteveL-MSFT/c9774da31c1f7c7bb717f75981f1eb9d to your computer and use it in GitHub Desktop.
Save SteveL-MSFT/c9774da31c1f7c7bb717f75981f1eb9d to your computer and use it in GitHub Desktop.
[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