PowerShell Examples
Create System.Security.SecureString type of password
Note: If you have a configured PowerShell script in Arcserve UDP 6.5 that uses a plain text password, modify the same to use $SecurePassword or use the password file.
Description
The command is used to create the password with System.Security.SecureString type and is also used by all other commands. The System.Security.SecureString type is system predefined type. There are many ways to generate it. The following two types are commonly used for different purposes:
- This command asks for inputting the password on the PowerShell Console. It requires interaction with the end users. Usually after executing this command, we could execute the command CreatePswFile to write the password to a password file. And then use the password file for running PowerShell scripts automatically.
- This command requires the password with plain text. It could use used directly for running PowerShell scripts automatically.
- (Optional) After executing one of the previous commands to assign a password, execute the CreatePswFile command to write the password to a password file. Next, use the password file for running the PowerShell scripts automatically.
- The command encrypts secure password and saves it to the password file.
$SecurePassword = Read-Host -AsSecureString
$SecurePassword = ConvertTo-SecureString “<PlainPassword>” -AsPlainText -Force
C:\PS>UDPPowerCLI.ps1 -Command CreatePswFile -Password $SecurePassword -PasswordFile myUDPPasswordFile
Example 1
Description
The command encrypts secure password and save it to the password file.
C:\PS>UDPPowerCLI.ps1 -Command CreatePswFile -Password $SecurePassword -PasswordFile myUDPPasswordFile
Example 2
Description
On the local server, the command connects to the UDP Console service with HTTP protocol over port 8015, and then submits an Incremental backup job for the plan named myplan.
C:\PS>UDPPowerCLI.ps1 -Command Backup -UDPConsoleUserName myUsr -UDPConsolePassword $SecurePassword -PlanName myPlan -BackupJobType Incr
Example 3
Description
On the local server, the command connects to the UDP Console service with HTTP protocol over port 8015, and then submits an Incremental backup job for the node named myNodeName.
C:\PS>UDPPowerCLI.ps1 -Command Backup -UDPConsoleUserName myUsr -UDPConsolePasswordFile myUDPPasswordFile -NodeName myNodeName -BackupJobType Incr
Example 4
Description
The command connects to the UDP Console service on the server named myServer with HTTPS protocol over port 8018, and then submits a Full backup job for the plan named myPlan, and set the job description as myJob.
C:\PS>UDPPowerCLI.ps1 -Command Backup -UDPConsoleServerName myServer -UDPConsoleProtocol https -UDPConsolePort 8018 -UDPConsoleUserName myUsr -UDPConsolePassword $SecurePassword -UDPConsoleDomainName myDomain -PlanName myPlan -BackupJobType Full -JobDescription myJob
Example 5
Description
The command connects to the UDP agent service on the server named yourUDPAgentServer with HTTP protocol over port 8014, and then submits an Incremental backup job for yourUDPAgentServer.
C:\PS>UDPPowerCLI.ps1 -Command Backup -UDPAgentServerName yourUDPAgentServer -UDPAgentPasswordFile myUDPAgentPasswordFile -BackupJobType Incr
Example 6
Description
The command shortens the Parameter name.
C:\PS>UDPPowerCLI.ps1 -Cmd Backup -Svr myServer -Ptc https -Prt 8018 -Usr myUsr -Psw $SecurePassword -Dmn myDomain -Pln myPlan -Jbt Full -Jbd myJob
Example 7
Description
The command connects to the server named yourUDPAgentServer using the user name of the environment, the default HTTP protocol, and port 8014. It verifies the backup session number is 1 from the yourUDPAgentServer backup configuration and then restores the directory to the original location, with the restore option selected as Overwrite existing files.
C:\PS>UDPPowerCLI.ps1 -Command restore -UDPAgentServerName yourUDPAgentServer -UDPAgentPasswordFile myUDPAgentPasswordFile -RestoreDirectoryPath 'c:\Test' -BackupSessionNumber 1
Example 8
Description
The command connects to the server named yourUDPAgentServer using the HTTPS protocol and port 8018. It verifies the backup session number is 1 from the yourUDPAgentServer backup configuration and then restores the 1.txt file to an alternate location, with the restore option selected as Overwrite existing file and create root directory.
C:\PS>UDPPowerCLI.ps1 -Command restore -UDPAgentServerName yourUDPAgentServer -UDPAgentUserName UDPAgentUsername -UDPAgentPasswordFile myUDPAgentPasswordFile -UDPAgentProtocol 'https' -UDPAgentPort 8018 -UDPAgentDomainName UDPAgentdomainName -BackupSessionNumber 1 -RestoreFilePath 'C:\1.txt' -RestoreDestination 'C:\restore' -RestoreDestinationUserName remoteAccessUser -RestoreDestinationPassword remoteAccessPsw -CreateBaseFolder 'true'
Example 9
Description
The command connects to the server named yourUDPAgentServer using the user name of the environment, the default HTTP protocol, and port 8014. Then, it connects to the UDP server using the default port 8015 and protocol HTTP to check the backup session number is 1. Lastly, it restores the directory to an alternate location, with the restore option selected as Overwrite existing file and create root directory.
C:\PS>UDPPowerCLI.ps1 -Command restore -UDPAgentServerName yourUDPAgentServer -UDPAgentPasswordFile myUDPAgentPasswordFile -RestoreDirectoryPath 'c:\Test' -BackupSessionNumber 1 -RestoreDestination 'C:\restore' -RestoreDestinationUserName remoteAccessUser -RestoreDestinationPassword remoteAccessPsw -UDPConsoleServerName yourUDPServer -vmname sourceVMName -UDPConsolePasswordFile myUDPPasswordFile -domainname yourUDPDomainName -OverwriteExistFiles 'true' -CreateRootFolder 'true'
Example 10
Description
The command connects to the server named yourUDPAgentServer using the user name of the environment, the default HTTP protocol, and port 8014. Then, it connects to the UDP server using the default port 8015 and protocol HTTP to check the backup session number is 1. Lastly, it recovers the VM to the original location, with the recover VM option selected as Overwrite existing vm and power on vm after recovered.
C:\PS>UDPPowerCLI.ps1 -Command RecoverVM -UDPAgentServerName yourUDPAgentServer -UDPAgentPasswordFile myUDPAgentPasswordFile -BackupSessionNumber 1 -UDPConsoleServerName yourUDPServer -recovervmname sourceVMName -UDPConsolePasswordFile myUDPPasswordFile -UDPConsoleDomainName yourUDPDomainName -OverwriteExistingVM 'true' -PoweronVM 'true'
Example 11
Description
The command submits weekly backup job on the UDP Agent immediately and runs only one time.
C:\PS>UDPPowerCLI.ps1 -Command Backup -UDPAgentServerName myServer -UDPAgentPassword $SecurePassword -UDPAgentDomainName myDomainName -UDPAgentUserName UDPAgentUsername -BackupJobType Incr -backupScheduleType 'weekly' -jobDescription 'PowerCLIJob'
Example 12
Description
The command submits the backup job and sets the timeout in seconds to wait for the job to complete.
C:\PS>UDPPowerCLI.ps1 -Command Backup -UDPConsoleServerName myServer -UDPConsolePasswordFile myUDPPasswordFile -UDPConsoleDomainName myDomainName -nodeName myNodeName -UDPConsoleUserName myAdmin -BackupJobType Incr -jobDescription 'PowerCLIJob' waitJobFinish 'true' -timeout 600 -jobType 'agentbase'