I'm trying to utilize this document in SSM to remove a computer object from Active Directory when it's triggered by a lambda function. I can not get it to recognize the $false boolean as needed to make the -Confirm parameter work as needed. It's needed to bypass the prompt that comes up when using that command.
Here's what i've attempted to use unsuccessfully in the command section to get around it:
[boolean]::Parse('false')
$false = False, ([System.Convert]::ToBoolean($false))
$ConfirmPreference='None'
Command:
Send-SSMCommand -DocumentName AWS-RunPowerShellScript -InstanceId i-0fb07c751beb53f97 -Parameter @{executionTimeout= '60'; commands=@("Remove-ADComputer -Credential $credentials -Identity $tag -Confirm:$false")}
Using AWSPowershell.NetCore 4.0.1.1 and SDK 3.1, although this same issue was occuring with the 3.X version as well (i went to the newest version thinking it may help)
Remove-ADComputer : Cannot convert 'System.String' to the type
'System.Management.Automation.SwitchParameter' required by parameter
'Confirm'.
At C:\ProgramData\Amazon\SSM\InstanceData\i-0fb07c751beb53f97\document\orchestr
ation\628c99dc-7a6a-4951-99ca-2d07127d678c\awsrunPowerShellScript\0.awsrunPower
ShellScript\_script.ps1:1 char:106
+ ... gement.Automation.PSCredential -Identity LAMBDA-7A9BB4 -Confirm:False
+ ~~~~~
+ CategoryInfo : InvalidArgument: (:) [Remove-ADComputer], Parame
terBindingException
+ FullyQualifiedErrorId : CannotConvertArgument,Microsoft.ActiveDirectory.
Management.Commands.RemoveADComputer
In the Parameters pane of the command when viewing it in the SSM console, here's the the command looks like if it helps: It gets the values for the variables from the lambda function
"Remove-ADComputer -Credential System.Management.Automation.PSCredential -Identity LAMBDA-7A9BB4 -Confirm:false" executionTimeout "60"