New-WBFileSpec
New-WBFileSpec
Creates a new WBFileSpec object.
Syntax
New-WBFileSpec [-FileSpec] <string[]> [-NonRecursive] [-Exclude] [<CommonParameters>]
Detailed Description
The New-WBFileSpec cmdlet creates a new WBFileSpec object based on the parameters you specify. The WBFileSpec object defines what items will be included or excluded from backups.
Parameters
-Exclude <SwitchParameter>
Specifies the items to exclude from the WBFileSpec object. This parameter is optional.
Attributes
Name | Value |
---|---|
Required? |
false |
Accept wildcard characters? |
false |
Accept Pipeline Input? |
false |
Position? |
3 |
-FileSpec <string[]>
Specifies the list of items for the WBFileSpec object. This parameter can include file paths and volumes (such as C:\) or file specs (such as C:\dir1\*.*).
Attributes
Name | Value |
---|---|
Required? |
true |
Accept wildcard characters? |
false |
Accept Pipeline Input? |
false |
Position? |
1 |
-NonRecursive <SwitchParameter>
Specifies whether the items in the WBFileSpec object will be backed up non-recursively (only the items specified and not the items subordinate in the file structure). If not specified, the items will be backed up recursively. This parameter is optional.
Attributes
Name | Value |
---|---|
Required? |
false |
Accept wildcard characters? |
false |
Accept Pipeline Input? |
false |
Position? |
2 |
-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
You can include multiple files, folders, or volumes. Volume paths can be specified using volume drive letters, volume mount points, or GUID-based volume names. If you use a GUID-based volume name, it should be terminated with a backslash (\). You can use the wildcard character (*) in the file name when specifying a path to a file or when specifying a file type to include or exclude.
You can also specify whether the items in WBFileSpec are recursive (include the item and everything subordinate to the item in the file structure) or non-recursive (include only the item).
To use Windows Server Backup cmdlets, you must be a member of the Administrators group or Backup Operators group.
Examples
EXAMPLE 1
C:\PS>$filespec = New-WBFileSpec -FileSpec C:\sample\1.jpg
The WBFileSpec object that specifies the file C:\sample\1.jpg for backup.
Description
-----------
Creates the file spec for the file C:\sample\1.jpg.
EXAMPLE 2
C:\PS>$filespec = New-WBFileSpec -FileSpec C:\sample
The WBFileSpec object that specifies the directory C:\sample for backup.
Description
-----------
Creates the file spec for the directory C:\sample. The contents for the directory and its subfolders will be backed up if the file spec is added to the backup policy (WBPolicy object).
EXAMPLE 3
C:\PS>$filespec = New-WBFileSpec -FileSpec C:\sample -NonRecursive
The WBFileSpec object that specifies the directory C:\sample for backup non-recursively.
Description
-----------
Creates the file spec for the directory C:\sample. The contents for the directory will be backed up if this file spec is added to the backup policy (WBPolicy object), but the contents of its subfolders will not backed up.
EXAMPLE 4
C:\PS>$filespec = New-WBFileSpec -FileSpec C:\sample\*.mp3 -Exclude
The WBFileSpec object that specifies the exclusion of*.mp3 files during backup under the path C:\sample.
Description
-----------
Creates the exclusion file spec for *.mp3 files under the path C:\sample. The *.mp3 files in C:\sample or its subfolders will not be part of the backup, if this file spec is added to the backup policy (WBPolicy object). Exclusion paths which are not under any inclusion path file specs in the policy will ignored at the time of the backup.