Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function Disable-Backups ($UserInput) {
- $AvamarCommand1="mccli client edit --name=/clients/$userinput.domain.com --activated=false --enabled=False"
- $AvamarCommand2="mccli group move-client --client-name=/clients/$userinput.domain.com --name=/clients/'Disabled Backups' --old-group-name=/clients/DefaultBackups"
- $AvamarServer = "BackupServer.backup.com"
- $User = "UserName"
- $Password = Get-Content C:\Powershell\Decommission-Server\cred.txt |ConvertTo-SecureString
- $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $User,$Password
- Add-Content $LogFile "Establishing SSH Session to Avamar Server"
- Echo "Establishing SSH Session to Avamar Server"
- $shesh = New-SSHSession -computername $AvamarServer -Credential $cred
- Add-Content $LogFile "Disabling Backups for $UserInput"
- Echo "Disabling Backups for $UserInput"
- $DisableClient = Invoke-SSHCommand -SessionId $shesh.SessionId -Command $AvamarCommand1
- Add-Content $LogFile $DisableClient.output
- Add-Content $LogFile "Moving $UserInput to Disabled Backups Group"
- Echo "Moving $UserInput to Disabled Backups Group"
- $MoveClient = Invoke-SSHCommand -SessionId $shesh.SessionId -Command $AvamarCommand2
- Add-Content $LogFile $MoveClient.output
- Add-Content $LogFile "Removing SSH Session to Avamar Server"
- Echo "removing SSH Session to Avamar Server"
- Remove-SSHSession -SessionId $shesh.sessionid
- }
Add Comment
Please, Sign In to add comment