mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 07:10:15 -05:00
Adds feature to open an Icinga Shell as other user
This commit is contained in:
parent
82fb8945c4
commit
5e0ca2e8ad
3 changed files with 23 additions and 2 deletions
|
|
@ -15,7 +15,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
|
||||||
|
|
||||||
* [#136](https://github.com/Icinga/icinga-powershell-framework/pull/136) Adds support to ignore empty check packages and return `Ok` instead of `Unknown` if `-IgnoreEmptyPackage` is set on `New-IcingaCheckPackage`
|
* [#136](https://github.com/Icinga/icinga-powershell-framework/pull/136) Adds support to ignore empty check packages and return `Ok` instead of `Unknown` if `-IgnoreEmptyPackage` is set on `New-IcingaCheckPackage`
|
||||||
* [#137](https://github.com/Icinga/icinga-powershell-framework/issues/137) Adds Cmdlet to compare a DateTime object with the current DateTime and return the offset as Integer in seconds
|
* [#137](https://github.com/Icinga/icinga-powershell-framework/issues/137) Adds Cmdlet to compare a DateTime object with the current DateTime and return the offset as Integer in seconds
|
||||||
|
* [#139](https://github.com/Icinga/icinga-powershell-framework/pull/139) Add Cmdlet `Start-IcingaShellAsUser` to open an Icinga Shell as different user for testing
|
||||||
|
|
||||||
### Bugfixes
|
### Bugfixes
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,8 @@
|
||||||
'Get-IcingaCacheDir',
|
'Get-IcingaCacheDir',
|
||||||
'Get-IcingaPowerShellConfigDir',
|
'Get-IcingaPowerShellConfigDir',
|
||||||
'Get-IcingaFrameworkRootPath',
|
'Get-IcingaFrameworkRootPath',
|
||||||
'Get-IcingaPowerShellModuleFile'
|
'Get-IcingaPowerShellModuleFile',
|
||||||
|
'Start-IcingaShellAsUser'
|
||||||
)
|
)
|
||||||
CmdletsToExport = @()
|
CmdletsToExport = @()
|
||||||
VariablesToExport = '*'
|
VariablesToExport = '*'
|
||||||
|
|
|
||||||
|
|
@ -278,6 +278,7 @@ function Invoke-IcingaCommand()
|
||||||
Write-Output '******************************************************';
|
Write-Output '******************************************************';
|
||||||
Write-Output ([string]::Format('** Icinga PowerShell Framework {0}', $IcingaFrameworkData.PrivateData.Version));
|
Write-Output ([string]::Format('** Icinga PowerShell Framework {0}', $IcingaFrameworkData.PrivateData.Version));
|
||||||
Write-Output ([string]::Format('** Copyright {0}', $IcingaFrameworkData.Copyright));
|
Write-Output ([string]::Format('** Copyright {0}', $IcingaFrameworkData.Copyright));
|
||||||
|
Write-Output ([string]::Format('** User environment {0}\{1}', $env:USERDOMAIN, $env:USERNAME));
|
||||||
Write-Output '******************************************************';
|
Write-Output '******************************************************';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -310,5 +311,24 @@ function Invoke-IcingaCommand()
|
||||||
} -Args $ScriptBlock, $PSScriptRoot, $IcingaFrameworkData.PrivateData.Version;
|
} -Args $ScriptBlock, $PSScriptRoot, $IcingaFrameworkData.PrivateData.Version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Start-IcingaShellAsUser()
|
||||||
|
{
|
||||||
|
param (
|
||||||
|
[string]$User = ''
|
||||||
|
);
|
||||||
|
|
||||||
|
Start-Process `
|
||||||
|
-WorkingDirectory $PSHOME `
|
||||||
|
-FilePath 'powershell.exe' `
|
||||||
|
-Verb RunAs `
|
||||||
|
-ArgumentList (
|
||||||
|
[string]::Format(
|
||||||
|
"-Command `"Start-Process -FilePath `"powershell.exe`" -WorkingDirectory `"{0}`" -Credential (Get-Credential -UserName '{1}' -Message 'Please enter your credentials to open an Icinga Shell with') -ArgumentList icinga`"",
|
||||||
|
$PSHOME,
|
||||||
|
$User
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Set-Alias icinga Invoke-IcingaCommand -Description "Execute Icinga Framework commands in a new PowerShell instance for testing or quick access to data";
|
Set-Alias icinga Invoke-IcingaCommand -Description "Execute Icinga Framework commands in a new PowerShell instance for testing or quick access to data";
|
||||||
Export-ModuleMember -Alias * -Function *;
|
Export-ModuleMember -Alias * -Function *;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue