SQLsafeCmd Create-Policy

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

Powershell is - just like CMD - a command line shell. If this command line runs this way in CMD it should run in Powershell as well just like it is. Did you try it? What happend?

[quote quote=192430]Powershell is – just like CMD – a command line shell. If this command line runs this way in CMD it should run in Powershell as well just like it is. Did you try it? What happend?

[/quote]

Yes, I’ve tried before coming on here…

If I open a cmd line session, and run the command, it works as expected. If I open a PowerShell session and run the command, I get an error

SQLsafe Backup and Recovery CLI Version 8.5.1.165 (x64)
Copyright (c) 2004-2017 Idera, Inc., All Rights Reserved.
<http://www.idera.com/>

Syntax Error:
Invalid argument: -inputFormat
Invalid argument: -outputFormat

If I try running the command using invoke-command, as I do with other command line tools, nothing is done and no errors.

 

update: I’m trying to add this as a step in a script