icinga-powershell-framework/lib/core/installer/tools/Alias.psm1
2021-08-06 15:08:53 +02:00

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;
}