Add-WBFileSpec

Add-WBFileSpec

Adds the WBFileSpec object, which specifies the items to include or exclude from a backup, to the backup policy (WBPolicy object).

Syntax

Add-WBFileSpec [-Policy] <WBPolicy> [-FileSpec] <WBFileSpec[]> [<CommonParameters>]

Detailed Description

The Add-WBFileSpec cmdlet adds the WBFileSpec object, which specifies the items to include or exclude from a backup, to the backup policy (WBPolicy object). The WBFileSpec object can include or exclude multiple files, folders, or volumes. You can define the list of items to include by using the New-WBFileSpec cmdlet and then using this cmdlet to update the WBPolicy object.

Parameters

-FileSpec <WBFileSpec[]>

Specifies the WBFileSpec object to add to the backup policy (WBPolicy object).

Attributes

Name Value

Required?

true

Accept wildcard characters?

false

Accept Pipeline Input?

true (ByValue)

Position?

2

-Policy <WBPolicy>

Specifies the backup policy (WBPolicy object) to update.

Attributes

Name Value

Required?

true

Accept wildcard characters?

false

Accept Pipeline Input?

true (ByValue)

Position?

1

-CommonParameter

This cmdlet supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, WarningVariable, OutBuffer, and OutVariable. For more information, see about_CommonParameters.

Input and Return Types

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

Notes

  • The WBPolicy object must be in edit mode. To put the WBPolicy object in edit mode for a policy that has been 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 Backup cmdlets, you must be a member of the Administrators group or Backup Operators group.

Examples

EXAMPLE 1

C:\PS>$filespec1 = New-WBFileSpec -FileSpec C:\sample\1.jpg 
$filespec2 = New-WBFileSpec -FileSpec C:\sample\*.txt 
$filespec3 = New-WBFileSpec -FileSpec C:\sample\*.mp3 -Exclude 
Add-WBFileSpec -Policy $policy $filespec1,$filespec2,$filespec3

None

Description

-----------

Adds three file specs to the WBPolicy object $policy.

EXAMPLE 2

C:\PS>$filespecarray = ($filespec1, $filespec2, $filespec3) 
Add-WBFileSpec -Policy $policy $filespecarray

None

Description

-----------

Adds the array of file specs to the WBPolicy object $policy.

See Also

Reference

Get-WBFileSpec
New-WBFileSpec
New-WBPolicy