SQLsafeCmd Create-Policy

Welcome Forums General PowerShell Q&A SQLsafeCmd Create-Policy

Viewing 2 reply threads
  • Author
    Posts
    • #192391
      Participant
      Topics: 50
      Replies: 206
      Points: 838
      Helping Hand
      Rank: Major Contributor

      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
      
      
    • #192430
      Participant
      Topics: 5
      Replies: 2411
      Points: 6,193
      Helping Hand
      Rank: Community MVP

      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?

    • #192511
      Participant
      Topics: 50
      Replies: 206
      Points: 838
      Helping Hand
      Rank: Major Contributor

      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?

      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

Viewing 2 reply threads
  • The topic ‘SQLsafeCmd Create-Policy’ is closed to new replies.