title: Backup SSRS Encryption Keys Using Powershell
body: <p>I have made the following script from google for backing up the SSRS Encryption keys:</p>
  
  <pre><code>cls
  $pwd = "sa@123@123"
  $SSRSClass = Get-Wmiobject -namespace "root\microsoft\sqlserver\reportserver\rs_BPSSRS\v10\admin" -class "MSReportServer_ConfigurationSetting"
  
  $key = $SSRSClass.BackupEncryptionKey($pwd)
  $stream = [System.IO.File]::Create("c:\\SSRS.snk", $key.KeyFile.Length)
  $stream.Write($key.KeyFile, 0, $key.KeyFile.Length)
  $stream.Close()
  </code></pre>
  
  <p>But I'm getting the following errors:</p>
  
  <pre><code>Method invocation failed because [System.Object[]] doesn't contain a method named 'BackupEn
  cryptionKey'.
  At line:5 char:38
  + $key = $SSRSClass.BackupEncryptionKey &lt;&lt;&lt;&lt; ($results)
      + CategoryInfo          : InvalidOperation: (BackupEncryptionKey:String) [], RuntimeEx 
     ception
      + FullyQualifiedErrorId : MethodNotFound
  
  Exception calling "Create" with "2" argument(s): "Positive number required.
  Parameter name: bufferSize"
  At line:6 char:35
  + $stream = [System.IO.File]::Create &lt;&lt;&lt;&lt; ("c:\\SSRS.snk", $key.KeyFile.Length)
      + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
      + FullyQualifiedErrorId : DotNetMethodException
  
  You cannot call a method on a null-valued expression.
  At line:7 char:14
  + $stream.Write &lt;&lt;&lt;&lt; ($key.KeyFile, 0, $key.KeyFile.Length)
      + CategoryInfo          : InvalidOperation: (Write:String) [], RuntimeException
      + FullyQualifiedErrorId : InvokeMethodOnNull
  
  You cannot call a method on a null-valued expression.
  At line:8 char:14
  + $stream.Close &lt;&lt;&lt;&lt; ()
      + CategoryInfo          : InvalidOperation: (Close:String) [], RuntimeException
      + FullyQualifiedErrorId : InvokeMethodOnNull
  </code></pre>
  
  <p>I'm using powershell v2. I tried finding about this but no luck. There are around 50+ SSRS servers in our environment and doing backup manually is tiresome. Hence, we came up with this automation. Kindly provide your comments.</p>
  
  <p>Thanks</p>