diff --git a/changelogs/fragments/48728-win_nssm-credential-quoting.yml b/changelogs/fragments/48728-win_nssm-credential-quoting.yml new file mode 100644 index 00000000000..1579ca9afcd --- /dev/null +++ b/changelogs/fragments/48728-win_nssm-credential-quoting.yml @@ -0,0 +1,2 @@ +bugfixes: + - "win_nssm - Switched to Argv-ToString for escaping NSSM credentials (https://github.com/ansible/ansible/issues/48728)" diff --git a/lib/ansible/modules/windows/win_nssm.ps1 b/lib/ansible/modules/windows/win_nssm.ps1 index 0a9cb420a96..323eeb0d712 100644 --- a/lib/ansible/modules/windows/win_nssm.ps1 +++ b/lib/ansible/modules/windows/win_nssm.ps1 @@ -403,7 +403,7 @@ Function Nssm-Update-Credentials } If ($nssm_result.stdout.split("`n`r")[0] -ne $fullUser) { - $cmd = "set ""$name"" ObjectName $fullUser '$password'" + $cmd = Argv-ToString @("set", $name, "ObjectName", $fullUser, $password) $nssm_result = Nssm-Invoke $cmd if ($nssm_result.rc -ne 0)