I’m trying to create a backup policy in SqlSafe using their command line. When I run the command in a Windows Command Prompt, the policy is created as expected but I want to add this to a PowerShell script and trying to find a way of running the command in PowerShell. I’ve tried unsuccessfully using Invoke-Command and Invoke-Expression.
The command I need to run is, see below, how can I run that using PowerShell
SQLsafeCmd Create-Policy Backup "System DBs > servername > Full" -IncludeInstance "servername\Instance" -IncludeDatabases {AllSystem} -BackupType Full -CompressionLevel 3 -EncryptionType AES256 -BackupEncryptionPassword password -IncludeLogins -MirrorFile "\\nas01\SQLBackups_No_IR\SystemDBs\%database%\%instance%_%database%_%backuptype%_%timestamp%.safe" -BackupFile "\\servername\sqlbackups\systemdbs\%instance%_database%_%backuptype%_%timestamp%.safe" -Delete 1Weeks -DeleteMirror 2Weeks -RetryWrites 10 300 60 -Schedule Daily -StartTime 03:00 -useagentaccount no -WindowsUsername userid -WindowsPassword password