- Windows Server 2016 Automation with PowerShell Cookbook(Second Edition)
- Thomas Lee
- 213字
- 2025-04-04 18:24:20
Getting ready
This recipe assumes you have loaded the Windows Server Backup feature and that you have no active WSB backup policy on the printer server PSRV. To install the Windows Server Backup feature, do this:
Install-WindowsFeature -Name Windows-Server-Backup
You also need to ensure you have no active backup policy set on this server. To ensure this is the case, do this:
If (Get-WBPolicy) { Remove-WBPolicy -All -Force }
This code fragment first tests to see if there is an active policy, and if so, removes it. By using the -Force parameter, Remove-WBPolicy does not prompt you to complete the operation, which is what you want if you are automating setting up backup on one or more computers.
This recipe also assumes you have two physical disks in the PSRV computer. You should set the first to C:, and you should create a second disk with just a single volume. Give this new volume a drive letter set to E:. For testing, you can always use a virtual hard drive for the E: volume.
In a production environment, backup up to a second volume or a virtual hard disk stored on a single physical disk is not a good idea. For production, always ensure the backup target is on a separate physical disk.