PowerShell 範例

建立 System.Security.SecureString 類型的密碼

附註:如果您在 Arcserve UDP 6.5 中配置使用純文字密碼的 PowerShell 指令碼,請將其修改為使用 $SecurePassword 或使用密碼檔案。

說明

此指令是用來建立 System.Security.SecureString 類型的密碼,也會由所有其他指令使用。System.Security.SecureString 類型是系統預先定義的類型。有許多種方法能夠產生。下列兩種類型常用於不同用途:

範例 1

說明

此指令會加密安全密碼,並將其儲存到密碼檔案。

C:\PS>UDPPowerCLI.ps1 -Command CreatePswFile -Password $SecurePassword -PasswordFile myUDPPasswordFile

範例 2

說明

在本機伺服器上,此命令透過連接埠 8015 使用 HTTP 通訊協定連線到 UDP 主控台服務的,並對於名為 myplan 的計劃提交遞增備份工作。

C:\PS>UDPPowerCLI.ps1 -Command Backup -UDPConsoleUserName myUsr -UDPConsolePassword $SecurePassword -PlanName myPlan -BackupJobType Incr

範例 3

說明

在本機伺服器上,此命令透過連接埠 8015 使用 HTTP 通訊協定連線到 UDP 主控台服務的,並對於名為 myNodeName 的節點提交遞增備份工作。

C:\PS>UDPPowerCLI.ps1 -Command Backup -UDPConsoleUserName myUsr -UDPConsolePasswordFile myUDPPasswordFile -NodeName myNodeName -BackupJobType Incr

範例 4

說明

命令會透過連接埠 8015 使用 HTTPS 通訊協定連線到名稱為 myServer 的伺服器上的 UDP 主控台服務,然後對於名為 myPlan 的計劃提交完整備份工作,並將該工作說明設定為 myJob

C:\PS>UDPPowerCLI.ps1 -Command Backup -UDPConsoleServerName myServer -UDPConsoleProtocol https -UDPConsolePort 8015 -UDPConsoleUserName myUsr -UDPConsolePassword $SecurePassword -UDPConsoleDomainName myDomain -PlanName myPlan -BackupJobType Full -JobDescription myJob

範例 5

說明

此命令會透過連接埠 8014 使用 HTTP 通訊協定連線到名為 yourUDPAgentServer 的伺服器上的 UDP 代理程式服務,然後為 yourUDPAgentServer 提交遞增備份工作。

C:\PS>UDPPowerCLI.ps1 -Command Backup -UDPAgentServerName yourUDPAgentServer -UDPAgentPasswordFile myUDPAgentPasswordFile -BackupJobType Incr

範例 6

說明

此命令將縮短參數名稱。

C:\PS>UDPPowerCLI.ps1 -Cmd Backup -Svr myServer -Ptc https -Prt 8014 -Usr myUsr -Psw $SecurePassword -Dmn myDomain -Pln myPlan -Jbt Full -Jbd myJob

範例 7

說明

命令會使用環境的使用者名稱、預設 HTTP 通訊協定和連接埠 8014 連線到名為 yourUDPAgentServer 的伺服器。選取覆寫現有檔案的還原選項後,它會從 yourUDPAgentServer備份配置驗證備份工作階段號碼是 1,然後將目錄還原到原始位置。

C:\PS>UDPPowerCLI.ps1 -Command restore -UDPAgentServerName yourUDPAgentServer -UDPAgentPasswordFile myUDPAgentPasswordFile -RestoreDirectoryPath 'c:\Test' -BackupSessionNumber 1

範例 8

說明

命令使用 HTTPS 通訊協定和連接埠 8014連線到名為伺服器 yourUDPAgentServer。它會從 yourUDPAgentServer 備份配置中驗證備份工作階段號碼是 1,然後將 1.txt 檔案還原到替代位置。

C:\PS>UDPPowerCLI.ps1 -Command restore -UDPAgentServerName yourUDPAgentServer -UDPAgentUserName UDPAgentUsername -UDPAgentPasswordFile myUDPAgentPasswordFile -UDPAgentProtocol 'https' -UDPAgentPort 8014 -UDPAgentDomainName UDPAgentdomainName -BackupSessionNumber 1 -RestoreFilePath 'C:\1.txt' -RestoreDestination 'C:\restore' -RestoreDestinationUserName remoteAccessUser -RestoreDestinationPassword remoteAccessPsw

範例 9

說明

命令會使用環境的使用者名稱、預設 HTTP 通訊協定和連接埠 8014 連線到名為 yourUDPAgentServer 的伺服器。接著,它會使用預設連接埠 8015 和 HTTP 通訊協定連線至 UDP 伺服器,以確認備份工作階段號碼是 1。最後,它會將目錄還原至替代位置,並選取 [覆寫現有檔案和建立根目錄] 的還原選項。

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'

範例 10

說明

命令會使用環境的使用者名稱、預設 HTTP 通訊協定和連接埠 8014 連線到名為 yourUDPAgentServer 的伺服器。接著,它會使用預設連接埠 8015 和 HTTP 通訊協定連線至 UDP 伺服器,以確認備份工作階段號碼是 1。最後,它會將 VM 還原至原始位置,並選取復原 VM 選項作為覆寫現有 vm 同時在復原後開啟 vm。

C:\PS>UDPPowerCLI.ps1 -Command RecoverVM -UDPAgentServerName yourUDPAgentServer -UDPAgentPasswordFile myUDPAgentPasswordFile -BackupSessionNumber 1 -UDPConsoleServerName yourUDPServer -recovervmname sourceVMName -UDPConsolePasswordFile myUDPPasswordFile -UDPConsoleDomainName yourUDPDomainName -OverwriteExistingVM 'true' -PoweronVM 'true'

範例 11

說明

此命令會立即提交 UDP 代理程式上的每週備份工作,且僅會執行一次。

C:\PS>UDPPowerCLI.ps1 -Command Backup -UDPAgentServerName myServer -UDPAgentPassword $SecurePassword -UDPAgentDomainName myDomainName -UDPAgentUserName UDPAgentUsername -BackupJobType Incr -backupScheduleType 'weekly' -jobDescription 'PowerCLIJob'

範例 12

說明

此命令會提交備份工作,並設定等候工作完成的逾時秒數。

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'