BooDaa63

Untitled

Aug 28th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. Function Disable-Backups ($UserInput) {
  2. $AvamarCommand1="mccli client edit --name=/clients/$userinput.domain.com --activated=false --enabled=False"
  3. $AvamarCommand2="mccli group move-client --client-name=/clients/$userinput.domain.com --name=/clients/'Disabled Backups' --old-group-name=/clients/DefaultBackups"
  4. $AvamarServer = "BackupServer.backup.com"
  5. $User = "UserName"
  6. $Password = Get-Content C:\Powershell\Decommission-Server\cred.txt |ConvertTo-SecureString
  7. $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $User,$Password
  8. Add-Content $LogFile "Establishing SSH Session to Avamar Server"
  9. Echo "Establishing SSH Session to Avamar Server"
  10. $shesh = New-SSHSession -computername $AvamarServer -Credential $cred
  11. Add-Content $LogFile "Disabling Backups for $UserInput"
  12. Echo "Disabling Backups for $UserInput"
  13. $DisableClient = Invoke-SSHCommand -SessionId $shesh.SessionId -Command $AvamarCommand1
  14. Add-Content $LogFile $DisableClient.output
  15. Add-Content $LogFile "Moving $UserInput to Disabled Backups Group"
  16. Echo "Moving $UserInput to Disabled Backups Group"
  17. $MoveClient = Invoke-SSHCommand -SessionId $shesh.SessionId -Command $AvamarCommand2
  18. Add-Content $LogFile $MoveClient.output
  19. Add-Content $LogFile "Removing SSH Session to Avamar Server"
  20. Echo "removing SSH Session to Avamar Server"
  21. Remove-SSHSession -SessionId $shesh.sessionid
  22. }
Add Comment
Please, Sign In to add comment