PoshCode Logo PowerShell Code Repository

Check Backups by gonads99 5 weeks ago
embed code: <script type="text/javascript" src="http://PoshCode.org/embed/6852"></script>download | new post

Check for successful backups in NetWorker

  1. # lists
  2. $devList = New-Object System.Collections.ArrayList
  3. $prodList = New-Object System.Collections.ArrayList
  4.  
  5. Try {
  6.     $hostList = gc $hostsToCheckFile -ErrorAction Stop
  7. }
  8. Catch {
  9.     #$ErrorMessage = $_.Exception.Message
  10.     #$FailedItem = $_.Exception.ItemName
  11.     echo "ERROR: Could not open $hostsToCheckFile..."
  12.     Break
  13. }
  14.    
  15.  
  16. foreach ($line in $hostList) {
  17.     #echo "$line"
  18.  
  19.     if ($line -match "^nzp") {
  20.         echo "Adding $line to prod list..."
  21.         $prodList.Add($line)
  22.     }
  23.     elseif ($line -match "^nz") {
  24.         echo "Adding $line to dev list..."
  25.         $devList.Add($line)
  26.     }
  27.     else {
  28.         echo "Cannot process $line..."
  29.     }
  30. }
  31.  
  32. # create a new remote session on the NSR server
  33. $s = New-PSSession -ComputerName $devServer #-Credential $devCreds
  34.  
  35. # $devList array needs to be wrapped in an array as ArgumentList expects an array of arguments. See http://stackoverflow.com/questions/17577705/passing-array-to-another-script-with-invoke-command.
  36. Invoke-Command -Session $s -ArgumentList (,$devList) -ScriptBlock {
  37.     param($devList)
  38.  
  39.     #$devList
  40.  
  41.     foreach ($client in $devList) {
  42.         echo "Checking client $client..."
  43.         $out = (mminfo -q "savetime>=24 hours ago,name=/,client=$client" -ot -r "savetime,client,name,sumsize,level")
  44.         echo $out
  45.     }
  46. }
  47.  
  48.  
  49. # There's a limit of 5 remote PS sessions per user
  50. echo "Removing PS session..."
  51. Remove-PSSession $s

Submit a correction or amendment below (
click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:


Remember me