mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
Add support to specify a service for changing the user for
This commit is contained in:
parent
54476cbb6d
commit
4ec3d795ff
1 changed files with 5 additions and 4 deletions
|
|
@ -2,7 +2,8 @@ function Set-IcingaAgentServiceUser()
|
|||
{
|
||||
param(
|
||||
[string]$User,
|
||||
[securestring]$Password
|
||||
[securestring]$Password,
|
||||
[string]$Service = 'icinga2'
|
||||
);
|
||||
|
||||
if ([string]::IsNullOrEmpty($User)) {
|
||||
|
|
@ -14,14 +15,14 @@ function Set-IcingaAgentServiceUser()
|
|||
$User = [string]::Format('.\{0}', $User);
|
||||
}
|
||||
|
||||
$ArgString = 'config icinga2 obj= "{0}" password="{1}"';
|
||||
$ArgString = 'config {0} obj= "{1}" password="{2}"';
|
||||
if($null -eq $Password) {
|
||||
$ArgString = 'config icinga2 obj= "{0}"{1}';
|
||||
$ArgString = 'config {0} obj= "{1}"{2}';
|
||||
}
|
||||
|
||||
$Output = Start-IcingaProcess `
|
||||
-Executable 'sc.exe' `
|
||||
-Arguments ([string]::Format($ArgString, $User, (ConvertFrom-IcingaSecureString $Password))) `
|
||||
-Arguments ([string]::Format($ArgString, $Service, $User, (ConvertFrom-IcingaSecureString $Password))) `
|
||||
-FlushNewLines $TRUE;
|
||||
|
||||
if ($Output.ExitCode -eq 0) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue