mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 07:10:15 -05:00
30 lines
684 B
PowerShell
30 lines
684 B
PowerShell
function Get-IcingaForWindowsManagementConsoleAlias()
|
|
{
|
|
param (
|
|
[string]$Command
|
|
);
|
|
|
|
if ([string]::IsNullOrEmpty($Command)) {
|
|
return '';
|
|
}
|
|
|
|
$ParentEntry = $null;
|
|
|
|
if ($Command.Contains(':')) {
|
|
$KeyValue = $Command.Split(':');
|
|
$Command = $KeyValue[0];
|
|
$ParentEntry = $KeyValue[1];
|
|
}
|
|
|
|
$CommandAlias = Get-Alias -Definition $Command -ErrorAction SilentlyContinue;
|
|
|
|
if ($null -ne $CommandAlias) {
|
|
$Command = $CommandAlias.Name;
|
|
}
|
|
|
|
if ([string]::IsNullOrEmpty($ParentEntry) -eq $FALSE) {
|
|
$Command = [string]::Format('{0}:{1}', $Command, $ParentEntry);
|
|
}
|
|
|
|
return $Command;
|
|
}
|