I'm trying to restore RDS DB using the InvokeSQL command and there is a use case to explicitly call pwsh!
The below works a gem
Invoke-Sqlcmd -Query 'exec msdb.dbo.rds_restore_database @s3_arn_to_restore_from="arn:aws:s3:::XXX/XX/XXX.bak",@restore_db_name=mydatabase' -ServerInstance XXXXX.eu-west-1.rds.amazonaws.com -Database master -Username XXX -Password XXX
But I have a problem while executing it as pwsh -command
pwsh -Command "& {Invoke-Sqlcmd -Query 'exec msdb.dbo.rds_restore_database @s3_arn_to_restore_from="arn:aws:s3:::XXX/XX/XXX.bak",@restore_db_name=mydatabase' -ServerInstance XXXXX.eu-west-1.rds.amazonaws.com -Database master -Username XXX -Password XXX}"
The error I get is a syntax issue-
pwsh : [91mInvoke-Sqlcmd: [91mIncorrect syntax near 'arn:'. At line:1 char:1
- pwsh -Command "& {Invoke-Sqlcmd -Query 'exec msdb.dbo.rds_restore_dat ...
-
+ CategoryInfo : NotSpecified: ([91mInvoke-Sql...x near 'arn:'. :String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError