Windows Backup

We use a command step to run Windows Backup (wbadmin.exe).  95% of our computers have a D:\ drive.  The other 5% have either have an E:\ or no partition at all.  Using your suggest PowerShell-Step-Deployments-and-Error-Handling, I have been able to identify them with an exit code.  How can I put some logic into my deployment so that it doesn't just exit?  Maybe a PowerShell step that can identify the drives and backup either C:,D: or C:,E: or C only, if the first two don't exists.

Step 1 - 'D:' was not found.

Try {
Get-ChildItem D:\ -ErrorAction Stop
Catch {
exit 777

Step 2 - Run Windows Backup C:,D:

# covers 95%

wbadmin.exe start backup -backuptarget:\\backuptarget\share -include:C:,D: -vssCopy -quiet

# covers the other 5%

wbadmin.exe start backup -backuptarget:\\backuptarget\share -include:C:,E: -vssCopy -quiet

- or -

wbadmin.exe start backup -backuptarget:\\backuptarget\share -include:C: -vssCopy -quiet

Any suggestions or help in a wbadmin deployment is appreciated.





Date Votes
  • Couple questions:


    1) What OS are your hosts running? All windows 7? All 8.1? Mix?

    2) How are you avoiding using an Optical Drive?


    I'd suggest wrapping logic around this:


    $hash = @{

    2 = "Removable Disk"
    3 = "Fixed local disk"
    4 = "Network Disk"
    5 = "Compact Disk"


    $disks = Get-CimInstance Win32_LogicalDisk | Select DeviceID, VolumeName,

    Expression = {$hash.item([int]$_.DriveType)}}


    That will list all your disks (Network, Fixed local, and optical). 

    Design logic that pulls out the Fixed Disks to a Variable, identify the C: drive and the second drive for backup (whatever that letter may be per host) and throw those two items to their own variable (I suggest something like $firstsource and $secondsource for readability, and then start your backup job. with:

    wbadmin.exe start backup -backuptarget:\\backuptarget\share -include:$source,$secondsource -vssCopy -quiet

    That should at least get your gears turning. If you need more help let me know, but I want you to figure out how to write it so you gain the understanding of how it all works together. If you get stuck, I'm here.

  • This is a good start.  We have a mixed environment of Windows 7 and Windows 10.  I am only concerned with Fixed local disk.  However, some have additional drives plugged in as slaves that I do not want to backup.  This is the reason I am specifying the C:,D: and not -allcritical.

  • Makes perfect sense. That building block I gave you will get you the data you need to perform your tests before executing the backup job. Like I said, I'd like you to take the lead of fleshing the powershell script out, but if you get stuck, I'm here to help!


Please sign in to leave a comment.

Didn't find what you were looking for?

New post