Add-WBFileSpec

Syntax

Detailed Description

The Add-WBFileSpec cmdlet adds a backup file specification, which specifies the items to include in or exclude from a backup, to a backup policy. A WBFileSpec object contains the backup file specification, and a WBPolicy object contains the backup policy. The WBFileSpec object can include or exclude multiple files, folders, or volumes. You can create a list of items to include or exclude by using the New-WBFileSpec cmdlet and then using the Add-WBFileSpec cmdlet to update the WBPolicy object.

Before you can add a backup file specification to a WBPolicy object, you must put the WBPolicy object in edit mode. To put the WBPolicy object in edit mode for a policy that you set as the scheduled backup policy, use the Get-WBPolicy cmdlet with the Editable parameter. The New-WBPolicy cmdlet creates a new WBPolicy object that is already in edit mode.

To use Windows Server® 2012 Backup cmdlets, you must be a member of the Administrators group or Backup Operators group.

Parameters

-FileSpec<WBFileSpec[]>

Specifies an array of WBFileSpec objects that contain backup file specifications to add to the WBPolicy object.

Aliases

none

Required?

true

Position?

2

Default Value

none

Accept Pipeline Input?

True (ByValue)

Accept Wildcard Characters?

false

-Policy<WBPolicy>

Specifies a WBPolicy object that contains the backup policy to update.

Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

True (ByValue)

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/p/?LinkID=113216).

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

WBFileSpec [], WBPolicy

The Add-WBFileSpec cmdlet adds a list of items from a WBFileSpec object that contains a backup file specification to a WBPolicy object that contains a backup policy.

Outputs

The output type is the type of the objects that the cmdlet emits.

None

None

Examples

Example 1: Add backup file specifications to a backup policy

This example adds three backup file specifications to the WBPolicy object in the variable named $Policy.

The first command assigns the file named C:\sample\1.jpg to the variable named $Filespec1.

The second command assigns the files that match the wildcard specification C:\Sample\*.txt (text files in the C:\Sample directory) to the variable named $Filespec2.

The third command assigns the files that match the wildcard specification C:\Sample\*.mp3 txt (MP3 files in the C:\Sample directory) to the variable named $Filespec3. Because this command includes the Exclude parameter, the backup from this policy excludes MP3 files in C:\Sample.

The fourth command adds the file specifications in $Filespec1, $Filespec2, and $Filespec3 to the backup policy in the variable named $Policy.