< Back
Export-ArchiveFile
Post
NAME Export-ArchiveFile
SYNOPSIS
Export and Archive files.
SYNTAX
Export-ArchiveFile [<CommonParameters>]
Export-ArchiveFile [-SourcePath] <String> -DestinationPath <String> [-FileType] <String[]>
[-ArchiveFilesOlderthan] <Int32> [[-ArchiveToZip]] [[-DeleteFilesFromSource]] [-Verify] [-Recurse] [-Force]
[<CommonParameters>]
DESCRIPTION
The Export-Archive command can be used to archive files. If required zipped and packaged into a single file.
PARAMETERS
-SourcePath <String>
The Source file path that file/s need to be Exported. This path needs to be a folder
Required? true
Position? 1
Default value
Accept pipeline input? true (ByValue, ByPropertyName)
Accept wildcard characters? false
-DestinationPath <String>
The Destination path the Exoported files need to be Copied/Moved
Required? true
Position? named
Default value
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false
-FileType <String[]>
File Type to archive. Multiple file types are supported with comma separation
Example ???????*.csv,*ps1,*.log???????
Required? true
Position? 2
Default value
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false
-ArchiveFilesOlderthan <Int32>
Export files older than the specified number of days. Example if all files older than 10 days needs to be
exported.
use value of 10
Required? true
Position? 3
Default value 0
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false
-ArchiveToZip [<SwitchParameter>]
This optional parameter is used to specify if the destination exported file/s needs to be zipped.
If this parameter is specified the ArchiveFilename parameter is Visible.
Required? false
Position? 4
Default value False
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false
-DeleteFilesFromSource [<SwitchParameter>]
If this optional parameter is specified files from the source directory is deleted(removed) after file has
been exported
Required? false
Position? 5
Default value False
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false
-Verify [<SwitchParameter>]
This parameter is used to verify that the source and destination files match on completion of the export
process.
The output of this will only be displayed if the -verbose switch is used
Required? false
Position? named
Default value False
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false
-Recurse [<SwitchParameter>]
Indicates that this gets the items in the specified locations and in all child items of the locations.
Required? false
Position? named
Default value False
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false
-Force [<SwitchParameter>]
Indicates that this command will overwrite items that cannot otherwise be changed, such as copying over a
read-only
file or alias.
Required? false
Position? named
Default value False
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
NOTES
The Export-Archive can be used to archive all files and subfolders. If the -force switch is used all duplicate
files will be overwritten in the destination
If the -force switch is used in conjunction with -ArchiveToZip the Zip file will be overwritten and updated
If the -force switch is used in conjunction with - DeleteFilesFromSource
the files will be deleted from the source even if file verification on both source and destination do not match
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Export-ArchiveFile -SourcePath C:\\scripts\\ -DestinationPath C:\\test\\ -FileType "*.csv"
-ArchiveFilesOlderthan 20 -ArchiveToZip - -Verify -Force -Recurse -Verbose
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Export-ArchiveFile -SourcePath C:\\scripts\\ -DestinationPath C:\\test\\ -FileType "*.csv"
-ArchiveFilesOlderthan 20 -ArchiveToZip -ArchiveFileName Test.zip -Verify -Force -Recurse -Verbose
RELATED LINKS
SYNOPSIS
Export and Archive files.
SYNTAX
Export-ArchiveFile [<CommonParameters>]
Export-ArchiveFile [-SourcePath] <String> -DestinationPath <String> [-FileType] <String[]>
[-ArchiveFilesOlderthan] <Int32> [[-ArchiveToZip]] [[-DeleteFilesFromSource]] [-Verify] [-Recurse] [-Force]
[<CommonParameters>]
DESCRIPTION
The Export-Archive command can be used to archive files. If required zipped and packaged into a single file.
PARAMETERS
-SourcePath <String>
The Source file path that file/s need to be Exported. This path needs to be a folder
Required? true
Position? 1
Default value
Accept pipeline input? true (ByValue, ByPropertyName)
Accept wildcard characters? false
-DestinationPath <String>
The Destination path the Exoported files need to be Copied/Moved
Required? true
Position? named
Default value
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false
-FileType <String[]>
File Type to archive. Multiple file types are supported with comma separation
Example ???????*.csv,*ps1,*.log???????
Required? true
Position? 2
Default value
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false
-ArchiveFilesOlderthan <Int32>
Export files older than the specified number of days. Example if all files older than 10 days needs to be
exported.
use value of 10
Required? true
Position? 3
Default value 0
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false
-ArchiveToZip [<SwitchParameter>]
This optional parameter is used to specify if the destination exported file/s needs to be zipped.
If this parameter is specified the ArchiveFilename parameter is Visible.
Required? false
Position? 4
Default value False
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false
-DeleteFilesFromSource [<SwitchParameter>]
If this optional parameter is specified files from the source directory is deleted(removed) after file has
been exported
Required? false
Position? 5
Default value False
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false
-Verify [<SwitchParameter>]
This parameter is used to verify that the source and destination files match on completion of the export
process.
The output of this will only be displayed if the -verbose switch is used
Required? false
Position? named
Default value False
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false
-Recurse [<SwitchParameter>]
Indicates that this gets the items in the specified locations and in all child items of the locations.
Required? false
Position? named
Default value False
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false
-Force [<SwitchParameter>]
Indicates that this command will overwrite items that cannot otherwise be changed, such as copying over a
read-only
file or alias.
Required? false
Position? named
Default value False
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
NOTES
The Export-Archive can be used to archive all files and subfolders. If the -force switch is used all duplicate
files will be overwritten in the destination
If the -force switch is used in conjunction with -ArchiveToZip the Zip file will be overwritten and updated
If the -force switch is used in conjunction with - DeleteFilesFromSource
the files will be deleted from the source even if file verification on both source and destination do not match
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Export-ArchiveFile -SourcePath C:\\scripts\\ -DestinationPath C:\\test\\ -FileType "*.csv"
-ArchiveFilesOlderthan 20 -ArchiveToZip - -Verify -Force -Recurse -Verbose
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Export-ArchiveFile -SourcePath C:\\scripts\\ -DestinationPath C:\\test\\ -FileType "*.csv"
-ArchiveFilesOlderthan 20 -ArchiveToZip -ArchiveFileName Test.zip -Verify -Force -Recurse -Verbose
RELATED LINKS