├── .github └── workflows │ └── tests.yml ├── .vscode ├── settings.json ├── tasks.json └── tasks.json.old ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── Robocopy.build.ps1 ├── RobocopyPS ├── RobocopyPS.psd1 ├── RobocopyPS.psm1 ├── en-US │ └── RobocopyPS-help.xml ├── functions │ ├── Copy-RoboItem.ps1 │ ├── Get-RoboItem.ps1 │ ├── Invoke-RoboCopy.ps1 │ ├── Move-RoboItem.ps1 │ ├── Remove-RoboItem.ps1 │ └── Sync-RoboItem.ps1 └── internal │ ├── Format-SpeedHumanReadable.ps1 │ ├── Invoke-RobocopyParser.ps1 │ └── New-ProxyFunction.ps1 ├── build.ps1 ├── docs ├── Copy-RoboItem.md ├── Get-RoboItem.md ├── Invoke-RoboCopy.md ├── Move-RoboItem.md ├── Remove-RoboItem.md └── Sync-RoboItem.md └── tests ├── CompabilitySettings.psd1 ├── Help.Tests.ps1 └── Invoke-RobocopyParser.Tests.ps1 /.github/workflows/tests.yml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | on: [push] 3 | 4 | jobs: 5 | build: 6 | name: Run Tests 7 | runs-on: windows-latest 8 | steps: 9 | - uses: actions/checkout@v3 10 | 11 | - name: Install and cache PowerShell modules 12 | uses: potatoqualitee/psmodulecache@v5.2 13 | with: 14 | modules-to-cache: InvokeBuild, platyPS, BuildHelpers 15 | shell: powershell 16 | 17 | - name: Get Robocopy Version 18 | shell: powershell 19 | run: | 20 | Write-Host "Robocopy Version:" $(Get-Command Robocopy | Select-Object -ExpandProperty version).ToString() 21 | 22 | - name: Start Build script 23 | shell: powershell 24 | run: | 25 | .\build.ps1 26 | 27 | - name: Pester Tests 28 | shell: powershell 29 | run: | 30 | $res = Invoke-Pester -Path ".\Tests" -OutputFormat NUnitXml -OutputFile TestsResults.xml -PassThru 31 | if ($res.FailedCount -gt 0) { throw "$($res.FailedCount) tests failed."} else {"Tests passed."} -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | // 3 | // Custom Settings for Project 4 | // 5 | // These are here so that anyone potentially modifying the code base has the same editor experience, this ensures that the code will follow the same structure. 6 | 7 | // Controls how the editor should render whitespace characters, possibilities are 'none', 'boundary', and 'all'. The 'boundary' option does not render single spaces between words. 8 | "editor.renderWhitespace": "all", // Default: none 9 | 10 | // Controls whether the editor should render control characters 11 | "editor.renderControlCharacters": true, // Default: false 12 | 13 | // Number of spaces for tabs 14 | "editor.tabSize": 4, // Default: 4 15 | 16 | // Use spaces not tabs 17 | "editor.insertSpaces": true, // Default: true 18 | 19 | // When enabled, will trim trailing whitespace when you save a file. 20 | "files.trimTrailingWhitespace": true, // Default: false 21 | 22 | // Does not reformat one-line code blocks, such as "if (...) {...} else {...}". 23 | "powershell.codeFormatting.ignoreOneLineBlock": false, // Default: True 24 | 25 | // Adds a newline (line break) after a closing brace. 26 | "powershell.codeFormatting.newLineAfterCloseBrace": true, // Default: True 27 | 28 | // Adds a newline (line break) after an open brace. 29 | "powershell.codeFormatting.newLineAfterOpenBrace": true, // Default: True 30 | 31 | // Places open brace on the same line as its associated statement. 32 | "powershell.codeFormatting.openBraceOnSameLine": true, // Default: True 33 | 34 | // Adds a space after a separator (',' and ';'). 35 | "powershell.codeFormatting.whitespaceAfterSeparator": true, // Default: True 36 | 37 | // Adds spaces before and after an operator ('=', '+', '-', etc.). 38 | "powershell.codeFormatting.whitespaceAroundOperator": true, // Default: True 39 | 40 | // Adds a space between a keyword and its associated scriptblock expression. 41 | "powershell.codeFormatting.whitespaceBeforeOpenBrace": true, // Default: True 42 | 43 | // Adds a space between a keyword (if, elseif, while, switch, etc) and its associated conditional expression. 44 | "powershell.codeFormatting.whitespaceBeforeOpenParen": true, // Default: True 45 | 46 | // Align assignment statements in a hashtable or a DSC Configuration. 47 | "powershell.codeFormatting.alignPropertyValuePairs": true // Default: True 48 | } 49 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | // Available variables which can be used inside of strings. 2 | // ${workspaceRoot}: the root folder of the team 3 | // ${file}: the current opened file 4 | // ${relativeFile}: the current opened file relative to workspaceRoot 5 | // ${fileBasename}: the current opened file's basename 6 | // ${fileDirname}: the current opened file's dirname 7 | // ${fileExtname}: the current opened file's extension 8 | // ${cwd}: the current working directory of the spawned process 9 | { 10 | // See https://go.microsoft.com/fwlink/?LinkId=733558 11 | // for the documentation about the tasks.json format 12 | "version": "2.0.0", 13 | 14 | // Start PowerShell 15 | "windows": { 16 | "command": "${env:windir}\\sysnative\\WindowsPowerShell\\v1.0\\powershell.exe", 17 | "args": [ "-NoProfile", "-ExecutionPolicy", "Bypass" ] 18 | }, 19 | "linux": { 20 | "command": "/usr/bin/powershell", 21 | "args": [ "-NoProfile" ] 22 | }, 23 | "osx": { 24 | "command": "/usr/local/bin/powershell", 25 | "args": [ "-NoProfile" ] 26 | }, 27 | 28 | // Associate with test task runner 29 | "tasks": [ 30 | { 31 | "label": "Test", 32 | "type": "shell", 33 | "args": [ 34 | "Write-Host 'Invoking Pester'; Invoke-Pester -PesterOption @{IncludeVSCodeMarker=$true};", 35 | "Invoke-Command { Write-Host 'Completed Test task in task runner.' }" 36 | ], 37 | "problemMatcher": [ 38 | { 39 | "owner": "powershell", 40 | "fileLocation": [ 41 | "absolute" 42 | ], 43 | "severity": "error", 44 | "pattern": [ 45 | { 46 | "regexp": "^\\s*(\\[-\\]\\s*.*?)(\\d+)ms\\s*$", 47 | "message": 1 48 | }, 49 | { 50 | "regexp": "^\\s+at\\s+[^,]+,\\s*(.*?):\\s+line\\s+(\\d+)$", 51 | "file": 1, 52 | "line": 2 53 | } 54 | ] 55 | } 56 | ], 57 | "group": "test" 58 | } 59 | ] 60 | } -------------------------------------------------------------------------------- /.vscode/tasks.json.old: -------------------------------------------------------------------------------- 1 | // Available variables which can be used inside of strings. 2 | // ${workspaceRoot}: the root folder of the team 3 | // ${file}: the current opened file 4 | // ${relativeFile}: the current opened file relative to workspaceRoot 5 | // ${fileBasename}: the current opened file's basename 6 | // ${fileDirname}: the current opened file's dirname 7 | // ${fileExtname}: the current opened file's extension 8 | // ${cwd}: the current working directory of the spawned process 9 | { 10 | // See https://go.microsoft.com/fwlink/?LinkId=733558 11 | // for the documentation about the tasks.json format 12 | "version": "0.1.0", 13 | 14 | // Start PowerShell 15 | "windows": { 16 | "command": "${env:windir}\\sysnative\\WindowsPowerShell\\v1.0\\powershell.exe", 17 | "args": [ "-NoProfile", "-ExecutionPolicy", "Bypass" ] 18 | }, 19 | "linux": { 20 | "command": "/usr/bin/powershell", 21 | "args": [ "-NoProfile" ] 22 | }, 23 | "osx": { 24 | "command": "/usr/local/bin/powershell", 25 | "args": [ "-NoProfile" ] 26 | }, 27 | 28 | // The command is a shell script 29 | "isShellCommand": true, 30 | 31 | // Show the output window always 32 | "showOutput": "always", 33 | 34 | // Associate with test task runner 35 | "tasks": [ 36 | { 37 | "taskName": "Test", 38 | "suppressTaskName": true, 39 | "isTestCommand": true, 40 | "showOutput": "always", 41 | "args": [ 42 | "Write-Host 'Invoking Pester'; Invoke-Pester -PesterOption @{IncludeVSCodeMarker=$true};", 43 | "Invoke-Command { Write-Host 'Completed Test task in task runner.' }" 44 | ], 45 | "problemMatcher": [ 46 | { 47 | "owner": "powershell", 48 | "fileLocation": ["absolute"], 49 | "severity": "error", 50 | "pattern": [ 51 | { 52 | "regexp": "^\\s*(\\[-\\]\\s*.*?)(\\d+)ms\\s*$", 53 | "message": 1 54 | }, 55 | { 56 | "regexp": "^\\s+at\\s+[^,]+,\\s*(.*?):\\s+line\\s+(\\d+)$", 57 | "file": 1, 58 | "line": 2 59 | } 60 | ] 61 | } 62 | ] 63 | } 64 | ] 65 | } -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # RobocopyPS Release History 2 | 3 | ## 0.2.21 - 2023-08-18 4 | 5 | ### Fixed 6 | 7 | * Fixed how speed was not parsed correctly in Windows 11 8 | 9 | ## 0.2.20 - 2023-08-04 10 | 11 | ### Added 12 | 13 | * Added Sparse parameter for Robocopy 14 | 15 | ## 0.2.19 - 2023-07-14 16 | 17 | ### Fixed 18 | 19 | * Fixed a bug in how Robocopy output was parsed. Thanks [@WiredSharp](https://github.com/WiredSharp) 20 | 21 | ## 0.2.18 - 2023-02-26 22 | 23 | ### Fixed 24 | 25 | * Fixed a bug in PowerShell version 7.3, where a change was made to argument passing. Thanks [@fjollberg](https://github.com/fjollberg) 26 | 27 | ## 0.2.17 - 2022-07-15 28 | 29 | ### Added 30 | 31 | * Sync-RoboItem: New command for syncing (Robocopy.exe /MIR) folders 32 | * Added IoMaxSize, IoRate and Threshold parameters for Windows 11 33 | * Invoke-RoboCopy: Added parameter -OutputType to choose if you want to parse the output or not 34 | 35 | ## 0.2.15 - 2022-06-06 36 | 37 | ### Fixed 38 | 39 | * Fixed a bug where "EXTRA File" was not handled by Invoke-RobocopyParser 40 | * Fixed a bug where Robocopys native /v was not added correctly when using -Verbose 41 | * Fixed an bug where property Success not always was correct 42 | 43 | ### Changed 44 | 45 | * Moved "How RobocopyPS handle native Robocopy errors" to Wiki 46 | * Updated readme.md 47 | 48 | ### Removed 49 | 50 | * Removed [SUCCESS], [WARNING] and [ERROR] from property LastExitCodeMessage. This is done to not confuse end users. LastExitCodeMessage will still write information about that happended. 51 | 52 | ## 0.2.13 - 2022-05-26 53 | 54 | ### Added 55 | 56 | * Remove-RoboItem: Added Threads parameter 57 | * Added Precision parameter 58 | 59 | ### Fixed 60 | 61 | * Invoke-RobocopyParser.ps1: Changes to TotalTime for jobs running for a day or longer 62 | * Remove-RoboItem: Fixed bug where temporary folders where not deleted correctly 63 | * Remove-RoboItem: Fixed bug where function tried to remove the temporary instead of the specified folder 64 | * Fixed module auto import 65 | 66 | ### Changed 67 | * Copy-RoboItem: Removed ErrorAction Stop when calling Invoke-RoboCopy to let the end user handle errors 68 | 69 | ## 0.2.12 - 2022-02-06 70 | 71 | ### Added 72 | 73 | * Added Force parameter that will try and create the destination folder if it does not exist 74 | * Added TotalSizeBytes as a int64 75 | 76 | ### Fixed 77 | 78 | * Fixed problem when using Copy-RoboItem when specifying multiple paths 79 | 80 | ### Changed 81 | 82 | * Updated readme 83 | 84 | ## 0.2.8 - 2022-01-15 85 | 86 | ### Fixed 87 | 88 | * Fixed problem with escape character in PowerShell, for example paths with [ in them 89 | * Fixed problem when using Remove-RoboItem and Get-RoboItem when specifying multiple paths 90 | 91 | ## 0.2.7 - 2021-10-17 92 | 93 | ### Added 94 | 95 | * Added parameters ExcludeDirectory and ExcludeFileName to Get-RoboItem 96 | 97 | ### Changed 98 | 99 | * Fixed problem with parameters ExcludeDirectory and ExcludeFileName 100 | 101 | 102 | ## 0.2.6 - 2021-09-02 103 | 104 | ### Added 105 | 106 | * Added new cmdlets Get-RoboItem, Remove-RoboItem,Copy-RoboItem,Move-RoboItem. 107 | 108 | ### Changed 109 | 110 | * Removed all ParameterSetName in Invoke-Robocopy, including IncludeSubDirectories (/s) and IncludeEmptySubDirectories (/e) as they are not mutually exlusive. 111 | * Changed Pester Tests to match Version 5 of Pester. 112 | * Changed help file for Get-Help. 113 | * Changed how we validate source directories. 114 | 115 | ## 0.2.5 - 2021-08-12 116 | 117 | ### Added 118 | 119 | * Added parameters so the module is in phase with native Robocopy, tested on Windows 10 21H1 120 | 121 | ### Changed 122 | 123 | * Removed some of the forced parameters we use (example /v is not used if -Verbose is not specified) 124 | * Changed some tests to be compatible with Pester version 5 125 | * Changed documentation 126 | 127 | ### Removed 128 | 129 | * Removed some tests 130 | 131 | 132 | ## 0.2.2 - 2019-07-18 133 | 134 | ### Fixed 135 | 136 | * Fixed problem with parameter ExcludeFileName and ExcludeDirectory where you could not specify multiple files/directories. 137 | 138 | ### Added 139 | 140 | * Added functionality to Exclude/IncludeAttribute and Remove/AddAttribute 141 | 142 | 143 | ## 0.2.0 - 2019-07-16 144 | 145 | ### Changed 146 | 147 | * A re-write was done to be able to handle error code better and more precisely. Changes to the function names was also done, Start-Robocopy became Invoke-Robocopy and the internal logic handling output from Robocopy.exe was extracted to Invoke-RobocopyParser. 148 | 149 | * All other functions was removed during this release so they can be re-worked to follow the new standard. 150 | 151 | ## 0.1.0 - 2019-05-30 152 | 153 | ### Fixed 154 | 155 | * No fix as this is the first release 156 | 157 | ### Added 158 | 159 | * Added function Start-Robocopy 160 | * Added function Remove-RoboDirectory 161 | 162 | ### Changed 163 | 164 | * No change as this is first release -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # MIT License 2 | 3 | Copyright (c) Simon Bergwall 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RobocopyPS 2 | 3 | | Powershell Gallery | Dev branch | Main branch | 4 | |------------|-----|------| 5 | | ![](https://img.shields.io/powershellgallery/dt/robocopyPS) | ![Dev Branch](https://github.com/sbergwall/RobocopyPS/actions/workflows/tests.yml/badge.svg?branch=dev) | ![Main Branch](https://github.com/sbergwall/RobocopyPS/actions/workflows/tests.yml/badge.svg?branch=master) | 6 | 7 | 8 | ## Description 9 | 10 | RobocopyPS is a PowerShell module with the intention to be a wrapper for [Robocopy.exe](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/robocopy) and output Robocopys information to PowerShell streams (Verbose, Error etc). 11 | 12 | RobocopyPS only works if the language is set to en-US. This is because we look at each line of output from Robocopy and make a decision on what stream to use. If the language is not english we are not sure what to do. 13 | 14 | If we do not know what stream to output to we use the Information stream, so if you are missing output try and run with -InformationAction Continue 15 | 16 | You can use all Robocopys native parameters like -e, -mir etc but we try and translate them to easier parameter names as -Recurse and -Mirror instead. 17 | 18 | # Installation 19 | 20 | The easiest way to get RobocopyPS is using the [PowerShell Gallery](https://powershellgallery.com/packages/RobocopyPS/)! 21 | 22 | ``` PowerShell 23 | Install-Module -Name RobocopyPS 24 | ``` 25 | 26 | # Usage 27 | 28 | ## Invoke-Robocopy 29 | 30 | Invoke-RoboCopy is the core function used by RobocopyPS and will contain all parameters that can be used with Robocopy.exe. Most, if not all, other functions will call Invoke-RoboCopy. 31 | 32 | Copy all items from C:\tmp\from\ to C:\tmp\to\\. Include subdirectories that is empty and create a log file at C:\tmp\log.log 33 | ```` PowerShell 34 | Invoke-RoboCopy -Source C:\tmp\from\ -Destination C:\tmp\to\ -IncludeEmptySubDirectories -LogFile C:\tmp\log.log 35 | ```` 36 | 37 | Move all items from C:\tmp\from\ to C:\tmp\to\\. Note that this will remove C:\tmp\from\ when Robocopy is done 38 | ```` PowerShell 39 | Invoke-RoboCopy -Source C:\tmp\from\ -Destination C:\tmp\to\ -MoveFilesAndDirectories 40 | ```` 41 | 42 | # Other functions 43 | 44 | Other functions are usually using Invoke-Robocopy under the hood but exist for convenience for the user to easier understand what the specific function does. 45 | 46 | ## Copy-RoboItem 47 | 48 | Copy items from one directory to another, including empty subdirectories. Using -Force will create the destination folder if it does not exist. 49 | 50 | ```` PowerShell 51 | Copy-RoboItem -Source C:\tmp\from\ -Destination C:\tmp\to\ -IncludeEmptySubDirectories -Force 52 | ```` 53 | 54 | ## Get-RoboItem 55 | 56 | List information about a directory, including file count and total folder size, and using -Unit will show the size in bytes. 57 | 58 | ```` PowerShell 59 | Get-RoboItem -Path C:\tmp\from\ -Unit Bytes 60 | ```` 61 | 62 | ## Move-RoboItem 63 | 64 | Move D:\tmp\from to destination D:\tmp\to. 65 | 66 | ```` PowerShell 67 | Move-RoboItem -Source D:\tmp\from\ -Destination D:\tmp\to 68 | ```` 69 | 70 | ## Remove-RoboItem 71 | 72 | Remove multiple directories. 73 | 74 | ```` PowerShell 75 | Remove-RoboItem -Path "D:\dir1","D:\dir2" 76 | ```` 77 | 78 | # Release History 79 | 80 | A detailed release history is contained in the [Change Log](CHANGELOG.md). 81 | 82 | # License 83 | 84 | RobocopyPS is provided under the [MIT license](LICENSE.md). -------------------------------------------------------------------------------- /Robocopy.build.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Build script (https://github.com/nightroman/Invoke-Build) 4 | #> 5 | PARAM ( 6 | $VersionType = 'Patch', 7 | $m, 8 | $branch = 'dev' 9 | ) 10 | 11 | task UpdateHelp { 12 | "Import Module $PSScriptRoot\RobocopyPS" 13 | Import-Module $PSScriptRoot\RobocopyPS -Force 14 | Update-MarkdownHelpModule -Path $PSScriptRoot\docs 15 | New-ExternalHelp -Path $PSScriptRoot\docs -OutputPath .\RobocopyPS\en-US -Force 16 | } 17 | 18 | #region Task to run all Pester tests in folder .\tests 19 | task Test { 20 | $Result = Invoke-Pester .\tests -PassThru -Output Normal 21 | if ($Result.FailedCount -gt 0) { 22 | throw 'Pester tests failed' 23 | } 24 | } 25 | 26 | task TestComp { 27 | $result = Invoke-ScriptAnalyzer -Path .\RobocopyPS\* -Settings .\tests\CompabilitySettings.psd1 -Severity Warning 28 | If ($result.count -gt 0) { 29 | $result | Format-Table -AutoSize 30 | throw 'Invoke-ScriptAnalyzer tests failed' 31 | } 32 | } 33 | #endregion 34 | 35 | Task UpdateModuleVersion { 36 | Set-BuildEnvironment -Force 37 | 38 | [version]$version = Get-Metadata -Path $env:BHPSModuleManifest -PropertyName 'ModuleVersion' 39 | $NewVersion = [version] (Step-Version -Version $version -Type $VersionType) 40 | 41 | " Setting version [$NewVersion]" 42 | Update-Metadata -Path $env:BHPSModuleManifest -PropertyName 'ModuleVersion' -Value $NewVersion 43 | 44 | (Get-Content -Path $env:BHPSModuleManifest -Raw -Encoding UTF8) | 45 | ForEach-Object { $_.TrimEnd() } | 46 | Set-Content -Path $env:BHPSModuleManifest -Encoding UTF8 47 | } 48 | 49 | Task push UpdateHelp, Test, TestComp,{ 50 | git add . 51 | git commit -a -m $m 52 | git push origin $branch 53 | } -------------------------------------------------------------------------------- /RobocopyPS/RobocopyPS.psd1: -------------------------------------------------------------------------------- 1 | # 2 | # Module manifest for module 'RobocopyPS' 3 | # 4 | # Generated by: Simon Bergwall 5 | # 6 | # Generated on: 2019-04-07 7 | # 8 | 9 | @{ 10 | 11 | # Script module or binary module file associated with this manifest. 12 | RootModule = 'RobocopyPS.psm1' 13 | 14 | # Version number of this module. 15 | ModuleVersion = '0.2.21' 16 | 17 | # Supported PSEditions 18 | # CompatiblePSEditions = @() 19 | 20 | # ID used to uniquely identify this module 21 | GUID = 'ac3476a0-362c-4e8f-9112-3519a87b00e9' 22 | 23 | # Author of this module 24 | Author = 'Simon Bergwall' 25 | 26 | # Company or vendor of this module 27 | CompanyName = 'Simon Bergwall' 28 | 29 | # Copyright statement for this module 30 | Copyright = '(c) 2019 Simon Bergwall. All rights reserved.' 31 | 32 | # Description of the functionality provided by this module 33 | Description = 'Wrapper for Robocopy' 34 | 35 | # Minimum version of the Windows PowerShell engine required by this module 36 | PowerShellVersion = '5.0' 37 | 38 | # Name of the Windows PowerShell host required by this module 39 | # PowerShellHostName = '' 40 | 41 | # Minimum version of the Windows PowerShell host required by this module 42 | # PowerShellHostVersion = '' 43 | 44 | # Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. 45 | # DotNetFrameworkVersion = '' 46 | 47 | # Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. 48 | # CLRVersion = '' 49 | 50 | # Processor architecture (None, X86, Amd64) required by this module 51 | # ProcessorArchitecture = '' 52 | 53 | # Modules that must be imported into the global environment prior to importing this module 54 | # RequiredModules = @() 55 | 56 | # Assemblies that must be loaded prior to importing this module 57 | # RequiredAssemblies = @() 58 | 59 | # Script files (.ps1) that are run in the caller's environment prior to importing this module. 60 | # ScriptsToProcess = @() 61 | 62 | # Type files (.ps1xml) to be loaded when importing this module 63 | # TypesToProcess = @() 64 | 65 | # Format files (.ps1xml) to be loaded when importing this module 66 | #FormatsToProcess = 'RobocopyPS.Format.ps1xml' 67 | 68 | # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess 69 | # NestedModules = @() 70 | 71 | # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. 72 | FunctionsToExport = @( 73 | 'Get-RoboItem', 74 | 'Remove-RoboItem', 75 | 'Invoke-RoboCopy', 76 | 'Move-RoboItem', 77 | 'Copy-RoboItem', 78 | 'Sync-RoboItem' 79 | ) 80 | 81 | # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. 82 | #CmdletsToExport = '*' 83 | 84 | # Variables to export from this module 85 | #VariablesToExport = '*' 86 | 87 | # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. 88 | #AliasesToExport = '*' 89 | 90 | # DSC resources to export from this module 91 | # DscResourcesToExport = @() 92 | 93 | # List of all modules packaged with this module 94 | # ModuleList = @() 95 | 96 | # List of all files packaged with this module 97 | # FileList = @() 98 | 99 | # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. 100 | PrivateData = @{ 101 | 102 | PSData = @{ 103 | 104 | # Tags applied to this module. These help with module discovery in online galleries. 105 | Tags = @('Robocopy') 106 | 107 | # A URL to the license for this module. 108 | LicenseUri = 'https://github.com/sbergwall/RobocopyPS/blob/master/LICENSE.md' 109 | 110 | # A URL to the main website for this project. 111 | ProjectUri = 'https://github.com/sbergwall/RobocopyPS' 112 | 113 | # A URL to an icon representing this module. 114 | # IconUri = '' 115 | 116 | # ReleaseNotes of this module 117 | ReleaseNotes = 'https://github.com/sbergwall/RobocopyPS/blob/master/CHANGELOG.md' 118 | 119 | } # End of PSData hashtable 120 | 121 | } # End of PrivateData hashtable 122 | 123 | # HelpInfo URI of this module 124 | # HelpInfoURI = '' 125 | 126 | # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. 127 | # DefaultCommandPrefix = '' 128 | 129 | } 130 | -------------------------------------------------------------------------------- /RobocopyPS/RobocopyPS.psm1: -------------------------------------------------------------------------------- 1 | # Taken from http://overpoweredshell.com/Working-with-Plaster/ 2 | 3 | $functionFolders = @('functions', 'internal', 'classes') 4 | ForEach ($folder in $functionFolders) 5 | { 6 | $folderPath = Join-Path -Path $PSScriptRoot -ChildPath $folder 7 | If (Test-Path -Path $folderPath) 8 | { 9 | Write-Verbose -Message "Importing from $folder" 10 | $functions = Get-ChildItem -Path $folderPath -Filter '*.ps1' 11 | ForEach ($function in $functions) 12 | { 13 | Write-Verbose -Message " Importing $($function.BaseName)" 14 | . $function.FullName 15 | } 16 | } 17 | } 18 | $publicFunctions = (Get-ChildItem -Path "$PSScriptRoot\functions" -Filter '*.ps1').BaseName 19 | Export-ModuleMember -Function $publicFunctions -------------------------------------------------------------------------------- /RobocopyPS/functions/Copy-RoboItem.ps1: -------------------------------------------------------------------------------- 1 | function Copy-RoboItem { 2 | [CmdletBinding(SupportsShouldProcess = $True)] 3 | param ( 4 | # Specifies the path to the source directory. Must be a folder. 5 | [Parameter( Mandatory = $True, 6 | ValueFromPipelineByPropertyName, 7 | ValueFromPipeline)] 8 | [Alias('Path', 'FullPath')] 9 | [String[]]$Source 10 | ) 11 | 12 | DynamicParam { 13 | # Get available parameters from Invoke-RoboCopy and ignore parameters that is not for moving items 14 | New-ProxyFunction -CommandName 'Invoke-RoboCopy' -CommandType 'Function' -ignoredParams "Source", "Purge", "Mirror", "MoveFiles", "MoveFilesAndDirectories" 15 | } 16 | 17 | 18 | begin { 19 | 20 | } 21 | 22 | process { 23 | $Destination = $PSBoundParameters['Destination'] 24 | foreach ($Dir in $Source) { 25 | If ($PSCmdlet.ShouldProcess("$Destination from $Dir" , "Copy")) { 26 | try { 27 | $PSBoundParameters.Set_Item('Source', $dir) 28 | Invoke-RoboCopy @PSBoundParameters 29 | } 30 | catch { 31 | $PSCmdlet.WriteError($PSitem) 32 | } 33 | } 34 | } 35 | } 36 | 37 | end { 38 | 39 | } 40 | } -------------------------------------------------------------------------------- /RobocopyPS/functions/Get-RoboItem.ps1: -------------------------------------------------------------------------------- 1 | Function Get-RoboItem { 2 | [CmdletBinding(SupportsShouldProcess = $True)] 3 | 4 | PARAM ( 5 | # Path to directory 6 | [Parameter( Mandatory = $True, 7 | ValueFromPipelineByPropertyName, 8 | ValueFromPipeline)] 9 | [Alias('FullPath')] 10 | [String[]]$Path, 11 | 12 | # Specifies the file or files. You can use wildcard characters (* or ?), if you want. If the File parameter is not specified, *.* is used as the default value. 13 | [String[]]$Files = '*.*', 14 | 15 | # Includes subdirectories and files. 16 | [Switch]$Recurse, 17 | 18 | # Get only the top N levels of the source directory tree. 19 | [Parameter(Mandatory = $False)] 20 | [Alias('lev', 'Depth')] 21 | [Int]$Level, 22 | 23 | # Get files in restartable mode. 24 | [Alias('z')] 25 | [switch]$RestartMode, 26 | 27 | # Get files in Backup mode. 28 | [Alias('b')] 29 | [switch]$BackupMode, 30 | 31 | # Get files in restartable mode. If file access is denied, switches to backup mode. 32 | [Alias('zb')] 33 | [switch]$RestartAndBackupMode, 34 | 35 | # Excludes files that match the specified names or paths. Note that FileName can include wildcard characters (* and ?). 36 | [Parameter(Mandatory = $False)] 37 | [Alias('xf')] 38 | [String[]]$ExcludeFileName, 39 | 40 | # Excludes directories that match the specified names and paths. 41 | [Parameter(Mandatory = $False)] 42 | [Alias('xd')] 43 | [String[]]$ExcludeDirectory, 44 | 45 | # Creates multi-threaded copies with N threads. N must be an integer between 1 and 128. Cannot be used with the InterPacketGap and EFSRAW parameters. The /MT parameter applies to Windows Server 2008 R2 and Windows 7. 46 | [Parameter(Mandatory = $False)] 47 | [ValidateRange(1, 128)] 48 | [Alias('MT', 'MultiThread')] 49 | [int]$Threads, 50 | 51 | # What unit the sizes are shown as 52 | [ValidateSet('Auto', 'PB', 'TB', 'GB', 'MB', 'KB', 'Bytes')] 53 | [String]$Unit = 'Auto', 54 | 55 | [System.Int64]$Precision = 4 56 | ) 57 | 58 | Begin { 59 | } 60 | 61 | Process { 62 | foreach ($Location in $Path) { 63 | If ($PSCmdlet.ShouldProcess("$location" , 'Get')) { 64 | try { 65 | $PSBoundParameters.Set_Item('Path', $location) 66 | Invoke-RoboCopy -Destination NULL -List -ErrorAction Stop @PSBoundParameters 67 | } 68 | catch { 69 | $PSCmdlet.WriteError($PSitem) 70 | } 71 | } 72 | } 73 | } 74 | 75 | End { 76 | } 77 | } -------------------------------------------------------------------------------- /RobocopyPS/functions/Invoke-RoboCopy.ps1: -------------------------------------------------------------------------------- 1 | Function Invoke-RoboCopy { 2 | <# 3 | .SYNOPSIS 4 | Invoke Robocopy with PowerShell 5 | 6 | .DESCRIPTION 7 | See https://technet.microsoft.com/en-us/library/cc733145(v=ws.11).aspx for an extensive documentation on Robocopy switches. 8 | Some parameters are in use by the function: /bytes /TEE /np /njh /fp /ndl /ts. 9 | 10 | .PARAMETER Confirm 11 | Prompts you for confirmation before running the function. 12 | 13 | .PARAMETER WhatIf 14 | Shows what would happen if the function runs. The function is not run. 15 | 16 | .EXAMPLE 17 | Copy with Recurse 18 | 19 | Invoke-RoboCopy -Source "E:\Google Drive\Script Library" -Destination G:\Temp\ -Recurse -Unit Bytes 20 | 21 | Source : E:\Google Drive\Script Library 22 | Destination : G:\Temp\ 23 | Command : Robocopy.exe "E:\Google Drive\Script Library" "G:\Temp" *.* /r:3 /w:3 /e /bytes /TEE /np /njh /fp /ndl /ts 24 | DirCount : 589 25 | FileCount : 1220 26 | DirCopied : 588 27 | FileCopied : 1220 28 | DirIgnored : 1 29 | FileIgnored : 0 30 | DirMismatched : 0 31 | FileMismatched : 0 32 | DirFailed : 0 33 | FileFailed : 0 34 | DirExtra : 0 35 | FileExtra : 1 36 | TotalTime : 00:00:02 37 | StartedTime : 7/16/2019 10:03:28 PM 38 | EndedTime : 7/16/2019 10:03:30 PM 39 | TotalSize : 18839977 B 40 | TotalSizeCopied : 18839977 B 41 | TotalSizeIgnored : 0 B 42 | TotalSizeMismatched : 0 B 43 | TotalSizeFailed : 0 B 44 | TotalSizeExtra : 557048280 B 45 | Speed : 12957343 B/s 46 | ExitCode : 3 47 | Success : True 48 | LastExitCodeMessage : [SUCCESS]Some files were copied. Additional files were present. No failure was encountered. 49 | 50 | .EXAMPLE 51 | This will only list all your files to verbose and output information. No copy, delete or mirror will be done. 52 | 53 | Invoke-RoboCopy -Source "C:\Users\Simon\Downloads\" -Destination NULL -List -Recurse -Verbose 54 | 55 | VERBOSE: Performing the operation "List" on target "NULL from C:\Users\Simon\Downloads\". 56 | VERBOSE: "List File" on "Item C:\Users\Simon\Downloads\desktop.ini" to target "NULL" Status on Item "New File". Length on Item "282". TimeStamp on Item "6/22/2019 2:28:00 PM" 57 | VERBOSE: "List File" on "Item C:\Users\Simon\Downloads\SteamSetup.exe" to target "NULL" Status on Item "New File". Length on Item "1573568". TimeStamp on Item "6/27/2019 9:20:02 AM" 58 | VERBOSE: "List File" on "Item C:\Users\Simon\Downloads\VeeamBackup&Replication_9.5.4.2753.Update4a.iso" to target "NULL" Status on Item "New File". Length on Item "5208592384". TimeStamp on Item 59 | "7/11/2019 8:54:34 PM" 60 | VERBOSE: "List File" on "Item C:\Users\Simon\Downloads\Windows10Upgrade9252.exe" to target "NULL" Status on Item "New File". Length on Item "6254480". TimeStamp on Item "6/22/2019 11:15:55 AM" 61 | 62 | 63 | Source : C:\Users\Simon\Downloads\ 64 | Destination : NULL 65 | Command : Robocopy.exe "C:\Users\Simon\Downloads" "NULL" *.* /r:3 /w:3 /e /l /bytes /TEE /np /njh /fp /v /ndl /ts 66 | DirCount : 1 67 | FileCount : 4 68 | DirCopied : 1 69 | FileCopied : 4 70 | DirIgnored : 0 71 | FileIgnored : 0 72 | DirMismatched : 0 73 | FileMismatched : 0 74 | DirFailed : 0 75 | FileFailed : 0 76 | DirExtra : 0 77 | FileExtra : 0 78 | TotalTime : 00:00:00 79 | StartedTime : 7/16/2019 10:16:39 PM 80 | EndedTime : 7/16/2019 10:16:39 PM 81 | TotalSize : 4.9 GB 82 | TotalSizeCopied : 4.9 GB 83 | TotalSizeIgnored : 0 B 84 | TotalSizeMismatched : 0 B 85 | TotalSizeFailed : 0 B 86 | TotalSizeExtra : 0 B 87 | Speed : 0 B/s 88 | ExitCode : 1 89 | Success : True 90 | LastExitCodeMessage : [SUCCESS]All files were copied successfully. 91 | 92 | .EXAMPLE 93 | Invoke-RoboCopy -Source C:\temp\from -Destination C:\temp\to -Mirror -SaveJob C:\temp\job 94 | 95 | .NOTES 96 | Original script by Keith S. Garner (KeithGa@KeithGa.com) - 6/23/2014 97 | Originally posted on https://keithga.wordpress.com/2014/06/23/copy-itemwithprogress 98 | 99 | With inspiration by Trevor Sullivan @pcgeek86 100 | https://stackoverflow.com/a/21209726 101 | 102 | Updated by Ninjigen - 01/08/2018 103 | https://github.com/Ninjigen/PowerShell/tree/master/Robocopy 104 | #> 105 | 106 | 107 | [CmdletBinding(SupportsShouldProcess)] 108 | 109 | Param ( 110 | 111 | # Specifies the path to the source directory. Must be a folder. 112 | [Parameter( Mandatory = $True, 113 | ValueFromPipelineByPropertyName, 114 | ValueFromPipeline)] 115 | [Alias('Path', 'FullPath')] 116 | [String]$Source, 117 | 118 | # Specifies the path to the destination directory. Must be a folder. 119 | [Parameter( Mandatory = $True, 120 | ValueFromPipelineByPropertyName, 121 | ValueFromPipeline)] 122 | [Alias('Target')] 123 | [String]$Destination, 124 | 125 | # Specifies the file or files to be copied. You can use wildcard characters (* or ?), if you want. If the File parameter is not specified, *.* is used as the default value. 126 | [Parameter(Mandatory = $False)] 127 | [Alias('File')] 128 | [String[]] $Files = '*.*', 129 | 130 | # If destination folder does not exist the Force parameter will try and create it. 131 | [Parameter(Mandatory = $False)] 132 | [switch] $Force, 133 | 134 | #region Copy Options 135 | <#Copy options: https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/robocopy#copy-options#> 136 | 137 | # Copies subdirectories. Note that this option excludes empty directories. 138 | [Alias('s')] 139 | [switch]$IncludeSubDirectories, 140 | 141 | # Copies subdirectories. Note that this option includes empty directories. 142 | [Alias('e', 'Recurse')] 143 | [switch]$IncludeEmptySubDirectories, 144 | 145 | # Copies only the top N levels of the source directory tree. 146 | [Parameter(Mandatory = $False)] 147 | [Alias('lev', 'Depth')] 148 | [Int]$Level, 149 | 150 | # Copies files in restartable mode. 151 | [Alias('z')] 152 | [switch]$RestartMode, 153 | 154 | # Copies files in Backup mode. 155 | [Alias('b')] 156 | [switch]$BackupMode, 157 | 158 | # Copies files in restartable mode. If file access is denied, switches to backup mode. 159 | [Alias('zb')] 160 | [switch]$RestartAndBackupMode, 161 | 162 | # Copies using unbuffered I/O (recommended for large files). 163 | [Alias('j')] 164 | [Switch]$UnbufferedIO, 165 | 166 | # Copies all encrypted files in EFS RAW mode. 167 | [switch]$EFSRaw, 168 | 169 | # Specifies the file properties to be copied. The default value for CopyFlags is DAT (data, attributes, and time stamps). D = Data. A = Attributes. T = Time stamps.S = NTFS access control list (ACL). O =Owner information. U = Auditing information 170 | [Parameter(Mandatory = $False)] 171 | [Alias('copy')] 172 | [ValidateSet('D', 'A', 'T', 'S', 'O', 'U')] 173 | [String[]]$CopyFlags, 174 | 175 | # Specifies what to copy in directories. The valid values for this option are:D - Data, A - Attributes, T - Time stamps. The default value for this option is DA (data and attributes). 176 | [Parameter(Mandatory = $False)] 177 | [Alias('dcopy')] 178 | [ValidateSet('D', 'A', 'T')] 179 | [String[]]$DirectoryCopyFlags, 180 | 181 | # Copies files with security (equivalent to /copy:DATS). 182 | [Alias('sec')] 183 | [switch]$CopyWithSecurity, 184 | 185 | # Copies all file information (equivalent to /copy:DATSOU). 186 | [Alias('copyall')] 187 | [switch]$CopyAllFileInformation, 188 | 189 | # Copies no file information. 190 | [switch]$NoCopy, 191 | 192 | # Fixes file security on all files, even skipped ones. 193 | [Alias('secfix')] 194 | [switch]$SecurityFix, 195 | 196 | # Fixes file times on all files, even skipped ones. 197 | [Alias('timfix')] 198 | [switch]$Timefix, 199 | 200 | # Deletes destination files and directories that no longer exist in the source. 201 | [switch]$Purge, 202 | 203 | # Mirrors a directory tree 204 | [Alias('mir', 'Sync')] 205 | [switch]$Mirror, 206 | 207 | # Moves files, recursively, and deletes them from the source after they are copied. Folders will still be in source directory. 208 | [Alias('mov')] 209 | [switch]$MoveFiles, 210 | 211 | # Moves files and directories, and deletes them from the source after they are copied. 212 | [Alias('move')] 213 | [switch]$MoveFilesAndDirectories, 214 | 215 | # Adds the specified attributes to copied files. 216 | [Parameter(Mandatory = $False)] 217 | [ValidateSet('R', 'A', 'S', 'H', 'C', 'N', 'E', 'T')] 218 | [String[]]$AddAttribute, 219 | 220 | # Removes the specified attributes from copied files. 221 | [Parameter(Mandatory = $False)] 222 | [ValidateSet('R', 'A', 'S', 'H', 'C', 'N', 'E', 'T')] 223 | [String[]]$RemoveAttribute, 224 | 225 | # Creates a directory tree and zero-length files only. 226 | [switch]$Create, 227 | 228 | # Creates destination files by using 8.3 character-length FAT file names only. 229 | [switch]$FAT, 230 | 231 | # Turns off support for very long paths. 232 | [Alias('256')] 233 | [switch]$IgnoreLongPath, 234 | 235 | # Monitors the source, and runs again when more than N changes are detected. 236 | [Parameter(Mandatory = $False)] 237 | [Alias('mon')] 238 | [Int]$MonitorChanges, 239 | 240 | # Monitors source, and runs again in M minutes if changes are detected. 241 | [Parameter(Mandatory = $False)] 242 | [Alias('mot')] 243 | [Int]$MonitorMinutes, 244 | 245 | #Default value is 8. Value must be at least 1 and not greater than 128. This option is incompatible with the /IPG and /EFSRAW options. Redirect output using /LOG option for better performance. 246 | [Parameter(Mandatory = $False)] 247 | [ValidateRange(1, 128)] 248 | [Alias('MT', 'MultiThread')] 249 | [int]$Threads = 8, 250 | 251 | # Specifies run times when new copies may be started. 252 | [Parameter(Mandatory = $False)] 253 | [Alias('rh')] 254 | [ValidatePattern('[0-2]{1}[0-3]{1}[0-5]{1}[0-9]{1}-[0-2]{1}[0-3]{1}[0-5]{1}[0-9]{1}')] 255 | [String]$RunTimes, 256 | 257 | # Checks run times on a per-file (not per-pass) basis. 258 | [Alias('pf')] 259 | [switch]$UsePerFileRunTimes, 260 | 261 | # Specifies the inter-packet gap to free bandwidth on slow lines. 262 | [Parameter(Mandatory = $False)] 263 | [Alias('ipg')] 264 | [Int]$InterPacketGap, 265 | 266 | # Copy Junctions as junctions instead of as the junction targets. 267 | [Alias('sj')] 268 | [switch]$CopyJunction, 269 | 270 | # Copy Symbolic Links as links instead of as the link targets. 271 | [Alias('sl')] 272 | [switch]$SymbolicLink, 273 | 274 | # Copies no directory info (the default /dcopy:DA is done). 275 | [Alias('nodcopy')] 276 | [switch]$NoDirectoryInformation, 277 | 278 | # Copies files without using the Windows Copy Offload mechanism. 279 | [Switch]$NoOffload, 280 | 281 | # Requests network compression during file transfer, if applicable. 282 | [Switch]$Compress, 283 | #endregion 284 | 285 | # Enable retaining sparse state during copy. 286 | [Switch]$Sparse, 287 | #endregion 288 | 289 | #region Copy File Throttling Options 290 | [ValidatePattern('[0-9]{1,}[K]|[0-9]{1,}[M]|[0-9]{1,}[G]')] 291 | [String]$IoMaxSize, 292 | 293 | [ValidatePattern('[0-9]{1,}[K]|[0-9]{1,}[M]|[0-9]{1,}[G]')] 294 | [String]$IoRate, 295 | 296 | [ValidatePattern('[0-9]{1,}[K]|[0-9]{1,}[M]|[0-9]{1,}[G]')] 297 | [String]$Threshold, 298 | #endregion 299 | 300 | #region File Selection Options 301 | <# File selection options: https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/robocopy#file-selection-options #> 302 | 303 | # Copies only files for which the Archive attribute is set. 304 | [Alias('a')] 305 | [switch]$Archive, 306 | 307 | # Copies only files for which the Archive attribute is set, and resets the Archive attribute. 308 | [Alias('m')] 309 | [switch]$ResetArchiveAttribute, 310 | 311 | # Includes only files for which any of the specified attributes are set. 312 | [Parameter(Mandatory = $False)] 313 | [Alias('ia')] 314 | [ValidateSet('R', 'A', 'S', 'C' , 'H', 'N', 'E', 'T', 'O')] 315 | [String[]]$IncludeAttribute, 316 | 317 | # Excludes files for which any of the specified attributes are set. 318 | [Parameter(Mandatory = $False)] 319 | [ValidateSet('R', 'A', 'S', 'C' , 'H', 'N', 'E', 'T', 'O')] 320 | [Alias('xa')] 321 | [String[]]$ExcludeAttribute, 322 | 323 | # Excludes files that match the specified names or paths. Note that FileName can include wildcard characters (* and ?). 324 | [Parameter(Mandatory = $False)] 325 | [Alias('xf')] 326 | [String[]]$ExcludeFileName, 327 | 328 | # Excludes directories that match the specified names and paths. 329 | [Parameter(Mandatory = $False)] 330 | [Alias('xd')] 331 | [String[]]$ExcludeDirectory, 332 | 333 | # Excludes changed files. 334 | [Alias('xc')] 335 | [switch]$ExcludeChangedFiles, 336 | 337 | # Excludes newer files. 338 | [Alias('xn')] 339 | [switch]$ExcludeNewerFiles, 340 | 341 | # Excludes older files. 342 | [Alias('xo')] 343 | [switch]$ExcludeOlderFiles, 344 | 345 | # Excludes extra files and directories. 346 | [Alias('xx')] 347 | [switch]$ExcludeExtraFiles, 348 | 349 | # Excludes "lonely" files and directories. 350 | [Alias('xl')] 351 | [switch]$ExcludeLonelyFiles, 352 | 353 | # Include modified files (differing change times). 354 | [Alias('im')] 355 | [switch]$IncludeModifiedFile, 356 | 357 | # Includes the same files. 358 | [Alias('is')] 359 | [switch]$IncludeSameFiles, 360 | 361 | # Includes "tweaked" files. 362 | [Alias('it')] 363 | [switch]$IncludeTweakedFiles, 364 | 365 | # Specifies the maximum file size (to exclude files bigger than N bytes). 366 | [Parameter(Mandatory = $False)] 367 | [Alias('max')] 368 | [String]$MaximumFileSize, 369 | 370 | # Specifies the minimum file size (to exclude files smaller than N bytes). 371 | [Parameter(Mandatory = $False)] 372 | [Alias('min')] 373 | [String]$MinimumFileSize, 374 | 375 | # Specifies the maximum file age (to exclude files older than N days or date). 376 | [Parameter(Mandatory = $False)] 377 | [Alias('maxage')] 378 | [String]$MaximumFileAge, 379 | 380 | # Specifies the minimum file age (exclude files newer than N days or date). 381 | [Parameter(Mandatory = $False)] 382 | [Alias('minage')] 383 | [String]$MinimumFileAge, 384 | 385 | # Specifies the maximum last access date (excludes files unused since N). 386 | [Parameter(Mandatory = $False)] 387 | [Alias('maxlad')] 388 | [String]$MaximumFileLastAccessDate, 389 | 390 | # Specifies the minimum last access date (excludes files used since N) If N is less than 1900, N specifies the number of days. Otherwise, N specifies a date in the format YYYYMMDD. 391 | [Parameter(Mandatory = $False)] 392 | [Alias('minlad')] 393 | [String]$MinimumFileLastAccessDate, 394 | 395 | # Excludes junction points, which are normally included by default. 396 | [Alias('xj')] 397 | [switch]$ExcludeJunctionPoints, 398 | 399 | # Assumes FAT file times (two-second precision). 400 | [Alias('fft')] 401 | [switch]$AssumeFATFileTime, 402 | 403 | # Compensates for one-hour DST time differences. 404 | [Alias('dst')] 405 | [switch]$CompensateDST, 406 | 407 | # Excludes junction points for directories. 408 | [Alias('xjd')] 409 | [switch]$ExcludeDirectoryJunctionPoints, 410 | 411 | # Excludes junction points for files. 412 | [Alias('xjf')] 413 | [switch]$ExcludeFileJunctionPoints, 414 | #endregion 415 | 416 | #region Retry Options 417 | <#Retry Options#> 418 | 419 | # Specifies the number of retries on failed copies. Default is 3. 420 | [Alias('r')] 421 | [int]$Retry = 3, 422 | 423 | # Specifies the wait time between retries, in seconds. The default value of N is 3. 424 | [Alias('w')] 425 | [int]$Wait = 3, 426 | 427 | # Saves the values specified in the /r and /w options as default settings in the registry. 428 | [Alias('reg')] 429 | [switch]$SaveRetrySettings, 430 | 431 | # Specifies that the system will wait for share names to be defined (retry error 67). 432 | [Alias('tbd')] 433 | [switch]$WaitForShareName, 434 | 435 | # Using /LFSM requests robocopy to operate in 'low free space mode'. In that mode, robocopy will pause whenever a file copy would cause the destination volume's free space to go below ten percent of the destination volume's size. 436 | [Alias('lfsm')] 437 | [switch]$LowFreeSpaceMode, 438 | 439 | # Using /LFSM requests robocopy to operate in 'low free space mode'. In that mode, robocopy will pause whenever a file copy would cause the destination volume's free space to go below a 'floor' value, which can be explicitly specified by the n[KMG] form of the flag where n=number and K:kilobytes ,M:megabytes or G:gigabytes. 440 | [ValidatePattern('[0-9]{1,}[K]|[0-9]{1,}[M]|[0-9]{1,}[G]')] 441 | [String]$LowFreeSpaceModeValue, 442 | #endregion 443 | 444 | #region Logging 445 | <# Logging #> 446 | 447 | # Specifies that files are to be listed only (and not copied, deleted, or time stamped). 448 | [Alias('l')] 449 | [Switch]$List, 450 | 451 | # Report all eXtra files, not just those selected & copied. 452 | [Alias('x')] 453 | [Switch]$ReportExtraFile, 454 | 455 | # Specifies that file sizes are not to be logged. 456 | [Alias('ns')] 457 | [switch]$NoSizeToLog, 458 | 459 | # Specifies that file sizes are not to be logged. 460 | [Alias('nc')] 461 | [switch]$NoClassToLog, 462 | 463 | # Specifies that file names are not to be logged. 464 | [Alias('nfl')] 465 | $NoFileNameToLog, 466 | 467 | # Writes the status output to the log file (overwrites the existing log file). 468 | [Alias('log')] 469 | [Parameter(Mandatory = $False)] 470 | [String]$LogFile, 471 | 472 | # Writes the status output to the log file (appends the output to the existing log file). 473 | [Parameter(Mandatory = $False)] 474 | [String]$LogFileWithAppend, 475 | 476 | # Displays the status output as Unicode text. 477 | [switch]$Unicode, 478 | 479 | # Writes the status output to the log file as Unicode text (overwrites the existing log file). 480 | [Alias('unilog')] 481 | [string]$UnicodeLog, 482 | 483 | # Writes the status output to the log file as Unicode text (appends the output to the existing log file). 484 | [string]$UnicodeLogWithAppend, 485 | #endregion 486 | 487 | #region Job options 488 | <#Job options#> 489 | 490 | # Specifies that parameters are to be derived from the named job file. 491 | [Alias('Job')] 492 | [string]$JobName, 493 | 494 | # Specifies that parameters are to be saved to the named job file. 495 | [Alias('Save')] 496 | [string]$SaveJob, 497 | 498 | # Quits after processing command line to view parameters. 499 | [switch]$Quit, 500 | 501 | # NO Source Directory is specified. 502 | [Alias('NOSD')] 503 | [switch]$NoSourceDirectory, 504 | 505 | # NO Destination Directory is specified. 506 | [Alias('NODD')] 507 | [switch]$NoDestinationDirectory, 508 | 509 | # Include the following Files. 510 | [Alias('IF')] 511 | [string]$IncludeFollowingFile, 512 | #endregion 513 | 514 | #Region Other 515 | <# Other #> 516 | 517 | # What unit the sizes are shown as 518 | [ValidateSet('Auto', 'PB', 'TB', 'GB', 'MB', 'KB', 'Bytes')] 519 | [String]$Unit = 'Auto', 520 | 521 | [ValidateRange(1, 28)] 522 | [System.Int64]$Precision = 4, 523 | 524 | [ValidateSet('Native', 'Parse')] 525 | $OutputType = 'Parse' 526 | #endregion 527 | ) 528 | 529 | Process { 530 | # Handle different types of paths, like C:\tmp\[] and 'C:\tmp\`[`]\' (note the escape characters, Powershell usually do this when using tab to find your folder) 531 | try { 532 | # Try literalpath, if it doesnt exist we will try with -Path 533 | $Source = (Get-Item -LiteralPath $Source -ErrorAction Stop).FullName 534 | } 535 | Catch [System.Management.Automation.ItemNotFoundException] { 536 | $Source = (Get-Item -Path $Source -ErrorAction Stop).FullName 537 | } 538 | Catch { 539 | $PSCmdlet.WriteError($PSitem) 540 | } 541 | 542 | # See if $destination is NULL because its used by other cmdlets 543 | If ($Destination -eq 'NULL') { 544 | } 545 | 546 | # If Force is true we want to create the destination folder even if it doesnt exist 547 | elseif ($Force -eq $True -and $null -eq $WhatIf) { 548 | try { 549 | If (Test-Path $Destination) { 550 | Write-Verbose "$Destination already exist" 551 | } 552 | else { 553 | New-Item -Path $Destination -ItemType Directory -ErrorAction Stop | Out-Null 554 | } 555 | } 556 | catch { 557 | $PSCmdlet.WriteError($PSitem) 558 | } 559 | } 560 | 561 | else { 562 | try { 563 | # Try literalpath, if it doesnt exist we will try with -Path 564 | $Destination = (Get-Item -LiteralPath $Destination -ErrorAction Stop).FullName 565 | } 566 | Catch [System.Management.Automation.ItemNotFoundException] { 567 | $Destination = (Get-Item -Path $Destination -ErrorAction Stop).FullName 568 | } 569 | Catch { 570 | $PSCmdlet.WriteError($PSitem) 571 | } 572 | } 573 | 574 | # Remove trailing backslash because Robocopy can sometimes error out when spaces are in path names 575 | $ModifiedSource = $Source -replace '\\$' 576 | $ModifiedDestination = $Destination -replace '\\$' 577 | 578 | # We place "" so we can use spaces in path names 579 | $ModifiedSource = '"' + $ModifiedSource + '"' 580 | $ModifiedDestination = '"' + $ModifiedDestination + '"' 581 | 582 | # RobocopyArguments are not the final variable that countain all robocopy parameters 583 | $RobocopyArguments = $ModifiedSource, $ModifiedDestination + $Files 584 | 585 | # We add wait and retry with the default from their parameters, else Robocopy will try a million time before time out 586 | $RobocopyArguments += '/r:' + $Retry 587 | $RobocopyArguments += '/w:' + $Wait 588 | 589 | #region Copy options 590 | if ($IncludeSubDirectories) { 591 | $RobocopyArguments += '/s'; $action = 'Copy' 592 | } 593 | if ($IncludeEmptySubDirectories) { 594 | $RobocopyArguments += '/e'; $action = 'Copy' 595 | } 596 | if ($Level) { 597 | $RobocopyArguments += '/lev:' + $Level 598 | } 599 | if ($BackupMode) { 600 | $RobocopyArguments += '/b' 601 | } 602 | if ($RestartMode) { 603 | $RobocopyArguments += '/z' 604 | } 605 | if ($RestartAndBackupMode) { 606 | $RobocopyArguments += '/zb' 607 | } 608 | if ($UnbufferedIO) { 609 | $RobocopyArguments += '/j' 610 | } 611 | if ($EFSRaw) { 612 | $RobocopyArguments += '/efsraw' 613 | } 614 | if ($CopyFlags) { 615 | $RobocopyArguments += '/copy:' + (($CopyFlags | Sort-Object -Unique) -join '') 616 | } 617 | If ($DirectoryCopyFlags) { 618 | $RobocopyArguments += '/dcopy:' + (($DirectoryCopyFlags | Sort-Object -Unique) -join '') 619 | } 620 | if ($CopyWithSecurity) { 621 | $RobocopyArguments += '/sec' 622 | } 623 | If ($CopyAllFileInformation) { 624 | $RobocopyArguments += '/copyall' 625 | } 626 | if ($NoCopy) { 627 | $RobocopyArguments += '/nocopy' 628 | } 629 | if ($SecurityFix) { 630 | $RobocopyArguments += '/secfix' 631 | } 632 | if ($Timefix) { 633 | $RobocopyArguments += '/timfix' 634 | } 635 | if ($Purge) { 636 | $RobocopyArguments += '/purge' ; $action = 'Purge' 637 | } 638 | if ($Mirror) { 639 | $RobocopyArguments += '/mir'; $action = 'Mirror' 640 | } 641 | if ($MoveFiles) { 642 | $RobocopyArguments += '/mov'; $action = 'Move' 643 | } 644 | if ($MoveFilesAndDirectories) { 645 | $RobocopyArguments += '/move' ; $action = 'Move' 646 | } 647 | if ($AddAttribute) { 648 | $RobocopyArguments += '/a+:' + (($AddAttribute | Sort-Object -Unique) -join '') 649 | } 650 | if ($RemoveAttribute) { 651 | $RobocopyArguments += '/a-:' + (($RemoveAttribute | Sort-Object -Unique) -join '') 652 | } 653 | if ($Create) { 654 | $RobocopyArguments += '/create' 655 | } 656 | if ($fat) { 657 | $RobocopyArguments += '/fat' 658 | } 659 | if ($IgnoreLongPath) { 660 | $RobocopyArguments += '/256' 661 | } 662 | if ($MonitorChanges) { 663 | $RobocopyArguments += '/mon:' + $MonitorChanges 664 | } 665 | if ($MonitorMinutes) { 666 | $RobocopyArguments += '/mot:' + $MonitorMinutes 667 | } 668 | if ($Threads) { 669 | $RobocopyArguments += '/MT:' + $Threads 670 | } 671 | if ($RunTimes) { 672 | $RobocopyArguments += '/rh:' + $RunTimes 673 | } 674 | if ($UsePerFileRunTimes) { 675 | $RobocopyArguments += '/pf' 676 | } 677 | if ($InterPacketGap) { 678 | $RobocopyArguments += '/ipg:' + $InterPacketGap 679 | } 680 | if ($CopyJunction) { 681 | $RobocopyArguments += '/sj' 682 | } 683 | if ($SymbolicLink) { 684 | $RobocopyArguments += '/sl' 685 | } 686 | if ($NoDirectoryInformation) { 687 | $RobocopyArguments += '/nodcopy' 688 | } 689 | if ($NoOffload) { 690 | $RobocopyArguments += '/nooffload' 691 | } 692 | if ($Compress) { 693 | $RobocopyArguments += '/compress' 694 | } 695 | if ($Sparse) { 696 | $RobocopyArguments += '/sparse' 697 | } 698 | #endregion 699 | 700 | #region Copy File Throttling Options 701 | If ($IoMaxSize) { 702 | $RobocopyArguments += '/IoMaxSize:' + $IoMaxSize 703 | } 704 | If ($IoRate) { 705 | $RobocopyArguments += '/IoRate:' + $IoRate 706 | } 707 | If ($Threshold) { 708 | $RobocopyArguments += '/Threshold:' + $Threshold 709 | } 710 | #endregion 711 | 712 | #region File selection options 713 | if ($Archive) { 714 | $RobocopyArguments += '/a' 715 | } 716 | if ($ResetArchiveAttribute) { 717 | $RobocopyArguments += '/m' 718 | } 719 | if ($IncludeAttribute) { 720 | $RobocopyArguments += '/ia:' + ($IncludeAttribute | Sort-Object -Unique) -join '' 721 | } 722 | if ($ExcludeAttribute) { 723 | $RobocopyArguments += '/xa:' + ($ExcludeAttribute | Sort-Object -Unique) -join '' 724 | } 725 | if ($ExcludeFileName) { 726 | $RobocopyArguments += ('/xf', ($ExcludeFileName | ForEach-Object { $_ })) 727 | } 728 | if ($ExcludeDirectory) { 729 | $RobocopyArguments += ('/xd', ($ExcludeDirectory | ForEach-Object { $_ })) 730 | } 731 | if ($ExcludeChangedFiles) { 732 | $RobocopyArguments += '/xc' 733 | } 734 | if ($ExcludeNewerFiles) { 735 | $RobocopyArguments += '/xn' 736 | } 737 | if ($ExcludeOlderFiles) { 738 | $RobocopyArguments += '/xo' 739 | } 740 | if ($ExcludeExtraFiles) { 741 | $RobocopyArguments += '/xx' 742 | } 743 | if ($ExcludeLonelyFiles) { 744 | $RobocopyArguments += '/xl' 745 | } 746 | if ($IncludeModifiedFile) { 747 | $RobocopyArguments += '/im' 748 | } 749 | if ($IncludeSameFiles) { 750 | $RobocopyArguments += '/is' 751 | } 752 | if ($IncludeTweakedFiles) { 753 | $RobocopyArguments += '/it' 754 | } 755 | if ($MaximumFileSize) { 756 | $RobocopyArguments += '/max:' + $MaximumFileSize 757 | } 758 | if ($MinimumFileSize) { 759 | $RobocopyArguments += '/min:' + $MinimumFileSize 760 | } 761 | if ($MaximumFileAge) { 762 | $RobocopyArguments += '/maxage:' + $MaximumFileAge 763 | } 764 | if ($MinimumFileAge) { 765 | $RobocopyArguments += '/minage:' + $MinimumFileAge 766 | } 767 | if ($MaximumFileLastAccessDate) { 768 | $RobocopyArguments += '/maxlad:' + $MaximumFileLastAccessDate 769 | } 770 | if ($MinimumFileLastAccessDate) { 771 | $RobocopyArguments += '/minlad:' + $MinimumFileLastAccessDate 772 | } 773 | if ($ExcludeJunctionPoints) { 774 | $RobocopyArguments += '/xj' 775 | } 776 | if ($ExcludeFileJunctionPoints) { 777 | $RobocopyArguments += '/xjf' 778 | } 779 | if ($ExcludeDirectoryJunctionPoints) { 780 | $RobocopyArguments += '/xjd' 781 | } 782 | if ($AssumeFATFileTime) { 783 | $RobocopyArguments += '/fft' 784 | } 785 | if ($CompensateDST) { 786 | $RobocopyArguments += '/dst' 787 | } 788 | if ($SaveRetrySettings) { 789 | $RobocopyArguments += '/reg' 790 | } 791 | if ($WaitForShareName) { 792 | $RobocopyArguments += '/tbd' 793 | } 794 | If ($LowFreeSpaceMode) { 795 | $RobocopyArguments += '/LFSM' 796 | } 797 | If ($LowFreeSpaceModeValue) { 798 | $RobocopyArguments += '/LFSM:' + $LowFreeSpaceModeValue 799 | } 800 | #endregion 801 | 802 | #region Logging Options 803 | If ($List) { 804 | $RobocopyArguments += '/l' ; $action = 'List' 805 | } 806 | If ($ReportExtraFile) { 807 | $RobocopyArguments += '/x' 808 | } 809 | if ($PSBoundParameters.ContainsKey('Verbose')) { 810 | $RobocopyArguments += '/v' 811 | } 812 | If ($NoSizeToLog) { 813 | $RobocopyArguments += '/ns' 814 | } 815 | If ($NoClassToLog) { 816 | $RobocopyArguments += '/nc' 817 | } 818 | If ($NoFileNameToLog) { 819 | $RobocopyArguments += '/nfl' 820 | } 821 | If ($LogFile) { 822 | $RobocopyArguments += '/log:' + $LogFile 823 | } 824 | If ($LogFileWithAppend) { 825 | $RobocopyArguments += '/log+:' + $LogFileWithAppend 826 | } 827 | If ($Unicode) { 828 | $RobocopyArguments += '/unicode' 829 | } 830 | If ($UnicodeLog) { 831 | $RobocopyArguments += '/unilog:' + $UnicodeLog 832 | } 833 | If ($UnicodeLogWithAppend) { 834 | $RobocopyArguments += '/unilog+:' + $UnicodeLogWithAppend 835 | } 836 | #endregion 837 | 838 | #region Job Options 839 | If ($JobName) { 840 | $RobocopyArguments += '/job:' + $JobName 841 | } 842 | If ($SaveJob) { 843 | $RobocopyArguments += '/save:' + $SaveJob 844 | } 845 | If ($Quit) { 846 | $RobocopyArguments += '/quit' 847 | } 848 | If ($NoSourceDirectory) { 849 | $RobocopyArguments += '/NOSD' 850 | } 851 | If ($NoDestinationDirectory) { 852 | $RobocopyArguments += '/NODD' 853 | } 854 | If ($IncludeFollowingFile) { 855 | $RobocopyArguments += '/IF' + " $IncludeFollowingFile" 856 | } 857 | #endregion 858 | 859 | # Arguments of the copy command. Fills in the $RoboLog temp file 860 | $RoboArgs = @($RobocopyArguments + ('/bytes', '/TEE', '/np', '/njh', '/fp', '/ndl', '/ts')) 861 | 862 | # Powershell 7.3 introduces breaking changes to argument passing. 863 | # https://learn.microsoft.com/en-us/powershell/scripting/learn/experimental-features?view=powershell-7.3#psnativecommandargumentpassing 864 | $script:PSNativeCommandArgumentPassing = 'Legacy' 865 | 866 | # Reason why ShouldProcess is this far down is because $action is not set before this part 867 | $strRoboArgs = ($RoboArgs | ForEach-Object { [string]$_ }) -join ' ' 868 | If ($PSCmdlet.ShouldProcess("$Destination from $Source" , "$action with arguments $strRoboArgs")) { 869 | 870 | if (-not (Get-Command -Name robocopy -ErrorAction SilentlyContinue)) { 871 | Write-Warning -Message 'Action failed because robocopy.exe could not be found.' 872 | break 873 | } 874 | 875 | If ($Quit) { 876 | # If Quit is used output parameters and break 877 | Robocopy.exe $RoboArgs 878 | break 879 | } 880 | 881 | <# 882 | If (!(Test-Path -LiteralPath $Source -PathType Container)) { 883 | $Exception = [Exception]::new("Cannot find source directory $Source because it does not exist.") 884 | $TargetObject = $source 885 | $ErrorRecord = [System.Management.Automation.ErrorRecord]::new( 886 | $Exception, 887 | "errorID", 888 | [System.Management.Automation.ErrorCategory]::NotSpecified, 889 | $TargetObject 890 | ) 891 | $PSCmdlet.ThrowTerminatingError($ErrorRecord) 892 | } 893 | #> 894 | 895 | #region All Logic for the robocopy process is handled here. Including what to do with the output etc. 896 | if ($OutputType -eq 'Parse') { 897 | Robocopy.exe @RoboArgs | Where-Object { $PSItem -ne '' } | Invoke-RobocopyParser -Unit $unit -Precision $Precision | & { 898 | process { 899 | If ($psitem.stream -eq 'Verbose') { 900 | Write-Verbose -Message ('"{0} File" on "Item {1}" to target "{2}" Status on Item "{3}". Length on Item "{4}". TimeStamp on Item "{5}"' -f $action, $psitem.FullName , $Destination, $psitem.status, $psitem.length, $psitem.TimeStamp) 901 | } 902 | 903 | ElseIf ($psitem.stream -eq 'Error') { 904 | 905 | If ($psitem.exception) { 906 | $Exception = [Exception]::new($psitem.exception) 907 | } 908 | Else { 909 | $Exception = [Exception]::new($psitem.Value) 910 | } 911 | 912 | $ErrorRecord = [System.Management.Automation.ErrorRecord]::new( 913 | $Exception, 914 | $Psitem.ErrorID, 915 | [System.Management.Automation.ErrorCategory]::NotSpecified, 916 | $TargetObject # usually the object that triggered the error, if possible 917 | ) 918 | $PSCmdlet.WriteError($ErrorRecord) 919 | } 920 | 921 | ElseIf ($psitem.stream -eq 'Warning') { 922 | Write-Warning $psitem.value 923 | } 924 | 925 | ElseIf ($psitem.stream -eq 'Information') { 926 | Write-Information $psitem.Value 927 | } 928 | 929 | Else { 930 | # This will output the pscustomobject with information as source, destination, success and more 931 | $Psitem 932 | } 933 | } 934 | } 935 | } 936 | else { 937 | Robocopy.exe @RoboArgs 938 | } 939 | } 940 | } 941 | } 942 | -------------------------------------------------------------------------------- /RobocopyPS/functions/Move-RoboItem.ps1: -------------------------------------------------------------------------------- 1 | function Move-RoboItem { 2 | [CmdletBinding(SupportsShouldProcess = $True)] 3 | param ( 4 | 5 | ) 6 | 7 | DynamicParam { 8 | # Get available parameters from Invoke-RoboCopy and ignore parameters that is not for moving items 9 | New-ProxyFunction -CommandName 'Invoke-RoboCopy' -CommandType 'Function' -ignoredParams "Mirror", "MoveFiles", "MoveFilesAndDirectories" 10 | } 11 | 12 | 13 | begin { 14 | 15 | } 16 | 17 | process { 18 | $Destination = $PSBoundParameters['Destination'] 19 | $Source = $PSBoundParameters['Source'] 20 | 21 | If ($PSCmdlet.ShouldProcess("$Destination from $Source" , "Move")) { 22 | try { 23 | Invoke-RoboCopy -MoveFilesAndDirectories @PSBoundParameters -ErrorAction Stop 24 | } 25 | catch { 26 | $PSCmdlet.WriteError($psitem) 27 | } 28 | } 29 | } 30 | 31 | end { 32 | 33 | } 34 | } -------------------------------------------------------------------------------- /RobocopyPS/functions/Remove-RoboItem.ps1: -------------------------------------------------------------------------------- 1 | Function Remove-RoboItem { 2 | [CmdletBinding(SupportsShouldProcess = $True)] 3 | 4 | PARAM ( 5 | # Path to directory 6 | [Parameter( Mandatory = $True, 7 | ValueFromPipelineByPropertyName, 8 | ValueFromPipeline)] 9 | [Alias('FullPath')] 10 | [String[]]$Path, 11 | 12 | # Remove files in restartable mode. 13 | [Alias('z')] 14 | [switch]$RestartMode, 15 | 16 | # Remove files in Backup mode. 17 | [Alias('b')] 18 | [switch]$BackupMode, 19 | 20 | # Remove files in restartable mode. If file access is denied, switches to backup mode. 21 | [Alias('zb')] 22 | [switch]$RestartAndBackupMode, 23 | 24 | # Creates multi-threaded copies with N threads. N must be an integer between 1 and 128. Cannot be used with the InterPacketGap and EFSRAW parameters. The /MT parameter applies to Windows Server 2008 R2 and Windows 7. 25 | [Parameter(Mandatory = $False)] 26 | [ValidateRange(1, 128)] 27 | [Alias('MT', 'MultiThread')] 28 | [int]$Threads, 29 | 30 | <#Retry Options#> 31 | 32 | # Specifies the number of retries on failed copies. Default is 3. 33 | [Alias('r')] 34 | [int]$Retry = 3, 35 | 36 | # Specifies the wait time between retries, in seconds. The default value of N is 3. 37 | [Alias('w')] 38 | [int]$Wait = 3 39 | 40 | ) 41 | 42 | Begin {} 43 | 44 | Process { 45 | foreach ($Location in $Path) { 46 | If ($PSCmdlet.ShouldProcess("$Location" , 'Remove')) { 47 | 48 | # Because we are using -Destination in Invoke-RoboCopy, and no validation to check if the Destination directory 49 | # actually exists we need to create the validation here instead 50 | 51 | If (!(Test-Path -Path $Location -PathType Container)) { 52 | $Exception = [Exception]::new("Cannot find directory $Location because it does not exist.") 53 | $TargetObject = $Location 54 | $ErrorRecord = [System.Management.Automation.ErrorRecord]::new( 55 | $Exception, 56 | 'errorID', 57 | [System.Management.Automation.ErrorCategory]::NotSpecified, 58 | $TargetObject 59 | ) 60 | $PSCmdlet.WriteError($ErrorRecord) 61 | Continue 62 | } 63 | 64 | try { 65 | $tempDirectory = New-Item -Path $env:temp -Name (New-Guid).Guid -ItemType Directory -ErrorAction Stop 66 | $PSBoundParameters.Set_Item('Path', $tempDirectory) 67 | 68 | Invoke-RoboCopy -Destination $Location -Mirror @PSBoundParameters 69 | Get-Item -Path $Location | ForEach-Object {$_.Delete()} 70 | } 71 | catch { 72 | $PSCmdlet.WriteError($PSitem) 73 | } 74 | finally { 75 | Get-Item -Path $tempDirectory | ForEach-Object {$_.Delete()} 76 | } 77 | } # end WhatIf 78 | } #end foreach 79 | } 80 | 81 | End {} 82 | } -------------------------------------------------------------------------------- /RobocopyPS/functions/Sync-RoboItem.ps1: -------------------------------------------------------------------------------- 1 | function Sync-RoboItem { 2 | [CmdletBinding(SupportsShouldProcess = $True)] 3 | 4 | 5 | param ( 6 | 7 | ) 8 | 9 | DynamicParam { 10 | # Get available parameters from Invoke-RoboCopy and ignore parameters that is not for moving items 11 | New-ProxyFunction -CommandName 'Invoke-RoboCopy' -CommandType 'Function' -ignoredParams "Mirror", "MoveFiles", "MoveFilesAndDirectories","Files","IncludeSubDirectories","IncludeEmptySubDirectories","Purge" 12 | } 13 | 14 | begin { 15 | 16 | } 17 | 18 | process { 19 | $Destination = $PSBoundParameters['Destination'] 20 | $Source = $PSBoundParameters['Source'] 21 | 22 | If ($PSCmdlet.ShouldProcess("from $source to $destination" , 'Sync')) { 23 | Invoke-RoboCopy -Mirror @PSBoundParameters 24 | } 25 | } 26 | 27 | end { 28 | 29 | } 30 | } -------------------------------------------------------------------------------- /RobocopyPS/internal/Format-SpeedHumanReadable.ps1: -------------------------------------------------------------------------------- 1 | Function Format-SpeedHumanReadable { 2 | Param ( 3 | [String]$Size, 4 | 5 | [ValidateSet('Auto', 'PB', 'TB', 'GB', 'MB', 'KB', 'Bytes')] 6 | [String]$Unit = 'Auto', 7 | 8 | [ValidateRange(1,28)] 9 | [System.Int64]$Precision 10 | ) 11 | 12 | [System.Double]$absSize = $size.trimStart('-') 13 | if ($size -like '-*') { 14 | $Operator = '-' 15 | } 16 | else { 17 | $Operator = '' 18 | } 19 | 20 | If ($Unit -eq 'Auto') { 21 | switch ($absSize) { 22 | { $_ -ge 1PB } { 23 | #"{1}{0:#.#' PB'}" -f ($absSize / 1PB), $Operator; break 24 | $Output = [Math]::Round(([Decimal] $absSize / 1PB), $Precision) 25 | [System.String]$Output + " PB" ; break 26 | } 27 | { $_ -ge 1TB } { 28 | #"{1}{0:#.#' TB'}" -f ($absSize / 1TB), $Operator; break 29 | $Output = [Math]::Round(([Decimal] $absSize / 1TB), $Precision) 30 | [System.String]$Output + " TB" ; break 31 | } 32 | { $_ -ge 1GB } { 33 | #"{1}{0:#.#' GB'}" -f ($absSize / 1GB), $Operator; break 34 | $Output = [Math]::Round(([Decimal] $absSize / 1GB), $Precision) 35 | [System.String]$Output + " GB" ; break 36 | } 37 | { $_ -ge 1MB } { 38 | #"{1}{0:#.#' MB'}" -f ($absSize / 1MB), $Operator; break 39 | $Output = [Math]::Round(([Decimal] $absSize / 1MB), $Precision) 40 | [System.String]$Output + " MB" ; break 41 | } 42 | { $_ -ge 1KB } { 43 | #"{1}{0:#' KB'}" -f ($absSize / 1KB), $Operator; break 44 | $Output = [Math]::Round(([Decimal] $absSize / 1KB), $Precision) 45 | [System.String]$Output + " KB" ; break 46 | } 47 | default { 48 | "{1}{0}" -f ($absSize), $Operator + " B" 49 | } 50 | } 51 | } 52 | else { 53 | switch ($Unit) { 54 | 'PB' { 55 | #"{1}{0:#.#' PB'}" -f ($absSize / 1PB), $Operator; break 56 | $Output = [Math]::Round(([decimal] $absSize / 1PB), $Precision) 57 | [System.String]$Output + " PB" ; break 58 | } 59 | 'TB' { 60 | #"{1}{0:#.#' TB'}" -f ($absSize / 1TB), $Operator; break 61 | $Output = [Math]::Round(([decimal] $absSize / 1TB), $Precision) 62 | [System.String]$Output + " TB" ; break 63 | } 64 | 'GB' { 65 | #"{1}{0:#.#' GB'}" -f ($absSize / 1GB), $Operator; break 66 | $Output = [Math]::Round(([decimal] $absSize / 1GB), $Precision) 67 | [System.String]$Output + " GB" ; break 68 | } 69 | 'MB' { 70 | #"{1}{0:#.#' MB'}" -f ($absSize / 1MB), $Operator; break 71 | $Output = [Math]::Round(([decimal] $absSize / 1MB), $Precision) 72 | [System.String]$Output + " MB" ; break 73 | } 74 | 'KB' { 75 | #"{1}{0:#' KB'}" -f ($absSize / 1KB), $Operator; break 76 | $Output = [Math]::Round(([decimal] $absSize / 1KB), $Precision) 77 | [System.String]$Output + " KB" ; break 78 | } 79 | default { 80 | "{1}{0}" -f ($absSize), $Operator + " B" 81 | } 82 | } 83 | } 84 | } -------------------------------------------------------------------------------- /RobocopyPS/internal/Invoke-RobocopyParser.ps1: -------------------------------------------------------------------------------- 1 | Function Invoke-RobocopyParser { 2 | <# 3 | .SYNOPSIS 4 | Parse Robocopy.exe output 5 | 6 | .DESCRIPTION 7 | This function will try and parse the output from when you run Robocopy.exe and give you information about what PowerShell stream should be used. 8 | 9 | .EXAMPLE 10 | PS$ > 11 | #> 12 | 13 | 14 | [CmdletBinding()] 15 | 16 | PARAM ( 17 | # Robocopy text 18 | [Parameter(ValueFromPipeline = $true)] 19 | [String] 20 | $InputObject, 21 | 22 | # What unit the sizes are shown as 23 | [ValidateSet('Auto', 'PB', 'TB', 'GB', 'MB', 'KB', 'Bytes')] 24 | [String]$Unit = 'Auto', 25 | 26 | [ValidateRange(1,28)] 27 | [System.Int64]$Precision = 4 28 | ) 29 | 30 | begin { 31 | # We have a corresponding $endtime to measure how long the code ran for 32 | $StartTime = $(Get-Date) 33 | 34 | # Regex for catching all text that will be sent to Error Stream 35 | $ErrorFilter = @( 36 | "The filename, directory name, or volume label syntax is incorrect.", 37 | "\*\*\*\*\* You need these to perform Backup copies \(\/B or \/ZB\).", 38 | "ERROR \d{1,3} \(0x\d{1,11}\)", 39 | "ERROR : ", 40 | "ERROR: RETRY LIMIT EXCEEDED.", 41 | "ERROR 123" 42 | ) -join '|' 43 | 44 | # Regex for catching all text that will be sent to Warning Stream 45 | $WarningFilter = @( 46 | "Waiting $Wait seconds... Retrying..." 47 | "Pausing to wait for free space" 48 | ) -join '|' 49 | 50 | # Regex filter used for finding strings we want to handle in Robocopy output. This is also used when we find specific strings in the output 51 | [regex] $HeaderRegex = '\s+Total\s*Copied\s+Skipped\s+Mismatch\s+FAILED\s+Extras' 52 | [regex] $DirLineRegex = 'Dirs\s*:\s*(?\d+)(?:\s+\d+){3}\s+(?\d+)\s+\d+' 53 | [regex] $FileLineRegex = 'Files\s*:\s*(?\d+)(?:\s+\d+){3}\s+(?\d+)\s+\d+' 54 | [regex] $BytesLineRegex = 'Bytes\s*:\s*(?\d+)(?:\s+\d+){3}\s+(?\d+)\s+\d+' 55 | [regex] $TimeLineRegex = 'Times\s*:\s*(?\d+).*' 56 | [regex] $EndedLineRegex = 'Ended\s*:\s*(?.+)' 57 | [regex] $SpeedLineRegex = 'Speed\s:\s+(\d+)\sBytes\/sec|Speed\s*:\s*([\d\s,]+)\s*Bytes\/sec\.' 58 | [regex] $JobSummaryEndLineRegex = '[-]{78}' 59 | [regex] $SpeedInMinutesRegex = 'Speed\s:\s+(\d+).(\d+)\sMegaBytes\/min' 60 | [regex] $FileInfoRegex = "\s*(?[\*A-Za-z]+|([\*A-Za-z]+\s+[A-Za-z]+)|)\s+(?[0-9]+)\s+(?([0-9]{4}\/[01][0-9]\/[0-3][0-9])\s+([0-2][0-9]:[0-5][0-9]:[0-5][0-9]))\s+(?.+)\s*$" 61 | } 62 | 63 | Process { 64 | try { 65 | 66 | If ($InputObject -match $ErrorFilter -or $ForceNextLineIntoError -eq $true) { 67 | # If any error happened we set $errorOccured to $true. 68 | # This is used in the output Property Success. If $errorOccured is $true we set Success to $false 69 | $errorOccured = $true 70 | 71 | If ($null -eq $Message) { 72 | $Message = $inputobject 73 | $ForceNextLineIntoError = $true 74 | } 75 | else { 76 | $LastMessage = ("{0}. {1}" -f $Message, $inputobject.trim()) 77 | $ForceNextLineIntoError = $false 78 | $Message = $null 79 | $SplitMessage = $LastMessage -split '(ERROR \d \(0x\d{1,11}\) )' 80 | [PSCustomObject]@{ 81 | Value = $LastMessage 82 | Stream = "Error" 83 | Exception = $SplitMessage[2] 84 | ErrorID = $SplitMessage[1] 85 | } 86 | } 87 | } 88 | 89 | ElseIf ($InputObject -match $FileInfoRegex) { 90 | $timestamp = [DateTime]::Parse($Matches.timestamp) 91 | $Extension = [System.IO.Path]::GetExtension($Matches.Path) 92 | $FileName = [System.IO.Path]::GetFileName($Matches.Path) 93 | 94 | [PSCustomObject]@{ 95 | Extension = $Extension 96 | Name = $FileName 97 | FullName = $Matches.Path 98 | Length = $Matches.Size 99 | TimeStamp = $TimeStamp 100 | Status = $Matches.Status 101 | Stream = "Verbose" 102 | } 103 | } 104 | 105 | ElseIf ($InputObject -match "$HeaderRegex|$DirLineRegex|$FileLineRegex|$BytesLineRegex|$TimeLineRegex|$EndedLineRegex|$SpeedLineRegex|$JobSummaryEndLineRegex|$SpeedInMinutesRegex") { 106 | # Some we will just assign to variables and dont use or dont do anything with 107 | Switch -Regex ($inputobject) { 108 | $JobSummaryEndLine { } 109 | $HeaderRegex { } 110 | $DirLineRegex { $TotalDirs, $TotalDirCopied, $TotalDirIgnored, $TotalDirMismatched, $TotalDirFailed, $TotalDirExtra = $PSitem | Select-String -Pattern '\d+' -AllMatches | ForEach-Object { $PSitem.Matches } | ForEach-Object { $PSitem.Value } } 111 | $FileLineRegex { $TotalFiles, $TotalFileCopied, $TotalFileIgnored, $TotalFileMismatched, $TotalFileFailed, $TotalFileExtra = $PSitem | Select-String -Pattern '\d+' -AllMatches | ForEach-Object { $PSitem.Matches } | ForEach-Object { $PSitem.Value } } 112 | $BytesLineRegex { $TotalBytes, $TotalBytesCopied, $TotalBytesIgnored, $TotalBytesMismatched, $TotalBytesFailed, $TotalBytesExtra = $PSitem | Select-String -Pattern '\d+' -AllMatches | ForEach-Object { $PSitem.Matches } | ForEach-Object { $PSitem.Value } } 113 | #$TimeLineRegex { [TimeSpan]$TotalDuration, [TimeSpan]$CopyDuration, [TimeSpan]$FailedDuration, [TimeSpan]$ExtraDuration = $PSitem | Select-String -Pattern '\d?\d\:\d{2}\:\d{2}' -AllMatches | ForEach-Object { $PSitem.Matches } | ForEach-Object { $PSitem.Value } } 114 | $EndedLineRegex { } 115 | $SpeedLineRegex { $TotalSpeedBytes, $null = ($PSitem | Select-String -Pattern '\d+' -AllMatches | ForEach-Object { $PSitem.Matches } | ForEach-Object { $PSitem.Value }) -join "" } # fix for issue 18 116 | $SpeedInMinutesRegex { } 117 | } 118 | } 119 | 120 | elseif ($InputObject -match $WarningFilter) { 121 | [PSCustomObject]@{ 122 | Value = $InputObject 123 | Stream = "Warning" 124 | } 125 | } 126 | 127 | ElseIf ($InputObject) { 128 | # Write all strings to Information stream that we dont have rules for 129 | [PSCustomObject]@{ 130 | Value = $InputObject 131 | Stream = "Information" 132 | } 133 | } 134 | } 135 | catch { 136 | Write-Warning "cannot parse output line: ${InputObject}: $($PSItem.Exception.Message)" 137 | [PSCustomObject]@{ 138 | Value = $InputObject 139 | Stream = "Information" 140 | } 141 | } 142 | } 143 | 144 | end { 145 | 146 | # Exit Code lookup "table" 147 | $LastExitCodeMessage = switch ($LASTEXITCODE) { 148 | 0 { 'No files were copied. No failure was encountered. No files were mismatched. The files already exist in the destination directory; therefore, the copy operation was skipped.' } 149 | 1 { 'All files were copied successfully.' } 150 | 2 { 'There are some additional files in the destination directory that are not present in the source directory. No files were copied.' } 151 | 3 { 'Some files were copied. Additional files were present. No failure was encountered.' } 152 | 4 { 'Some Mismatched files or directories were detected. Examine the output log. Housekeeping might be required.' } 153 | 5 { 'Some files were copied. Some files were mismatched. No failure was encountered.' } 154 | 6 { 'Additional files and mismatched files exist. No files were copied and no failures were encountered. This means that the files already exist in the destination directory.' } 155 | 7 { 'Files were copied, a file mismatch was present, and additional files were present.' } 156 | 8 { 'Several files did not copy.(copy errors occurred and the retry limit was exceeded). Check these errors further.' } 157 | 9 { 'Some files did copy, but copy errors occurred and the retry limit was exceeded. Check these errors further.' } 158 | 10 { 'Copy errors occurred and the retry limit was exceeded. Some Extra files or directories were detected.' } 159 | 11 { 'Some files were copied. Copy errors occurred and the retry limit was exceeded. Some Extra files or directories were detected.' } 160 | 12 { 'Copy errors occurred and the retry limit was exceeded. Some Mismatched files or directories were detected.' } 161 | 13 { 'Some files were copied. Copy errors occurred and the retry limit was exceeded. Some Mismatched files or directories were detected.' } 162 | 14 { 'Copy errors occurred and the retry limit was exceeded. Some Mismatched files or directories were detected. Some Extra files or directories were detected.' } 163 | 15 { 'Some files were copied. Copy errors occurred and the retry limit was exceeded. Some Mismatched files or directories were detected. Some Extra files or directories were detected.' } 164 | 16 { 'Robocopy did not copy any files. Either a usage error or an error due to insufficient access privileges on the source or destination directories.' } 165 | default { '[WARNING]No message associated with this exit code. ExitCode: {0}' -f $LASTEXITCODE } 166 | } 167 | 168 | # We have a corresponding $starttime to measure how long the code ran for 169 | $endtime = $(Get-Date) 170 | 171 | $FormatSpeedSplatting = @{ 172 | Unit = $Unit 173 | Precision = $Precision 174 | } 175 | 176 | [PSCustomObject]@{ 177 | 'Source' = [System.IO.DirectoryInfo]$Source 178 | 'Destination' = [System.IO.DirectoryInfo]$Destination 179 | 'Command' = 'Robocopy.exe ' + ($RoboArgs | ForEach-Object {[string]$_}) -join " " 180 | 'DirCount' = [int]$TotalDirs 181 | 'FileCount' = [int]$TotalFiles 182 | #'Duration' = $TotalDuration 183 | 'DirCopied' = [int]$TotalDirCopied 184 | 'FileCopied' = [int]$TotalFileCopied 185 | #'CopyDuration' = $CopyDuration 186 | 'DirIgnored' = [int]$TotalDirIgnored 187 | 'FileIgnored' = [int]$TotalFileIgnored 188 | 'DirMismatched' = [int]$TotalDirMismatched 189 | 'FileMismatched' = [int]$TotalFileMismatched 190 | 'DirFailed' = [int]$TotalDirFailed 191 | 'FileFailed' = [int]$TotalFileFailed 192 | #'FailedDuration' = $FailedDuration 193 | 'DirExtra' = [int]$TotalDirExtra 194 | 'FileExtra' = [int]$TotalFileExtra 195 | #'ExtraDuration' = $ExtraDuration 196 | 'TotalTime' = "{0:g}" -f ($endtime - $StartTime) 197 | 'StartedTime' = [datetime]$StartTime 198 | 'EndedTime' = [datetime]$endTime 199 | 'TotalSize' = (Format-SpeedHumanReadable $Totalbytes @FormatSpeedSplatting) 200 | 'TotalSizeCopied' = (Format-SpeedHumanReadable $TotalBytesCopied @FormatSpeedSplatting) 201 | 'TotalSizeIgnored' = (Format-SpeedHumanReadable $TotalBytesIgnored @FormatSpeedSplatting) 202 | 'TotalSizeMismatched' = (Format-SpeedHumanReadable $TotalBytesMismatched @FormatSpeedSplatting) 203 | 'TotalSizeFailed' = (Format-SpeedHumanReadable $TotalBytesFailed @FormatSpeedSplatting) 204 | 'TotalSizeExtra' = (Format-SpeedHumanReadable $TotalBytesExtra @FormatSpeedSplatting) 205 | 'TotalSizeBytes' = [int64]$Totalbytes 206 | 'Speed' = (Format-SpeedHumanReadable $TotalSpeedBytes @FormatSpeedSplatting) + '/s' 207 | 'ExitCode' = $LASTEXITCODE 208 | 'Success' = If ($LASTEXITCODE -lt 8 -and $errorOccured -ne $true) { $true } else { $false } 209 | 'LastExitCodeMessage' = [string]$LastExitCodeMessage 210 | } 211 | } 212 | } -------------------------------------------------------------------------------- /RobocopyPS/internal/New-ProxyFunction.ps1: -------------------------------------------------------------------------------- 1 | Function New-ProxyFunction { 2 | <# 3 | .SYNOPSIS 4 | Proxy function dynamic parameter block 5 | .DESCRIPTION 6 | The dynamic parameter block of a proxy function. This block can be used to copy a proxy function target's parameters, regardless of changes from version to version. 7 | .LINK 8 | https://www.the-little-things.net/blog/2017/07/30/powershell-inheriting-parameters-proxy-functions/ 9 | #> 10 | [CmdletBinding(SupportsShouldProcess = $true)] 11 | [System.Diagnostics.DebuggerStepThrough()] 12 | param( 13 | # The name of the command being proxied. 14 | [System.String] 15 | $CommandName, 16 | 17 | # The type of the command being proxied. Valid values include 'Cmdlet' or 'Function'. 18 | [System.Management.Automation.CommandTypes] 19 | $CommandType, 20 | 21 | [String[]] 22 | $ignoredParams 23 | ) 24 | 25 | Process { 26 | if ($pscmdlet.ShouldProcess('New-ProxyFunction', 'Invoke')) { 27 | try { 28 | # Look up the command being proxied. 29 | $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand($CommandName, $CommandType) 30 | 31 | #If the command was not found, throw an appropriate command not found exception. 32 | if (-not $wrappedCmd) { 33 | $PSCmdlet.ThrowCommandNotFoundError($CommandName, $PSCmdlet.MyInvocation.MyCommand.Name) 34 | } 35 | 36 | # Lookup the command metadata. 37 | $metadata = New-Object -TypeName System.Management.Automation.CommandMetadata -ArgumentList $wrappedCmd 38 | 39 | # Create dynamic parameters, one for each parameter on the command being proxied. 40 | $dynamicDictionary = New-Object -TypeName System.Management.Automation.RuntimeDefinedParameterDictionary 41 | foreach ($key in $metadata.Parameters.Keys) { 42 | If ($ignoredParams -notcontains $Key) { 43 | $parameter = $metadata.Parameters[$key] 44 | $dynamicParameter = New-Object -TypeName System.Management.Automation.RuntimeDefinedParameter -ArgumentList @( 45 | $parameter.Name 46 | $parameter.ParameterType 47 | , $parameter.Attributes 48 | ) 49 | $dynamicDictionary.Add($parameter.Name, $dynamicParameter) 50 | } 51 | } 52 | $dynamicDictionary 53 | 54 | } 55 | catch { 56 | $PSCmdlet.ThrowTerminatingError($_) 57 | } 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /build.ps1: -------------------------------------------------------------------------------- 1 | # Installing depending modules for local development 2 | 3 | [CmdletBinding()] 4 | 5 | $Script:Modules = @( 6 | 'InvokeBuild', 7 | 'platyPS', 8 | 'PSScriptAnalyzer', 9 | 'BuildHelpers' 10 | ) 11 | 12 | $Script:ModuleInstallScope = 'CurrentUser' 13 | 14 | 'Starting build...' 15 | 16 | Get-PackageProvider -Name 'NuGet' -ForceBootstrap | Out-Null 17 | 18 | foreach ($Module in $Script:Modules) { 19 | if (!(Get-Module $Module -ListAvailable)) { 20 | "Installing module dependencies: $Module" 21 | Install-Module -Name $Module -Scope $Script:ModuleInstallScope -Force 22 | } 23 | } 24 | 25 | if ((Get-Module pester -ListAvailable | Sort-Object version | Select-Object -Last 1).Version -lt 5.2){ 26 | Install-Module 'Pester' -MinimumVersion 5.5.0 -Scope $Script:ModuleInstallScope -Force 27 | } 28 | 29 | 'Setting Build Environment variables...' 30 | Set-BuildEnvironment -Force 31 | Get-ChildItem Env:BH* 32 | 33 | -------------------------------------------------------------------------------- /docs/Copy-RoboItem.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: RobocopyPS-help.xml 3 | Module Name: RobocopyPS 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Copy-RoboItem 9 | 10 | ## SYNOPSIS 11 | Copy directories with RoboCopy. 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Copy-RoboItem [-Source] [-WhatIf] [-Confirm] [-Destination] [[-Files] ] [-Force] 17 | [-IncludeSubDirectories] [-IncludeEmptySubDirectories] [[-Level] ] [-RestartMode] [-BackupMode] 18 | [-RestartAndBackupMode] [-UnbufferedIO] [-EFSRaw] [[-CopyFlags] ] [[-DirectoryCopyFlags] ] 19 | [-CopyWithSecurity] [-CopyAllFileInformation] [-NoCopy] [-SecurityFix] [-Timefix] [[-AddAttribute] ] 20 | [[-RemoveAttribute] ] [-Create] [-FAT] [-IgnoreLongPath] [[-MonitorChanges] ] 21 | [[-MonitorMinutes] ] [[-Threads] ] [[-RunTimes] ] [-UsePerFileRunTimes] 22 | [[-InterPacketGap] ] [-CopyJunction] [-SymbolicLink] [-NoDirectoryInformation] [-NoOffload] [-Compress] 23 | [-Sparse] [-IoMaxSize ] [-IoRate ] [-Threshold ] [-Archive] [-ResetArchiveAttribute] 24 | [[-IncludeAttribute] ] [[-ExcludeAttribute] ] [[-ExcludeFileName] ] 25 | [[-ExcludeDirectory] ] [-ExcludeChangedFiles] [-ExcludeNewerFiles] [-ExcludeOlderFiles] 26 | [-ExcludeExtraFiles] [-ExcludeLonelyFiles] [-IncludeModifiedFile] [-IncludeSameFiles] [-IncludeTweakedFiles] 27 | [[-MaximumFileSize] ] [[-MinimumFileSize] ] [[-MaximumFileAge] ] 28 | [[-MinimumFileAge] ] [[-MaximumFileLastAccessDate] ] [[-MinimumFileLastAccessDate] ] 29 | [-ExcludeJunctionPoints] [-AssumeFATFileTime] [-CompensateDST] [-ExcludeDirectoryJunctionPoints] 30 | [-ExcludeFileJunctionPoints] [[-Retry] ] [[-Wait] ] [-SaveRetrySettings] [-WaitForShareName] 31 | [-LowFreeSpaceMode] [[-LowFreeSpaceModeValue] ] [-List] [-ReportExtraFile] [-NoSizeToLog] 32 | [-NoClassToLog] [[-NoFileNameToLog] ] [[-LogFile] ] [[-LogFileWithAppend] ] [-Unicode] 33 | [[-UnicodeLog] ] [[-UnicodeLogWithAppend] ] [[-JobName] ] [[-SaveJob] ] 34 | [-Quit] [-NoSourceDirectory] [-NoDestinationDirectory] [[-IncludeFollowingFile] ] [[-Unit] ] 35 | [-Precision ] [-OutputType ] [] 36 | ``` 37 | 38 | ## DESCRIPTION 39 | Copy one or more directories to a destination directory with the help of Invoke-RoboCopy. 40 | 41 | ## EXAMPLES 42 | 43 | ### Example 1 44 | ```powershell 45 | PS C:\> Copy-RoboItem -Source "D:\tmp\from" -Destination "D:\tmp\to" 46 | ``` 47 | 48 | Copy files and folders from D:\tmp\from to D:\tmp\to 49 | 50 | ## PARAMETERS 51 | 52 | ### -AddAttribute 53 | Adds the specified attributes to copied files. 54 | 55 | ```yaml 56 | Type: String[] 57 | Parameter Sets: (All) 58 | Aliases: 59 | Accepted values: R, A, S, H, C, N, E, T 60 | 61 | Required: False 62 | Position: 6 63 | Default value: None 64 | Accept pipeline input: False 65 | Accept wildcard characters: False 66 | ``` 67 | 68 | ### -Archive 69 | Copies only files for which the Archive attribute is set. 70 | 71 | ```yaml 72 | Type: SwitchParameter 73 | Parameter Sets: (All) 74 | Aliases: a 75 | 76 | Required: False 77 | Position: Named 78 | Default value: False 79 | Accept pipeline input: False 80 | Accept wildcard characters: False 81 | ``` 82 | 83 | ### -AssumeFATFileTime 84 | Assumes FAT file times (two-second precision). 85 | 86 | ```yaml 87 | Type: SwitchParameter 88 | Parameter Sets: (All) 89 | Aliases: fft 90 | 91 | Required: False 92 | Position: Named 93 | Default value: False 94 | Accept pipeline input: False 95 | Accept wildcard characters: False 96 | ``` 97 | 98 | ### -BackupMode 99 | Copies files in Backup mode. 100 | 101 | ```yaml 102 | Type: SwitchParameter 103 | Parameter Sets: (All) 104 | Aliases: b 105 | 106 | Required: False 107 | Position: Named 108 | Default value: False 109 | Accept pipeline input: False 110 | Accept wildcard characters: False 111 | ``` 112 | 113 | ### -CompensateDST 114 | Compensates for one-hour DST time differences. 115 | 116 | ```yaml 117 | Type: SwitchParameter 118 | Parameter Sets: (All) 119 | Aliases: dst 120 | 121 | Required: False 122 | Position: Named 123 | Default value: False 124 | Accept pipeline input: False 125 | Accept wildcard characters: False 126 | ``` 127 | 128 | ### -Compress 129 | Requests network compression during file transfer, if applicable. 130 | 131 | ```yaml 132 | Type: SwitchParameter 133 | Parameter Sets: (All) 134 | Aliases: 135 | 136 | Required: False 137 | Position: Named 138 | Default value: False 139 | Accept pipeline input: False 140 | Accept wildcard characters: False 141 | ``` 142 | 143 | ### -Confirm 144 | Prompts you for confirmation before running the function. 145 | 146 | ```yaml 147 | Type: SwitchParameter 148 | Parameter Sets: (All) 149 | Aliases: cf 150 | 151 | Required: False 152 | Position: Named 153 | Default value: None 154 | Accept pipeline input: False 155 | Accept wildcard characters: False 156 | ``` 157 | 158 | ### -CopyAllFileInformation 159 | Copies all file information (equivalent to /copy:DATSOU). 160 | 161 | ```yaml 162 | Type: SwitchParameter 163 | Parameter Sets: (All) 164 | Aliases: copyall 165 | 166 | Required: False 167 | Position: Named 168 | Default value: False 169 | Accept pipeline input: False 170 | Accept wildcard characters: False 171 | ``` 172 | 173 | ### -CopyFlags 174 | Specifies the file properties to be copied. 175 | The default value for CopyFlags is DAT (data, attributes, and time stamps). 176 | D = Data. 177 | A = Attributes. 178 | T = Time stamps.S = NTFS access control list (ACL). 179 | O =Owner information. 180 | U = Auditing information 181 | 182 | ```yaml 183 | Type: String[] 184 | Parameter Sets: (All) 185 | Aliases: copy 186 | Accepted values: D, A, T, S, O, U 187 | 188 | Required: False 189 | Position: 4 190 | Default value: None 191 | Accept pipeline input: False 192 | Accept wildcard characters: False 193 | ``` 194 | 195 | ### -CopyJunction 196 | Copy Junctions as junctions instead of as the junction targets. 197 | 198 | ```yaml 199 | Type: SwitchParameter 200 | Parameter Sets: (All) 201 | Aliases: sj 202 | 203 | Required: False 204 | Position: Named 205 | Default value: False 206 | Accept pipeline input: False 207 | Accept wildcard characters: False 208 | ``` 209 | 210 | ### -CopyWithSecurity 211 | Copies files with security (equivalent to /copy:DATS). 212 | 213 | ```yaml 214 | Type: SwitchParameter 215 | Parameter Sets: (All) 216 | Aliases: sec 217 | 218 | Required: False 219 | Position: Named 220 | Default value: False 221 | Accept pipeline input: False 222 | Accept wildcard characters: False 223 | ``` 224 | 225 | ### -Create 226 | Creates a directory tree and zero-length files only. 227 | 228 | ```yaml 229 | Type: SwitchParameter 230 | Parameter Sets: (All) 231 | Aliases: 232 | 233 | Required: False 234 | Position: Named 235 | Default value: False 236 | Accept pipeline input: False 237 | Accept wildcard characters: False 238 | ``` 239 | 240 | ### -Destination 241 | Specifies the path to the destination directory. 242 | Must be a folder. 243 | 244 | ```yaml 245 | Type: String 246 | Parameter Sets: (All) 247 | Aliases: Target 248 | 249 | Required: True 250 | Position: 1 251 | Default value: None 252 | Accept pipeline input: True (ByPropertyName, ByValue) 253 | Accept wildcard characters: False 254 | ``` 255 | 256 | ### -DirectoryCopyFlags 257 | Specifies what to copy in directories. 258 | The valid values for this option are:D - Data, A - Attributes, T - Time stamps. 259 | The default value for this option is DA (data and attributes). 260 | 261 | ```yaml 262 | Type: String[] 263 | Parameter Sets: (All) 264 | Aliases: dcopy 265 | Accepted values: D, A, T 266 | 267 | Required: False 268 | Position: 5 269 | Default value: None 270 | Accept pipeline input: False 271 | Accept wildcard characters: False 272 | ``` 273 | 274 | ### -EFSRaw 275 | Copies all encrypted files in EFS RAW mode. 276 | 277 | ```yaml 278 | Type: SwitchParameter 279 | Parameter Sets: (All) 280 | Aliases: 281 | 282 | Required: False 283 | Position: Named 284 | Default value: False 285 | Accept pipeline input: False 286 | Accept wildcard characters: False 287 | ``` 288 | 289 | ### -ExcludeAttribute 290 | Excludes files for which any of the specified attributes are set. 291 | 292 | ```yaml 293 | Type: String[] 294 | Parameter Sets: (All) 295 | Aliases: xa 296 | Accepted values: R, A, S, C, H, N, E, T, O 297 | 298 | Required: False 299 | Position: 14 300 | Default value: None 301 | Accept pipeline input: False 302 | Accept wildcard characters: False 303 | ``` 304 | 305 | ### -ExcludeChangedFiles 306 | Excludes changed files. 307 | 308 | ```yaml 309 | Type: SwitchParameter 310 | Parameter Sets: (All) 311 | Aliases: xc 312 | 313 | Required: False 314 | Position: Named 315 | Default value: False 316 | Accept pipeline input: False 317 | Accept wildcard characters: False 318 | ``` 319 | 320 | ### -ExcludeDirectory 321 | Excludes directories that match the specified names and paths. 322 | 323 | ```yaml 324 | Type: String[] 325 | Parameter Sets: (All) 326 | Aliases: xd 327 | 328 | Required: False 329 | Position: 16 330 | Default value: None 331 | Accept pipeline input: False 332 | Accept wildcard characters: False 333 | ``` 334 | 335 | ### -ExcludeDirectoryJunctionPoints 336 | Excludes junction points for directories. 337 | 338 | ```yaml 339 | Type: SwitchParameter 340 | Parameter Sets: (All) 341 | Aliases: xjd 342 | 343 | Required: False 344 | Position: Named 345 | Default value: False 346 | Accept pipeline input: False 347 | Accept wildcard characters: False 348 | ``` 349 | 350 | ### -ExcludeExtraFiles 351 | Excludes extra files and directories. 352 | 353 | ```yaml 354 | Type: SwitchParameter 355 | Parameter Sets: (All) 356 | Aliases: xx 357 | 358 | Required: False 359 | Position: Named 360 | Default value: False 361 | Accept pipeline input: False 362 | Accept wildcard characters: False 363 | ``` 364 | 365 | ### -ExcludeFileJunctionPoints 366 | Excludes junction points for files. 367 | 368 | ```yaml 369 | Type: SwitchParameter 370 | Parameter Sets: (All) 371 | Aliases: xjf 372 | 373 | Required: False 374 | Position: Named 375 | Default value: False 376 | Accept pipeline input: False 377 | Accept wildcard characters: False 378 | ``` 379 | 380 | ### -ExcludeFileName 381 | Excludes files that match the specified names or paths. 382 | Note that FileName can include wildcard characters (* and ?). 383 | 384 | ```yaml 385 | Type: String[] 386 | Parameter Sets: (All) 387 | Aliases: xf 388 | 389 | Required: False 390 | Position: 15 391 | Default value: None 392 | Accept pipeline input: False 393 | Accept wildcard characters: False 394 | ``` 395 | 396 | ### -ExcludeJunctionPoints 397 | Excludes junction points, which are normally included by default. 398 | 399 | ```yaml 400 | Type: SwitchParameter 401 | Parameter Sets: (All) 402 | Aliases: xj 403 | 404 | Required: False 405 | Position: Named 406 | Default value: False 407 | Accept pipeline input: False 408 | Accept wildcard characters: False 409 | ``` 410 | 411 | ### -ExcludeLonelyFiles 412 | Excludes "lonely" files and directories. 413 | 414 | ```yaml 415 | Type: SwitchParameter 416 | Parameter Sets: (All) 417 | Aliases: xl 418 | 419 | Required: False 420 | Position: Named 421 | Default value: False 422 | Accept pipeline input: False 423 | Accept wildcard characters: False 424 | ``` 425 | 426 | ### -ExcludeNewerFiles 427 | Excludes newer files. 428 | 429 | ```yaml 430 | Type: SwitchParameter 431 | Parameter Sets: (All) 432 | Aliases: xn 433 | 434 | Required: False 435 | Position: Named 436 | Default value: False 437 | Accept pipeline input: False 438 | Accept wildcard characters: False 439 | ``` 440 | 441 | ### -ExcludeOlderFiles 442 | Excludes older files. 443 | 444 | ```yaml 445 | Type: SwitchParameter 446 | Parameter Sets: (All) 447 | Aliases: xo 448 | 449 | Required: False 450 | Position: Named 451 | Default value: False 452 | Accept pipeline input: False 453 | Accept wildcard characters: False 454 | ``` 455 | 456 | ### -FAT 457 | Creates destination files by using 8.3 character-length FAT file names only. 458 | 459 | ```yaml 460 | Type: SwitchParameter 461 | Parameter Sets: (All) 462 | Aliases: 463 | 464 | Required: False 465 | Position: Named 466 | Default value: False 467 | Accept pipeline input: False 468 | Accept wildcard characters: False 469 | ``` 470 | 471 | ### -Files 472 | Specifies the file or files to be copied. 473 | You can use wildcard characters (* or ?), if you want. 474 | If the File parameter is not specified, *.* is used as the default value. 475 | 476 | ```yaml 477 | Type: String[] 478 | Parameter Sets: (All) 479 | Aliases: File 480 | 481 | Required: False 482 | Position: 2 483 | Default value: *.* 484 | Accept pipeline input: False 485 | Accept wildcard characters: False 486 | ``` 487 | 488 | ### -IgnoreLongPath 489 | Turns off support for very long paths. 490 | 491 | ```yaml 492 | Type: SwitchParameter 493 | Parameter Sets: (All) 494 | Aliases: 256 495 | 496 | Required: False 497 | Position: Named 498 | Default value: False 499 | Accept pipeline input: False 500 | Accept wildcard characters: False 501 | ``` 502 | 503 | ### -IncludeAttribute 504 | Includes only files for which any of the specified attributes are set. 505 | 506 | ```yaml 507 | Type: String[] 508 | Parameter Sets: (All) 509 | Aliases: ia 510 | Accepted values: R, A, S, C, H, N, E, T, O 511 | 512 | Required: False 513 | Position: 13 514 | Default value: None 515 | Accept pipeline input: False 516 | Accept wildcard characters: False 517 | ``` 518 | 519 | ### -IncludeEmptySubDirectories 520 | Copies subdirectories. 521 | Note that this option includes empty directories. 522 | 523 | ```yaml 524 | Type: SwitchParameter 525 | Parameter Sets: (All) 526 | Aliases: e, Recurse 527 | 528 | Required: False 529 | Position: Named 530 | Default value: False 531 | Accept pipeline input: False 532 | Accept wildcard characters: False 533 | ``` 534 | 535 | ### -IncludeFollowingFile 536 | Include the following Files. 537 | 538 | ```yaml 539 | Type: String 540 | Parameter Sets: (All) 541 | Aliases: IF 542 | 543 | Required: False 544 | Position: 33 545 | Default value: None 546 | Accept pipeline input: False 547 | Accept wildcard characters: False 548 | ``` 549 | 550 | ### -IncludeModifiedFile 551 | Include modified files (differing change times). 552 | 553 | ```yaml 554 | Type: SwitchParameter 555 | Parameter Sets: (All) 556 | Aliases: im 557 | 558 | Required: False 559 | Position: Named 560 | Default value: False 561 | Accept pipeline input: False 562 | Accept wildcard characters: False 563 | ``` 564 | 565 | ### -IncludeSameFiles 566 | Includes the same files. 567 | 568 | ```yaml 569 | Type: SwitchParameter 570 | Parameter Sets: (All) 571 | Aliases: is 572 | 573 | Required: False 574 | Position: Named 575 | Default value: False 576 | Accept pipeline input: False 577 | Accept wildcard characters: False 578 | ``` 579 | 580 | ### -IncludeSubDirectories 581 | Copies subdirectories. 582 | Note that this option excludes empty directories. 583 | 584 | ```yaml 585 | Type: SwitchParameter 586 | Parameter Sets: (All) 587 | Aliases: s 588 | 589 | Required: False 590 | Position: Named 591 | Default value: False 592 | Accept pipeline input: False 593 | Accept wildcard characters: False 594 | ``` 595 | 596 | ### -IncludeTweakedFiles 597 | Includes "tweaked" files. 598 | 599 | ```yaml 600 | Type: SwitchParameter 601 | Parameter Sets: (All) 602 | Aliases: it 603 | 604 | Required: False 605 | Position: Named 606 | Default value: False 607 | Accept pipeline input: False 608 | Accept wildcard characters: False 609 | ``` 610 | 611 | ### -InterPacketGap 612 | Specifies the inter-packet gap to free bandwidth on slow lines. 613 | 614 | ```yaml 615 | Type: Int32 616 | Parameter Sets: (All) 617 | Aliases: ipg 618 | 619 | Required: False 620 | Position: 12 621 | Default value: 0 622 | Accept pipeline input: False 623 | Accept wildcard characters: False 624 | ``` 625 | 626 | ### -JobName 627 | Specifies that parameters are to be derived from the named job file. 628 | 629 | ```yaml 630 | Type: String 631 | Parameter Sets: (All) 632 | Aliases: Job 633 | 634 | Required: False 635 | Position: 31 636 | Default value: None 637 | Accept pipeline input: False 638 | Accept wildcard characters: False 639 | ``` 640 | 641 | ### -Level 642 | Copies only the top N levels of the source directory tree. 643 | 644 | ```yaml 645 | Type: Int32 646 | Parameter Sets: (All) 647 | Aliases: lev, Depth 648 | 649 | Required: False 650 | Position: 3 651 | Default value: 0 652 | Accept pipeline input: False 653 | Accept wildcard characters: False 654 | ``` 655 | 656 | ### -List 657 | Specifies that files are to be listed only (and not copied, deleted, or time stamped). 658 | 659 | ```yaml 660 | Type: SwitchParameter 661 | Parameter Sets: (All) 662 | Aliases: l 663 | 664 | Required: False 665 | Position: Named 666 | Default value: False 667 | Accept pipeline input: False 668 | Accept wildcard characters: False 669 | ``` 670 | 671 | ### -LogFile 672 | Writes the status output to the log file (overwrites the existing log file). 673 | 674 | ```yaml 675 | Type: String 676 | Parameter Sets: (All) 677 | Aliases: log 678 | 679 | Required: False 680 | Position: 27 681 | Default value: None 682 | Accept pipeline input: False 683 | Accept wildcard characters: False 684 | ``` 685 | 686 | ### -LogFileWithAppend 687 | Writes the status output to the log file (appends the output to the existing log file). 688 | 689 | ```yaml 690 | Type: String 691 | Parameter Sets: (All) 692 | Aliases: 693 | 694 | Required: False 695 | Position: 28 696 | Default value: None 697 | Accept pipeline input: False 698 | Accept wildcard characters: False 699 | ``` 700 | 701 | ### -LowFreeSpaceMode 702 | Using /LFSM requests robocopy to operate in 'low free space mode'. 703 | In that mode, robocopy will pause whenever a file copy would cause the destination volume's free space to go below ten percent of the destination volume's size. 704 | 705 | ```yaml 706 | Type: SwitchParameter 707 | Parameter Sets: (All) 708 | Aliases: lfsm 709 | 710 | Required: False 711 | Position: Named 712 | Default value: False 713 | Accept pipeline input: False 714 | Accept wildcard characters: False 715 | ``` 716 | 717 | ### -LowFreeSpaceModeValue 718 | Using /LFSM requests robocopy to operate in 'low free space mode'. 719 | In that mode, robocopy will pause whenever a file copy would cause the destination volume's free space to go below a 'floor' value, which can be explicitly specified by the n\[KMG\] form of the flag where n=number and K:kilobytes ,M:megabytes or G:gigabytes. 720 | 721 | ```yaml 722 | Type: String 723 | Parameter Sets: (All) 724 | Aliases: 725 | 726 | Required: False 727 | Position: 25 728 | Default value: None 729 | Accept pipeline input: False 730 | Accept wildcard characters: False 731 | ``` 732 | 733 | ### -MaximumFileAge 734 | Specifies the maximum file age (to exclude files older than N days or date). 735 | 736 | ```yaml 737 | Type: String 738 | Parameter Sets: (All) 739 | Aliases: maxage 740 | 741 | Required: False 742 | Position: 19 743 | Default value: None 744 | Accept pipeline input: False 745 | Accept wildcard characters: False 746 | ``` 747 | 748 | ### -MaximumFileLastAccessDate 749 | Specifies the maximum last access date (excludes files unused since N). 750 | 751 | ```yaml 752 | Type: String 753 | Parameter Sets: (All) 754 | Aliases: maxlad 755 | 756 | Required: False 757 | Position: 21 758 | Default value: None 759 | Accept pipeline input: False 760 | Accept wildcard characters: False 761 | ``` 762 | 763 | ### -MaximumFileSize 764 | Specifies the maximum file size (to exclude files bigger than N bytes). 765 | 766 | ```yaml 767 | Type: String 768 | Parameter Sets: (All) 769 | Aliases: max 770 | 771 | Required: False 772 | Position: 17 773 | Default value: None 774 | Accept pipeline input: False 775 | Accept wildcard characters: False 776 | ``` 777 | 778 | ### -MinimumFileAge 779 | Specifies the minimum file age (exclude files newer than N days or date). 780 | 781 | ```yaml 782 | Type: String 783 | Parameter Sets: (All) 784 | Aliases: minage 785 | 786 | Required: False 787 | Position: 20 788 | Default value: None 789 | Accept pipeline input: False 790 | Accept wildcard characters: False 791 | ``` 792 | 793 | ### -MinimumFileLastAccessDate 794 | Specifies the minimum last access date (excludes files used since N) If N is less than 1900, N specifies the number of days. 795 | Otherwise, N specifies a date in the format YYYYMMDD. 796 | 797 | ```yaml 798 | Type: String 799 | Parameter Sets: (All) 800 | Aliases: minlad 801 | 802 | Required: False 803 | Position: 22 804 | Default value: None 805 | Accept pipeline input: False 806 | Accept wildcard characters: False 807 | ``` 808 | 809 | ### -MinimumFileSize 810 | Specifies the minimum file size (to exclude files smaller than N bytes). 811 | 812 | ```yaml 813 | Type: String 814 | Parameter Sets: (All) 815 | Aliases: min 816 | 817 | Required: False 818 | Position: 18 819 | Default value: None 820 | Accept pipeline input: False 821 | Accept wildcard characters: False 822 | ``` 823 | 824 | ### -MonitorChanges 825 | Monitors the source, and runs again when more than N changes are detected. 826 | 827 | ```yaml 828 | Type: Int32 829 | Parameter Sets: (All) 830 | Aliases: mon 831 | 832 | Required: False 833 | Position: 8 834 | Default value: 0 835 | Accept pipeline input: False 836 | Accept wildcard characters: False 837 | ``` 838 | 839 | ### -MonitorMinutes 840 | Monitors source, and runs again in M minutes if changes are detected. 841 | 842 | ```yaml 843 | Type: Int32 844 | Parameter Sets: (All) 845 | Aliases: mot 846 | 847 | Required: False 848 | Position: 9 849 | Default value: 0 850 | Accept pipeline input: False 851 | Accept wildcard characters: False 852 | ``` 853 | 854 | ### -NoClassToLog 855 | Specifies that file sizes are not to be logged. 856 | 857 | ```yaml 858 | Type: SwitchParameter 859 | Parameter Sets: (All) 860 | Aliases: nc 861 | 862 | Required: False 863 | Position: Named 864 | Default value: False 865 | Accept pipeline input: False 866 | Accept wildcard characters: False 867 | ``` 868 | 869 | ### -NoCopy 870 | Copies no file information. 871 | 872 | ```yaml 873 | Type: SwitchParameter 874 | Parameter Sets: (All) 875 | Aliases: 876 | 877 | Required: False 878 | Position: Named 879 | Default value: False 880 | Accept pipeline input: False 881 | Accept wildcard characters: False 882 | ``` 883 | 884 | ### -NoDestinationDirectory 885 | NO Destination Directory is specified. 886 | 887 | ```yaml 888 | Type: SwitchParameter 889 | Parameter Sets: (All) 890 | Aliases: NODD 891 | 892 | Required: False 893 | Position: Named 894 | Default value: False 895 | Accept pipeline input: False 896 | Accept wildcard characters: False 897 | ``` 898 | 899 | ### -NoDirectoryInformation 900 | Copies no directory info (the default /dcopy:DA is done). 901 | 902 | ```yaml 903 | Type: SwitchParameter 904 | Parameter Sets: (All) 905 | Aliases: nodcopy 906 | 907 | Required: False 908 | Position: Named 909 | Default value: False 910 | Accept pipeline input: False 911 | Accept wildcard characters: False 912 | ``` 913 | 914 | ### -NoFileNameToLog 915 | Specifies that file names are not to be logged. 916 | 917 | ```yaml 918 | Type: Object 919 | Parameter Sets: (All) 920 | Aliases: nfl 921 | 922 | Required: False 923 | Position: 26 924 | Default value: None 925 | Accept pipeline input: False 926 | Accept wildcard characters: False 927 | ``` 928 | 929 | ### -NoOffload 930 | Copies files without using the Windows Copy Offload mechanism. 931 | 932 | ```yaml 933 | Type: SwitchParameter 934 | Parameter Sets: (All) 935 | Aliases: 936 | 937 | Required: False 938 | Position: Named 939 | Default value: False 940 | Accept pipeline input: False 941 | Accept wildcard characters: False 942 | ``` 943 | 944 | ### -NoSizeToLog 945 | Specifies that file sizes are not to be logged. 946 | 947 | ```yaml 948 | Type: SwitchParameter 949 | Parameter Sets: (All) 950 | Aliases: ns 951 | 952 | Required: False 953 | Position: Named 954 | Default value: False 955 | Accept pipeline input: False 956 | Accept wildcard characters: False 957 | ``` 958 | 959 | ### -NoSourceDirectory 960 | NO Source Directory is specified. 961 | 962 | ```yaml 963 | Type: SwitchParameter 964 | Parameter Sets: (All) 965 | Aliases: NOSD 966 | 967 | Required: False 968 | Position: Named 969 | Default value: False 970 | Accept pipeline input: False 971 | Accept wildcard characters: False 972 | ``` 973 | 974 | ### -Quit 975 | Quits after processing command line to view parameters. 976 | 977 | ```yaml 978 | Type: SwitchParameter 979 | Parameter Sets: (All) 980 | Aliases: 981 | 982 | Required: False 983 | Position: Named 984 | Default value: False 985 | Accept pipeline input: False 986 | Accept wildcard characters: False 987 | ``` 988 | 989 | ### -RemoveAttribute 990 | Removes the specified attributes from copied files. 991 | 992 | ```yaml 993 | Type: String[] 994 | Parameter Sets: (All) 995 | Aliases: 996 | Accepted values: R, A, S, H, C, N, E, T 997 | 998 | Required: False 999 | Position: 7 1000 | Default value: None 1001 | Accept pipeline input: False 1002 | Accept wildcard characters: False 1003 | ``` 1004 | 1005 | ### -ReportExtraFile 1006 | Report all eXtra files, not just those selected & copied. 1007 | 1008 | ```yaml 1009 | Type: SwitchParameter 1010 | Parameter Sets: (All) 1011 | Aliases: x 1012 | 1013 | Required: False 1014 | Position: Named 1015 | Default value: False 1016 | Accept pipeline input: False 1017 | Accept wildcard characters: False 1018 | ``` 1019 | 1020 | ### -ResetArchiveAttribute 1021 | Copies only files for which the Archive attribute is set, and resets the Archive attribute. 1022 | 1023 | ```yaml 1024 | Type: SwitchParameter 1025 | Parameter Sets: (All) 1026 | Aliases: m 1027 | 1028 | Required: False 1029 | Position: Named 1030 | Default value: False 1031 | Accept pipeline input: False 1032 | Accept wildcard characters: False 1033 | ``` 1034 | 1035 | ### -RestartAndBackupMode 1036 | Copies files in restartable mode. 1037 | If file access is denied, switches to backup mode. 1038 | 1039 | ```yaml 1040 | Type: SwitchParameter 1041 | Parameter Sets: (All) 1042 | Aliases: zb 1043 | 1044 | Required: False 1045 | Position: Named 1046 | Default value: False 1047 | Accept pipeline input: False 1048 | Accept wildcard characters: False 1049 | ``` 1050 | 1051 | ### -RestartMode 1052 | Copies files in restartable mode. 1053 | 1054 | ```yaml 1055 | Type: SwitchParameter 1056 | Parameter Sets: (All) 1057 | Aliases: z 1058 | 1059 | Required: False 1060 | Position: Named 1061 | Default value: False 1062 | Accept pipeline input: False 1063 | Accept wildcard characters: False 1064 | ``` 1065 | 1066 | ### -Retry 1067 | Specifies the number of retries on failed copies. 1068 | Default is 3. 1069 | 1070 | ```yaml 1071 | Type: Int32 1072 | Parameter Sets: (All) 1073 | Aliases: r 1074 | 1075 | Required: False 1076 | Position: 23 1077 | Default value: 3 1078 | Accept pipeline input: False 1079 | Accept wildcard characters: False 1080 | ``` 1081 | 1082 | ### -RunTimes 1083 | Specifies run times when new copies may be started. 1084 | 1085 | ```yaml 1086 | Type: String 1087 | Parameter Sets: (All) 1088 | Aliases: rh 1089 | 1090 | Required: False 1091 | Position: 11 1092 | Default value: None 1093 | Accept pipeline input: False 1094 | Accept wildcard characters: False 1095 | ``` 1096 | 1097 | ### -SaveJob 1098 | Specifies that parameters are to be saved to the named job file. 1099 | 1100 | ```yaml 1101 | Type: String 1102 | Parameter Sets: (All) 1103 | Aliases: Save 1104 | 1105 | Required: False 1106 | Position: 32 1107 | Default value: None 1108 | Accept pipeline input: False 1109 | Accept wildcard characters: False 1110 | ``` 1111 | 1112 | ### -SaveRetrySettings 1113 | Saves the values specified in the /r and /w options as default settings in the registry. 1114 | 1115 | ```yaml 1116 | Type: SwitchParameter 1117 | Parameter Sets: (All) 1118 | Aliases: reg 1119 | 1120 | Required: False 1121 | Position: Named 1122 | Default value: False 1123 | Accept pipeline input: False 1124 | Accept wildcard characters: False 1125 | ``` 1126 | 1127 | ### -SecurityFix 1128 | Fixes file security on all files, even skipped ones. 1129 | 1130 | ```yaml 1131 | Type: SwitchParameter 1132 | Parameter Sets: (All) 1133 | Aliases: secfix 1134 | 1135 | Required: False 1136 | Position: Named 1137 | Default value: False 1138 | Accept pipeline input: False 1139 | Accept wildcard characters: False 1140 | ``` 1141 | 1142 | ### -Source 1143 | Specifies the path to the source directory. 1144 | Must be a folder. 1145 | 1146 | ```yaml 1147 | Type: String[] 1148 | Parameter Sets: (All) 1149 | Aliases: Path, FullPath 1150 | 1151 | Required: True 1152 | Position: 0 1153 | Default value: None 1154 | Accept pipeline input: True (ByPropertyName, ByValue) 1155 | Accept wildcard characters: False 1156 | ``` 1157 | 1158 | ### -SymbolicLink 1159 | Copy Symbolic Links as links instead of as the link targets. 1160 | 1161 | ```yaml 1162 | Type: SwitchParameter 1163 | Parameter Sets: (All) 1164 | Aliases: sl 1165 | 1166 | Required: False 1167 | Position: Named 1168 | Default value: False 1169 | Accept pipeline input: False 1170 | Accept wildcard characters: False 1171 | ``` 1172 | 1173 | ### -Threads 1174 | Creates multi-threaded copies with N threads. 1175 | N must be an integer between 1 and 128. 1176 | Cannot be used with the InterPacketGap and EFSRAW parameters. 1177 | The /MT parameter applies to Windows Server 2008 R2 and Windows 7. 1178 | 1179 | ```yaml 1180 | Type: Int32 1181 | Parameter Sets: (All) 1182 | Aliases: MT, MultiThread 1183 | 1184 | Required: False 1185 | Position: 10 1186 | Default value: None 1187 | Accept pipeline input: False 1188 | Accept wildcard characters: False 1189 | ``` 1190 | 1191 | ### -Timefix 1192 | Fixes file times on all files, even skipped ones. 1193 | 1194 | ```yaml 1195 | Type: SwitchParameter 1196 | Parameter Sets: (All) 1197 | Aliases: timfix 1198 | 1199 | Required: False 1200 | Position: Named 1201 | Default value: False 1202 | Accept pipeline input: False 1203 | Accept wildcard characters: False 1204 | ``` 1205 | 1206 | ### -UnbufferedIO 1207 | Copies using unbuffered I/O (recommended for large files). 1208 | 1209 | ```yaml 1210 | Type: SwitchParameter 1211 | Parameter Sets: (All) 1212 | Aliases: j 1213 | 1214 | Required: False 1215 | Position: Named 1216 | Default value: False 1217 | Accept pipeline input: False 1218 | Accept wildcard characters: False 1219 | ``` 1220 | 1221 | ### -Unicode 1222 | Displays the status output as Unicode text. 1223 | 1224 | ```yaml 1225 | Type: SwitchParameter 1226 | Parameter Sets: (All) 1227 | Aliases: 1228 | 1229 | Required: False 1230 | Position: Named 1231 | Default value: False 1232 | Accept pipeline input: False 1233 | Accept wildcard characters: False 1234 | ``` 1235 | 1236 | ### -UnicodeLog 1237 | Writes the status output to the log file as Unicode text (overwrites the existing log file). 1238 | 1239 | ```yaml 1240 | Type: String 1241 | Parameter Sets: (All) 1242 | Aliases: unilog 1243 | 1244 | Required: False 1245 | Position: 29 1246 | Default value: None 1247 | Accept pipeline input: False 1248 | Accept wildcard characters: False 1249 | ``` 1250 | 1251 | ### -UnicodeLogWithAppend 1252 | Writes the status output to the log file as Unicode text (appends the output to the existing log file). 1253 | 1254 | ```yaml 1255 | Type: String 1256 | Parameter Sets: (All) 1257 | Aliases: 1258 | 1259 | Required: False 1260 | Position: 30 1261 | Default value: None 1262 | Accept pipeline input: False 1263 | Accept wildcard characters: False 1264 | ``` 1265 | 1266 | ### -Unit 1267 | What unit the sizes are shown as 1268 | 1269 | ```yaml 1270 | Type: String 1271 | Parameter Sets: (All) 1272 | Aliases: 1273 | Accepted values: Auto, PB, TB, GB, MB, KB, Bytes 1274 | 1275 | Required: False 1276 | Position: 34 1277 | Default value: Auto 1278 | Accept pipeline input: False 1279 | Accept wildcard characters: False 1280 | ``` 1281 | 1282 | ### -UsePerFileRunTimes 1283 | Checks run times on a per-file (not per-pass) basis. 1284 | 1285 | ```yaml 1286 | Type: SwitchParameter 1287 | Parameter Sets: (All) 1288 | Aliases: pf 1289 | 1290 | Required: False 1291 | Position: Named 1292 | Default value: False 1293 | Accept pipeline input: False 1294 | Accept wildcard characters: False 1295 | ``` 1296 | 1297 | ### -Wait 1298 | Specifies the wait time between retries, in seconds. 1299 | The default value of N is 3. 1300 | 1301 | ```yaml 1302 | Type: Int32 1303 | Parameter Sets: (All) 1304 | Aliases: w 1305 | 1306 | Required: False 1307 | Position: 24 1308 | Default value: 3 1309 | Accept pipeline input: False 1310 | Accept wildcard characters: False 1311 | ``` 1312 | 1313 | ### -WaitForShareName 1314 | Specifies that the system will wait for share names to be defined (retry error 67). 1315 | 1316 | ```yaml 1317 | Type: SwitchParameter 1318 | Parameter Sets: (All) 1319 | Aliases: tbd 1320 | 1321 | Required: False 1322 | Position: Named 1323 | Default value: False 1324 | Accept pipeline input: False 1325 | Accept wildcard characters: False 1326 | ``` 1327 | 1328 | ### -WhatIf 1329 | Shows what would happen if the function runs. 1330 | The function is not run. 1331 | 1332 | ```yaml 1333 | Type: SwitchParameter 1334 | Parameter Sets: (All) 1335 | Aliases: wi 1336 | 1337 | Required: False 1338 | Position: Named 1339 | Default value: None 1340 | Accept pipeline input: False 1341 | Accept wildcard characters: False 1342 | ``` 1343 | 1344 | ### -Force 1345 | If destination folder does not exist the Force parameter will try and create it. 1346 | 1347 | ```yaml 1348 | Type: SwitchParameter 1349 | Parameter Sets: (All) 1350 | Aliases: 1351 | 1352 | Required: False 1353 | Position: Named 1354 | Default value: None 1355 | Accept pipeline input: False 1356 | Accept wildcard characters: False 1357 | ``` 1358 | 1359 | ### -Precision 1360 | Number of digits after decimal point in rounded numbers. 1361 | 1362 | ```yaml 1363 | Type: Int64 1364 | Parameter Sets: (All) 1365 | Aliases: 1366 | 1367 | Required: False 1368 | Position: Named 1369 | Default value: None 1370 | Accept pipeline input: False 1371 | Accept wildcard characters: False 1372 | ``` 1373 | 1374 | ### -IoMaxSize 1375 | Requested max i/o size per {read,write} cycle, in n [KMG] bytes. 1376 | 1377 | ```yaml 1378 | Type: String 1379 | Parameter Sets: (All) 1380 | Aliases: 1381 | 1382 | Required: False 1383 | Position: Named 1384 | Default value: None 1385 | Accept pipeline input: False 1386 | Accept wildcard characters: False 1387 | ``` 1388 | 1389 | ### -IoRate 1390 | Requested i/o rate, in n [KMG] bytes per second. 1391 | 1392 | ```yaml 1393 | Type: String 1394 | Parameter Sets: (All) 1395 | Aliases: 1396 | 1397 | Required: False 1398 | Position: Named 1399 | Default value: None 1400 | Accept pipeline input: False 1401 | Accept wildcard characters: False 1402 | ``` 1403 | 1404 | ### -Threshold 1405 | File size threshold for throttling, in n [KMG] bytes. 1406 | 1407 | ```yaml 1408 | Type: String 1409 | Parameter Sets: (All) 1410 | Aliases: 1411 | 1412 | Required: False 1413 | Position: Named 1414 | Default value: None 1415 | Accept pipeline input: False 1416 | Accept wildcard characters: False 1417 | ``` 1418 | 1419 | ### -OutputType 1420 | Choose if output from Robocopy.exe should be parsed or not. 1421 | 1422 | ```yaml 1423 | Type: Object 1424 | Parameter Sets: (All) 1425 | Aliases: 1426 | 1427 | Required: False 1428 | Position: Named 1429 | Default value: None 1430 | Accept pipeline input: False 1431 | Accept wildcard characters: False 1432 | ``` 1433 | 1434 | ### -Sparse 1435 | Enable retaining sparse state during copy. 1436 | 1437 | ```yaml 1438 | Type: SwitchParameter 1439 | Parameter Sets: (All) 1440 | Aliases: 1441 | 1442 | Required: False 1443 | Position: Named 1444 | Default value: None 1445 | Accept pipeline input: False 1446 | Accept wildcard characters: False 1447 | ``` 1448 | 1449 | ### CommonParameters 1450 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 1451 | 1452 | ## INPUTS 1453 | 1454 | ### System.String[] 1455 | 1456 | ### System.String 1457 | 1458 | ## OUTPUTS 1459 | 1460 | ### System.Object 1461 | ## NOTES 1462 | 1463 | ## RELATED LINKS 1464 | -------------------------------------------------------------------------------- /docs/Get-RoboItem.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: RobocopyPS-help.xml 3 | Module Name: RobocopyPS 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-RoboItem 9 | 10 | ## SYNOPSIS 11 | Get information about file or directories with Robocopy. 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Get-RoboItem [-Path] [[-Files] ] [-Recurse] [[-Level] ] [-RestartMode] 17 | [-BackupMode] [-RestartAndBackupMode] [-ExcludeFileName ] [-ExcludeDirectory ] 18 | [-Threads ] [-Unit ] [-Precision ] [-WhatIf] [-Confirm] [] 19 | ``` 20 | 21 | ## DESCRIPTION 22 | Get information like directory size or number of directories in any give location with the help of Robocopy. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | ```powershell 28 | PS C:\> Get-RoboItem -Path "E:\Anno 1800\" -Recurse 29 | 30 | Source : E:\Anno 1800\ 31 | Destination : C:\Users\simon\AppData\Local\Temp 32 | Command : Robocopy.exe "E:\Anno 1800" "C:\Users\simon\AppData\Local\Temp" *.* /r:3 /w:3 /e /l /bytes /TEE /np /njh /fp /ndl /ts 33 | DirCount : 18 34 | FileCount : 230 35 | DirCopied : 17 36 | FileCopied : 230 37 | DirIgnored : 1 38 | FileIgnored : 0 39 | DirMismatched : 0 40 | FileMismatched : 0 41 | DirFailed : 0 42 | FileFailed : 0 43 | DirExtra : 20 44 | FileExtra : 42 45 | TotalTime : 00:00:00 46 | StartedTime : 2021-08-20 16:30:07 47 | EndedTime : 2021-08-20 16:30:07 48 | TotalSize : 60 GB 49 | TotalSizeCopied : 60 GB 50 | TotalSizeIgnored : 0 B 51 | TotalSizeMismatched : 0 B 52 | TotalSizeFailed : 0 B 53 | TotalSizeExtra : 3,2 MB 54 | Speed : 0 B/s 55 | ExitCode : 3 56 | Success : True 57 | LastExitCodeMessage : Some files were copied. Additional files were present. No failure was encountered. 58 | ``` 59 | 60 | Get the number and size of files and subdirectories on location "E:\Anno 1800" 61 | 62 | ### Example 2: Multiple directories 63 | ```powershell 64 | Get-RoboItem -Path "E:\Anno 1800\","D:\tmp\" 65 | 66 | Source : E:\Anno 1800\ 67 | Destination : C:\Users\simon\AppData\Local\Temp 68 | Command : Robocopy.exe "E:\Anno 1800" "C:\Users\simon\AppData\Local\Temp" *.* /r:3 /w:3 /l /bytes /TEE /np /njh /fp /ndl /ts 69 | DirCount : 1 70 | FileCount : 2 71 | DirCopied : 0 72 | FileCopied : 2 73 | DirIgnored : 1 74 | FileIgnored : 0 75 | DirMismatched : 0 76 | FileMismatched : 0 77 | DirFailed : 0 78 | FileFailed : 0 79 | DirExtra : 22 80 | FileExtra : 45 81 | TotalTime : 00:00:00 82 | StartedTime : 2021-08-21 08:37:05 83 | EndedTime : 2021-08-21 08:37:05 84 | TotalSize : 1 MB 85 | TotalSizeCopied : 1 MB 86 | TotalSizeIgnored : 0 B 87 | TotalSizeMismatched : 0 B 88 | TotalSizeFailed : 0 B 89 | TotalSizeExtra : 1,1 MB 90 | Speed : 0 B/s 91 | ExitCode : 3 92 | Success : True 93 | LastExitCodeMessage : Some files were copied. Additional files were present. No failure was encountered. 94 | 95 | Source : D:\tmp\ 96 | Destination : C:\Users\simon\AppData\Local\Temp 97 | Command : Robocopy.exe "D:\tmp" "C:\Users\simon\AppData\Local\Temp" *.* /r:3 /w:3 /l /bytes /TEE /np /njh /fp /ndl /ts 98 | DirCount : 1 99 | FileCount : 5 100 | DirCopied : 0 101 | FileCopied : 5 102 | DirIgnored : 1 103 | FileIgnored : 0 104 | DirMismatched : 0 105 | FileMismatched : 0 106 | DirFailed : 0 107 | FileFailed : 0 108 | DirExtra : 21 109 | FileExtra : 45 110 | TotalTime : 00:00:00 111 | StartedTime : 2021-08-21 08:37:05 112 | EndedTime : 2021-08-21 08:37:05 113 | TotalSize : 17 KB 114 | TotalSizeCopied : 17 KB 115 | TotalSizeIgnored : 0 B 116 | TotalSizeMismatched : 0 B 117 | TotalSizeFailed : 0 B 118 | TotalSizeExtra : 1,1 MB 119 | Speed : 0 B/s 120 | ExitCode : 3 121 | Success : True 122 | LastExitCodeMessage : Some files were copied. Additional files were present. No failure was encountered. 123 | ``` 124 | 125 | Get Robocopy information about multiple directories. 126 | 127 | ### Example 3: Pipe from Get-Childitem 128 | ```powershell 129 | PS C:\> Get-ChildItem -Path 'E:\Anno 1800\' -Recurse -Directory -Depth 1 | Get-RoboItem -Unit MB -Recurse -RestartAndBackupMode | Out-GridView 130 | ``` 131 | 132 | Get information including directorys size of all subfolders for a folder in MB. 133 | 134 | ## PARAMETERS 135 | 136 | ### -BackupMode 137 | Get files in Backup mode. 138 | 139 | ```yaml 140 | Type: SwitchParameter 141 | Parameter Sets: (All) 142 | Aliases: b 143 | 144 | Required: False 145 | Position: Named 146 | Default value: None 147 | Accept pipeline input: False 148 | Accept wildcard characters: False 149 | ``` 150 | 151 | ### -Files 152 | Specifies the file or files. You can use wildcard characters (* or ?), if you want. If the File parameter is not specified, *.* is used as the default value. 153 | 154 | ```yaml 155 | Type: String[] 156 | Parameter Sets: (All) 157 | Aliases: 158 | 159 | Required: False 160 | Position: 1 161 | Default value: None 162 | Accept pipeline input: False 163 | Accept wildcard characters: False 164 | ``` 165 | 166 | ### -Level 167 | Get only the top N levels of the source directory tree. 168 | 169 | ```yaml 170 | Type: Int32 171 | Parameter Sets: (All) 172 | Aliases: lev, Depth 173 | 174 | Required: False 175 | Position: 2 176 | Default value: None 177 | Accept pipeline input: False 178 | Accept wildcard characters: False 179 | ``` 180 | 181 | ### -Path 182 | Path to directory. 183 | 184 | ```yaml 185 | Type: String[] 186 | Parameter Sets: (All) 187 | Aliases: FullPath 188 | 189 | Required: True 190 | Position: 0 191 | Default value: None 192 | Accept pipeline input: True (ByPropertyName, ByValue) 193 | Accept wildcard characters: False 194 | ``` 195 | 196 | ### -Recurse 197 | Includes subdirectories and files. 198 | 199 | ```yaml 200 | Type: SwitchParameter 201 | Parameter Sets: (All) 202 | Aliases: 203 | 204 | Required: False 205 | Position: Named 206 | Default value: None 207 | Accept pipeline input: False 208 | Accept wildcard characters: False 209 | ``` 210 | 211 | ### -RestartAndBackupMode 212 | Get files in restartable mode. If file access is denied, switches to backup mode. 213 | 214 | ```yaml 215 | Type: SwitchParameter 216 | Parameter Sets: (All) 217 | Aliases: zb 218 | 219 | Required: False 220 | Position: Named 221 | Default value: None 222 | Accept pipeline input: False 223 | Accept wildcard characters: False 224 | ``` 225 | 226 | ### -RestartMode 227 | Get files in restartable mode. 228 | 229 | ```yaml 230 | Type: SwitchParameter 231 | Parameter Sets: (All) 232 | Aliases: z 233 | 234 | Required: False 235 | Position: Named 236 | Default value: None 237 | Accept pipeline input: False 238 | Accept wildcard characters: False 239 | ``` 240 | 241 | ### -Confirm 242 | Prompts you for confirmation before running the cmdlet. 243 | 244 | ```yaml 245 | Type: SwitchParameter 246 | Parameter Sets: (All) 247 | Aliases: cf 248 | 249 | Required: False 250 | Position: Named 251 | Default value: None 252 | Accept pipeline input: False 253 | Accept wildcard characters: False 254 | ``` 255 | 256 | ### -Unit 257 | What unit the sizes are shown as 258 | 259 | ```yaml 260 | Type: String 261 | Parameter Sets: (All) 262 | Aliases: 263 | 264 | Required: False 265 | Position: Named 266 | Default value: None 267 | Accept pipeline input: False 268 | Accept wildcard characters: False 269 | ``` 270 | 271 | ### -WhatIf 272 | Shows what would happen if the cmdlet runs. The cmdlet is not run. 273 | 274 | ```yaml 275 | Type: SwitchParameter 276 | Parameter Sets: (All) 277 | Aliases: wi 278 | 279 | Required: False 280 | Position: Named 281 | Default value: None 282 | Accept pipeline input: False 283 | Accept wildcard characters: False 284 | ``` 285 | 286 | ### -ExcludeDirectory 287 | Excludes directories that match the specified names and paths. 288 | 289 | ```yaml 290 | Type: String[] 291 | Parameter Sets: (All) 292 | Aliases: xd 293 | 294 | Required: False 295 | Position: Named 296 | Default value: None 297 | Accept pipeline input: False 298 | Accept wildcard characters: False 299 | ``` 300 | 301 | ### -ExcludeFileName 302 | Excludes files that match the specified names or paths. 303 | Note that FileName can include wildcard characters (* and ?). 304 | 305 | ```yaml 306 | Type: String[] 307 | Parameter Sets: (All) 308 | Aliases: xf 309 | 310 | Required: False 311 | Position: Named 312 | Default value: None 313 | Accept pipeline input: False 314 | Accept wildcard characters: False 315 | ``` 316 | 317 | ### -Threads 318 | Creates multi-threaded copies with N threads. 319 | N must be an integer between 1 and 128. 320 | Cannot be used with the InterPacketGap and EFSRAW parameters. 321 | The /MT parameter applies to Windows Server 2008 R2 and Windows 7. 322 | 323 | ```yaml 324 | Type: Int32 325 | Parameter Sets: (All) 326 | Aliases: MT, MultiThread 327 | 328 | Required: False 329 | Position: Named 330 | Default value: None 331 | Accept pipeline input: False 332 | Accept wildcard characters: False 333 | ``` 334 | 335 | ### -Precision 336 | Number of digits after decimal point in rounded numbers. 337 | 338 | ```yaml 339 | Type: Int64 340 | Parameter Sets: (All) 341 | Aliases: 342 | 343 | Required: False 344 | Position: Named 345 | Default value: None 346 | Accept pipeline input: False 347 | Accept wildcard characters: False 348 | ``` 349 | 350 | ### CommonParameters 351 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 352 | 353 | ## INPUTS 354 | 355 | ### System.Object 356 | 357 | ## OUTPUTS 358 | 359 | ### System.Object 360 | ## NOTES 361 | 362 | ## RELATED LINKS 363 | -------------------------------------------------------------------------------- /docs/Move-RoboItem.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: RobocopyPS-help.xml 3 | Module Name: RobocopyPS 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Move-RoboItem 9 | 10 | ## SYNOPSIS 11 | Move directory with Robocopy. 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Move-RoboItem [-WhatIf] [-Confirm] [-Source] [-Destination] [[-Files] ] [-Force] 17 | [-IncludeSubDirectories] [-IncludeEmptySubDirectories] [[-Level] ] [-RestartMode] [-BackupMode] 18 | [-RestartAndBackupMode] [-UnbufferedIO] [-EFSRaw] [[-CopyFlags] ] [[-DirectoryCopyFlags] ] 19 | [-CopyWithSecurity] [-CopyAllFileInformation] [-NoCopy] [-SecurityFix] [-Timefix] [-Purge] 20 | [[-AddAttribute] ] [[-RemoveAttribute] ] [-Create] [-FAT] [-IgnoreLongPath] 21 | [[-MonitorChanges] ] [[-MonitorMinutes] ] [[-Threads] ] [[-RunTimes] ] 22 | [-UsePerFileRunTimes] [[-InterPacketGap] ] [-CopyJunction] [-SymbolicLink] [-NoDirectoryInformation] 23 | [-NoOffload] [-Compress] [-Sparse] [-IoMaxSize ] [-IoRate ] [-Threshold ] [-Archive] 24 | [-ResetArchiveAttribute] [[-IncludeAttribute] ] [[-ExcludeAttribute] ] 25 | [[-ExcludeFileName] ] [[-ExcludeDirectory] ] [-ExcludeChangedFiles] [-ExcludeNewerFiles] 26 | [-ExcludeOlderFiles] [-ExcludeExtraFiles] [-ExcludeLonelyFiles] [-IncludeModifiedFile] [-IncludeSameFiles] 27 | [-IncludeTweakedFiles] [[-MaximumFileSize] ] [[-MinimumFileSize] ] 28 | [[-MaximumFileAge] ] [[-MinimumFileAge] ] [[-MaximumFileLastAccessDate] ] 29 | [[-MinimumFileLastAccessDate] ] [-ExcludeJunctionPoints] [-AssumeFATFileTime] [-CompensateDST] 30 | [-ExcludeDirectoryJunctionPoints] [-ExcludeFileJunctionPoints] [[-Retry] ] [[-Wait] ] 31 | [-SaveRetrySettings] [-WaitForShareName] [-LowFreeSpaceMode] [[-LowFreeSpaceModeValue] ] [-List] 32 | [-ReportExtraFile] [-NoSizeToLog] [-NoClassToLog] [[-NoFileNameToLog] ] [[-LogFile] ] 33 | [[-LogFileWithAppend] ] [-Unicode] [[-UnicodeLog] ] [[-UnicodeLogWithAppend] ] 34 | [[-JobName] ] [[-SaveJob] ] [-Quit] [-NoSourceDirectory] [-NoDestinationDirectory] 35 | [[-IncludeFollowingFile] ] [[-Unit] ] [-Precision ] [-OutputType ] 36 | [] 37 | ``` 38 | 39 | ## DESCRIPTION 40 | A simplified cmdlet for moving directories with help from Invoke-Robocopy. 41 | 42 | ## EXAMPLES 43 | 44 | ### Example 1 45 | ```powershell 46 | PS C:\> Move-RoboItem -Source D:\tmp\from\ -Destination D:\tmp\to 47 | ``` 48 | 49 | Move D:\tmp\from to destination D:\tmp\to. 50 | 51 | ## PARAMETERS 52 | 53 | ### -AddAttribute 54 | Adds the specified attributes to copied files. 55 | 56 | ```yaml 57 | Type: String[] 58 | Parameter Sets: (All) 59 | Aliases: 60 | Accepted values: R, A, S, H, C, N, E, T 61 | 62 | Required: False 63 | Position: 6 64 | Default value: None 65 | Accept pipeline input: False 66 | Accept wildcard characters: False 67 | ``` 68 | 69 | ### -Archive 70 | Copies only files for which the Archive attribute is set. 71 | 72 | ```yaml 73 | Type: SwitchParameter 74 | Parameter Sets: (All) 75 | Aliases: a 76 | 77 | Required: False 78 | Position: Named 79 | Default value: False 80 | Accept pipeline input: False 81 | Accept wildcard characters: False 82 | ``` 83 | 84 | ### -AssumeFATFileTime 85 | Assumes FAT file times (two-second precision). 86 | 87 | ```yaml 88 | Type: SwitchParameter 89 | Parameter Sets: (All) 90 | Aliases: fft 91 | 92 | Required: False 93 | Position: Named 94 | Default value: False 95 | Accept pipeline input: False 96 | Accept wildcard characters: False 97 | ``` 98 | 99 | ### -BackupMode 100 | Copies files in Backup mode. 101 | 102 | ```yaml 103 | Type: SwitchParameter 104 | Parameter Sets: (All) 105 | Aliases: b 106 | 107 | Required: False 108 | Position: Named 109 | Default value: False 110 | Accept pipeline input: False 111 | Accept wildcard characters: False 112 | ``` 113 | 114 | ### -CompensateDST 115 | Compensates for one-hour DST time differences. 116 | 117 | ```yaml 118 | Type: SwitchParameter 119 | Parameter Sets: (All) 120 | Aliases: dst 121 | 122 | Required: False 123 | Position: Named 124 | Default value: False 125 | Accept pipeline input: False 126 | Accept wildcard characters: False 127 | ``` 128 | 129 | ### -Compress 130 | Requests network compression during file transfer, if applicable. 131 | 132 | ```yaml 133 | Type: SwitchParameter 134 | Parameter Sets: (All) 135 | Aliases: 136 | 137 | Required: False 138 | Position: Named 139 | Default value: False 140 | Accept pipeline input: False 141 | Accept wildcard characters: False 142 | ``` 143 | 144 | ### -CopyAllFileInformation 145 | Copies all file information (equivalent to /copy:DATSOU). 146 | 147 | ```yaml 148 | Type: SwitchParameter 149 | Parameter Sets: (All) 150 | Aliases: copyall 151 | 152 | Required: False 153 | Position: Named 154 | Default value: False 155 | Accept pipeline input: False 156 | Accept wildcard characters: False 157 | ``` 158 | 159 | ### -CopyFlags 160 | Specifies the file properties to be copied. 161 | The default value for CopyFlags is DAT (data, attributes, and time stamps). 162 | D = Data. 163 | A = Attributes. 164 | T = Time stamps.S = NTFS access control list (ACL). 165 | O =Owner information. 166 | U = Auditing information 167 | 168 | ```yaml 169 | Type: String[] 170 | Parameter Sets: (All) 171 | Aliases: copy 172 | Accepted values: D, A, T, S, O, U 173 | 174 | Required: False 175 | Position: 4 176 | Default value: None 177 | Accept pipeline input: False 178 | Accept wildcard characters: False 179 | ``` 180 | 181 | ### -CopyJunction 182 | Copy Junctions as junctions instead of as the junction targets. 183 | 184 | ```yaml 185 | Type: SwitchParameter 186 | Parameter Sets: (All) 187 | Aliases: sj 188 | 189 | Required: False 190 | Position: Named 191 | Default value: False 192 | Accept pipeline input: False 193 | Accept wildcard characters: False 194 | ``` 195 | 196 | ### -CopyWithSecurity 197 | Copies files with security (equivalent to /copy:DATS). 198 | 199 | ```yaml 200 | Type: SwitchParameter 201 | Parameter Sets: (All) 202 | Aliases: sec 203 | 204 | Required: False 205 | Position: Named 206 | Default value: False 207 | Accept pipeline input: False 208 | Accept wildcard characters: False 209 | ``` 210 | 211 | ### -Create 212 | Creates a directory tree and zero-length files only. 213 | 214 | ```yaml 215 | Type: SwitchParameter 216 | Parameter Sets: (All) 217 | Aliases: 218 | 219 | Required: False 220 | Position: Named 221 | Default value: False 222 | Accept pipeline input: False 223 | Accept wildcard characters: False 224 | ``` 225 | 226 | ### -Destination 227 | Specifies the path to the destination directory. 228 | Must be a folder. 229 | 230 | ```yaml 231 | Type: String 232 | Parameter Sets: (All) 233 | Aliases: Target 234 | 235 | Required: True 236 | Position: 1 237 | Default value: None 238 | Accept pipeline input: True (ByPropertyName, ByValue) 239 | Accept wildcard characters: False 240 | ``` 241 | 242 | ### -DirectoryCopyFlags 243 | Specifies what to copy in directories. 244 | The valid values for this option are:D - Data, A - Attributes, T - Time stamps. 245 | The default value for this option is DA (data and attributes). 246 | 247 | ```yaml 248 | Type: String[] 249 | Parameter Sets: (All) 250 | Aliases: dcopy 251 | Accepted values: D, A, T 252 | 253 | Required: False 254 | Position: 5 255 | Default value: None 256 | Accept pipeline input: False 257 | Accept wildcard characters: False 258 | ``` 259 | 260 | ### -EFSRaw 261 | Copies all encrypted files in EFS RAW mode. 262 | 263 | ```yaml 264 | Type: SwitchParameter 265 | Parameter Sets: (All) 266 | Aliases: 267 | 268 | Required: False 269 | Position: Named 270 | Default value: False 271 | Accept pipeline input: False 272 | Accept wildcard characters: False 273 | ``` 274 | 275 | ### -ExcludeAttribute 276 | Excludes files for which any of the specified attributes are set. 277 | 278 | ```yaml 279 | Type: String[] 280 | Parameter Sets: (All) 281 | Aliases: xa 282 | Accepted values: R, A, S, C, H, N, E, T, O 283 | 284 | Required: False 285 | Position: 14 286 | Default value: None 287 | Accept pipeline input: False 288 | Accept wildcard characters: False 289 | ``` 290 | 291 | ### -ExcludeChangedFiles 292 | Excludes changed files. 293 | 294 | ```yaml 295 | Type: SwitchParameter 296 | Parameter Sets: (All) 297 | Aliases: xc 298 | 299 | Required: False 300 | Position: Named 301 | Default value: False 302 | Accept pipeline input: False 303 | Accept wildcard characters: False 304 | ``` 305 | 306 | ### -ExcludeDirectory 307 | Excludes directories that match the specified names and paths. 308 | 309 | ```yaml 310 | Type: String[] 311 | Parameter Sets: (All) 312 | Aliases: xd 313 | 314 | Required: False 315 | Position: 16 316 | Default value: None 317 | Accept pipeline input: False 318 | Accept wildcard characters: False 319 | ``` 320 | 321 | ### -ExcludeDirectoryJunctionPoints 322 | Excludes junction points for directories. 323 | 324 | ```yaml 325 | Type: SwitchParameter 326 | Parameter Sets: (All) 327 | Aliases: xjd 328 | 329 | Required: False 330 | Position: Named 331 | Default value: False 332 | Accept pipeline input: False 333 | Accept wildcard characters: False 334 | ``` 335 | 336 | ### -ExcludeExtraFiles 337 | Excludes extra files and directories. 338 | 339 | ```yaml 340 | Type: SwitchParameter 341 | Parameter Sets: (All) 342 | Aliases: xx 343 | 344 | Required: False 345 | Position: Named 346 | Default value: False 347 | Accept pipeline input: False 348 | Accept wildcard characters: False 349 | ``` 350 | 351 | ### -ExcludeFileJunctionPoints 352 | Excludes junction points for files. 353 | 354 | ```yaml 355 | Type: SwitchParameter 356 | Parameter Sets: (All) 357 | Aliases: xjf 358 | 359 | Required: False 360 | Position: Named 361 | Default value: False 362 | Accept pipeline input: False 363 | Accept wildcard characters: False 364 | ``` 365 | 366 | ### -ExcludeFileName 367 | Excludes files that match the specified names or paths. 368 | Note that FileName can include wildcard characters (* and ?). 369 | 370 | ```yaml 371 | Type: String[] 372 | Parameter Sets: (All) 373 | Aliases: xf 374 | 375 | Required: False 376 | Position: 15 377 | Default value: None 378 | Accept pipeline input: False 379 | Accept wildcard characters: False 380 | ``` 381 | 382 | ### -ExcludeJunctionPoints 383 | Excludes junction points, which are normally included by default. 384 | 385 | ```yaml 386 | Type: SwitchParameter 387 | Parameter Sets: (All) 388 | Aliases: xj 389 | 390 | Required: False 391 | Position: Named 392 | Default value: False 393 | Accept pipeline input: False 394 | Accept wildcard characters: False 395 | ``` 396 | 397 | ### -ExcludeLonelyFiles 398 | Excludes "lonely" files and directories. 399 | 400 | ```yaml 401 | Type: SwitchParameter 402 | Parameter Sets: (All) 403 | Aliases: xl 404 | 405 | Required: False 406 | Position: Named 407 | Default value: False 408 | Accept pipeline input: False 409 | Accept wildcard characters: False 410 | ``` 411 | 412 | ### -ExcludeNewerFiles 413 | Excludes newer files. 414 | 415 | ```yaml 416 | Type: SwitchParameter 417 | Parameter Sets: (All) 418 | Aliases: xn 419 | 420 | Required: False 421 | Position: Named 422 | Default value: False 423 | Accept pipeline input: False 424 | Accept wildcard characters: False 425 | ``` 426 | 427 | ### -ExcludeOlderFiles 428 | Excludes older files. 429 | 430 | ```yaml 431 | Type: SwitchParameter 432 | Parameter Sets: (All) 433 | Aliases: xo 434 | 435 | Required: False 436 | Position: Named 437 | Default value: False 438 | Accept pipeline input: False 439 | Accept wildcard characters: False 440 | ``` 441 | 442 | ### -FAT 443 | Creates destination files by using 8.3 character-length FAT file names only. 444 | 445 | ```yaml 446 | Type: SwitchParameter 447 | Parameter Sets: (All) 448 | Aliases: 449 | 450 | Required: False 451 | Position: Named 452 | Default value: False 453 | Accept pipeline input: False 454 | Accept wildcard characters: False 455 | ``` 456 | 457 | ### -Files 458 | Specifies the file or files to be copied. 459 | You can use wildcard characters (* or ?), if you want. 460 | If the File parameter is not specified, *.* is used as the default value. 461 | 462 | ```yaml 463 | Type: String[] 464 | Parameter Sets: (All) 465 | Aliases: File 466 | 467 | Required: False 468 | Position: 2 469 | Default value: *.* 470 | Accept pipeline input: False 471 | Accept wildcard characters: False 472 | ``` 473 | 474 | ### -IgnoreLongPath 475 | Turns off support for very long paths. 476 | 477 | ```yaml 478 | Type: SwitchParameter 479 | Parameter Sets: (All) 480 | Aliases: 256 481 | 482 | Required: False 483 | Position: Named 484 | Default value: False 485 | Accept pipeline input: False 486 | Accept wildcard characters: False 487 | ``` 488 | 489 | ### -IncludeAttribute 490 | Includes only files for which any of the specified attributes are set. 491 | 492 | ```yaml 493 | Type: String[] 494 | Parameter Sets: (All) 495 | Aliases: ia 496 | Accepted values: R, A, S, C, H, N, E, T, O 497 | 498 | Required: False 499 | Position: 13 500 | Default value: None 501 | Accept pipeline input: False 502 | Accept wildcard characters: False 503 | ``` 504 | 505 | ### -IncludeEmptySubDirectories 506 | Copies subdirectories. 507 | Note that this option includes empty directories. 508 | 509 | ```yaml 510 | Type: SwitchParameter 511 | Parameter Sets: (All) 512 | Aliases: e, Recurse 513 | 514 | Required: False 515 | Position: Named 516 | Default value: False 517 | Accept pipeline input: False 518 | Accept wildcard characters: False 519 | ``` 520 | 521 | ### -IncludeFollowingFile 522 | Include the following Files. 523 | 524 | ```yaml 525 | Type: String 526 | Parameter Sets: (All) 527 | Aliases: IF 528 | 529 | Required: False 530 | Position: 33 531 | Default value: None 532 | Accept pipeline input: False 533 | Accept wildcard characters: False 534 | ``` 535 | 536 | ### -IncludeModifiedFile 537 | Include modified files (differing change times). 538 | 539 | ```yaml 540 | Type: SwitchParameter 541 | Parameter Sets: (All) 542 | Aliases: im 543 | 544 | Required: False 545 | Position: Named 546 | Default value: False 547 | Accept pipeline input: False 548 | Accept wildcard characters: False 549 | ``` 550 | 551 | ### -IncludeSameFiles 552 | Includes the same files. 553 | 554 | ```yaml 555 | Type: SwitchParameter 556 | Parameter Sets: (All) 557 | Aliases: is 558 | 559 | Required: False 560 | Position: Named 561 | Default value: False 562 | Accept pipeline input: False 563 | Accept wildcard characters: False 564 | ``` 565 | 566 | ### -IncludeSubDirectories 567 | Copies subdirectories. 568 | Note that this option excludes empty directories. 569 | 570 | ```yaml 571 | Type: SwitchParameter 572 | Parameter Sets: (All) 573 | Aliases: s 574 | 575 | Required: False 576 | Position: Named 577 | Default value: False 578 | Accept pipeline input: False 579 | Accept wildcard characters: False 580 | ``` 581 | 582 | ### -IncludeTweakedFiles 583 | Includes "tweaked" files. 584 | 585 | ```yaml 586 | Type: SwitchParameter 587 | Parameter Sets: (All) 588 | Aliases: it 589 | 590 | Required: False 591 | Position: Named 592 | Default value: False 593 | Accept pipeline input: False 594 | Accept wildcard characters: False 595 | ``` 596 | 597 | ### -InterPacketGap 598 | Specifies the inter-packet gap to free bandwidth on slow lines. 599 | 600 | ```yaml 601 | Type: Int32 602 | Parameter Sets: (All) 603 | Aliases: ipg 604 | 605 | Required: False 606 | Position: 12 607 | Default value: 0 608 | Accept pipeline input: False 609 | Accept wildcard characters: False 610 | ``` 611 | 612 | ### -JobName 613 | Specifies that parameters are to be derived from the named job file. 614 | 615 | ```yaml 616 | Type: String 617 | Parameter Sets: (All) 618 | Aliases: Job 619 | 620 | Required: False 621 | Position: 31 622 | Default value: None 623 | Accept pipeline input: False 624 | Accept wildcard characters: False 625 | ``` 626 | 627 | ### -Level 628 | Copies only the top N levels of the source directory tree. 629 | 630 | ```yaml 631 | Type: Int32 632 | Parameter Sets: (All) 633 | Aliases: lev, Depth 634 | 635 | Required: False 636 | Position: 3 637 | Default value: 0 638 | Accept pipeline input: False 639 | Accept wildcard characters: False 640 | ``` 641 | 642 | ### -List 643 | Specifies that files are to be listed only (and not copied, deleted, or time stamped). 644 | 645 | ```yaml 646 | Type: SwitchParameter 647 | Parameter Sets: (All) 648 | Aliases: l 649 | 650 | Required: False 651 | Position: Named 652 | Default value: False 653 | Accept pipeline input: False 654 | Accept wildcard characters: False 655 | ``` 656 | 657 | ### -LogFile 658 | Writes the status output to the log file (overwrites the existing log file). 659 | 660 | ```yaml 661 | Type: String 662 | Parameter Sets: (All) 663 | Aliases: log 664 | 665 | Required: False 666 | Position: 27 667 | Default value: None 668 | Accept pipeline input: False 669 | Accept wildcard characters: False 670 | ``` 671 | 672 | ### -LogFileWithAppend 673 | Writes the status output to the log file (appends the output to the existing log file). 674 | 675 | ```yaml 676 | Type: String 677 | Parameter Sets: (All) 678 | Aliases: 679 | 680 | Required: False 681 | Position: 28 682 | Default value: None 683 | Accept pipeline input: False 684 | Accept wildcard characters: False 685 | ``` 686 | 687 | ### -LowFreeSpaceMode 688 | Using /LFSM requests robocopy to operate in 'low free space mode'. 689 | In that mode, robocopy will pause whenever a file copy would cause the destination volume's free space to go below ten percent of the destination volume's size. 690 | 691 | ```yaml 692 | Type: SwitchParameter 693 | Parameter Sets: (All) 694 | Aliases: lfsm 695 | 696 | Required: False 697 | Position: Named 698 | Default value: False 699 | Accept pipeline input: False 700 | Accept wildcard characters: False 701 | ``` 702 | 703 | ### -LowFreeSpaceModeValue 704 | Using /LFSM requests robocopy to operate in 'low free space mode'. 705 | In that mode, robocopy will pause whenever a file copy would cause the destination volume's free space to go below a 'floor' value, which can be explicitly specified by the n\[KMG\] form of the flag where n=number and K:kilobytes ,M:megabytes or G:gigabytes. 706 | 707 | ```yaml 708 | Type: String 709 | Parameter Sets: (All) 710 | Aliases: 711 | 712 | Required: False 713 | Position: 25 714 | Default value: None 715 | Accept pipeline input: False 716 | Accept wildcard characters: False 717 | ``` 718 | 719 | ### -MaximumFileAge 720 | Specifies the maximum file age (to exclude files older than N days or date). 721 | 722 | ```yaml 723 | Type: String 724 | Parameter Sets: (All) 725 | Aliases: maxage 726 | 727 | Required: False 728 | Position: 19 729 | Default value: None 730 | Accept pipeline input: False 731 | Accept wildcard characters: False 732 | ``` 733 | 734 | ### -MaximumFileLastAccessDate 735 | Specifies the maximum last access date (excludes files unused since N). 736 | 737 | ```yaml 738 | Type: String 739 | Parameter Sets: (All) 740 | Aliases: maxlad 741 | 742 | Required: False 743 | Position: 21 744 | Default value: None 745 | Accept pipeline input: False 746 | Accept wildcard characters: False 747 | ``` 748 | 749 | ### -MaximumFileSize 750 | Specifies the maximum file size (to exclude files bigger than N bytes). 751 | 752 | ```yaml 753 | Type: String 754 | Parameter Sets: (All) 755 | Aliases: max 756 | 757 | Required: False 758 | Position: 17 759 | Default value: None 760 | Accept pipeline input: False 761 | Accept wildcard characters: False 762 | ``` 763 | 764 | ### -MinimumFileAge 765 | Specifies the minimum file age (exclude files newer than N days or date). 766 | 767 | ```yaml 768 | Type: String 769 | Parameter Sets: (All) 770 | Aliases: minage 771 | 772 | Required: False 773 | Position: 20 774 | Default value: None 775 | Accept pipeline input: False 776 | Accept wildcard characters: False 777 | ``` 778 | 779 | ### -MinimumFileLastAccessDate 780 | Specifies the minimum last access date (excludes files used since N) If N is less than 1900, N specifies the number of days. 781 | Otherwise, N specifies a date in the format YYYYMMDD. 782 | 783 | ```yaml 784 | Type: String 785 | Parameter Sets: (All) 786 | Aliases: minlad 787 | 788 | Required: False 789 | Position: 22 790 | Default value: None 791 | Accept pipeline input: False 792 | Accept wildcard characters: False 793 | ``` 794 | 795 | ### -MinimumFileSize 796 | Specifies the minimum file size (to exclude files smaller than N bytes). 797 | 798 | ```yaml 799 | Type: String 800 | Parameter Sets: (All) 801 | Aliases: min 802 | 803 | Required: False 804 | Position: 18 805 | Default value: None 806 | Accept pipeline input: False 807 | Accept wildcard characters: False 808 | ``` 809 | 810 | ### -MonitorChanges 811 | Monitors the source, and runs again when more than N changes are detected. 812 | 813 | ```yaml 814 | Type: Int32 815 | Parameter Sets: (All) 816 | Aliases: mon 817 | 818 | Required: False 819 | Position: 8 820 | Default value: 0 821 | Accept pipeline input: False 822 | Accept wildcard characters: False 823 | ``` 824 | 825 | ### -MonitorMinutes 826 | Monitors source, and runs again in M minutes if changes are detected. 827 | 828 | ```yaml 829 | Type: Int32 830 | Parameter Sets: (All) 831 | Aliases: mot 832 | 833 | Required: False 834 | Position: 9 835 | Default value: 0 836 | Accept pipeline input: False 837 | Accept wildcard characters: False 838 | ``` 839 | 840 | ### -NoClassToLog 841 | Specifies that file sizes are not to be logged. 842 | 843 | ```yaml 844 | Type: SwitchParameter 845 | Parameter Sets: (All) 846 | Aliases: nc 847 | 848 | Required: False 849 | Position: Named 850 | Default value: False 851 | Accept pipeline input: False 852 | Accept wildcard characters: False 853 | ``` 854 | 855 | ### -NoCopy 856 | Copies no file information. 857 | 858 | ```yaml 859 | Type: SwitchParameter 860 | Parameter Sets: (All) 861 | Aliases: 862 | 863 | Required: False 864 | Position: Named 865 | Default value: False 866 | Accept pipeline input: False 867 | Accept wildcard characters: False 868 | ``` 869 | 870 | ### -NoDestinationDirectory 871 | NO Destination Directory is specified. 872 | 873 | ```yaml 874 | Type: SwitchParameter 875 | Parameter Sets: (All) 876 | Aliases: NODD 877 | 878 | Required: False 879 | Position: Named 880 | Default value: False 881 | Accept pipeline input: False 882 | Accept wildcard characters: False 883 | ``` 884 | 885 | ### -NoDirectoryInformation 886 | Copies no directory info (the default /dcopy:DA is done). 887 | 888 | ```yaml 889 | Type: SwitchParameter 890 | Parameter Sets: (All) 891 | Aliases: nodcopy 892 | 893 | Required: False 894 | Position: Named 895 | Default value: False 896 | Accept pipeline input: False 897 | Accept wildcard characters: False 898 | ``` 899 | 900 | ### -NoFileNameToLog 901 | Specifies that file names are not to be logged. 902 | 903 | ```yaml 904 | Type: Object 905 | Parameter Sets: (All) 906 | Aliases: nfl 907 | 908 | Required: False 909 | Position: 26 910 | Default value: None 911 | Accept pipeline input: False 912 | Accept wildcard characters: False 913 | ``` 914 | 915 | ### -NoOffload 916 | Copies files without using the Windows Copy Offload mechanism. 917 | 918 | ```yaml 919 | Type: SwitchParameter 920 | Parameter Sets: (All) 921 | Aliases: 922 | 923 | Required: False 924 | Position: Named 925 | Default value: False 926 | Accept pipeline input: False 927 | Accept wildcard characters: False 928 | ``` 929 | 930 | ### -NoSizeToLog 931 | Specifies that file sizes are not to be logged. 932 | 933 | ```yaml 934 | Type: SwitchParameter 935 | Parameter Sets: (All) 936 | Aliases: ns 937 | 938 | Required: False 939 | Position: Named 940 | Default value: False 941 | Accept pipeline input: False 942 | Accept wildcard characters: False 943 | ``` 944 | 945 | ### -NoSourceDirectory 946 | NO Source Directory is specified. 947 | 948 | ```yaml 949 | Type: SwitchParameter 950 | Parameter Sets: (All) 951 | Aliases: NOSD 952 | 953 | Required: False 954 | Position: Named 955 | Default value: False 956 | Accept pipeline input: False 957 | Accept wildcard characters: False 958 | ``` 959 | 960 | ### -Purge 961 | Deletes destination files and directories that no longer exist in the source. 962 | 963 | ```yaml 964 | Type: SwitchParameter 965 | Parameter Sets: (All) 966 | Aliases: 967 | 968 | Required: False 969 | Position: Named 970 | Default value: False 971 | Accept pipeline input: False 972 | Accept wildcard characters: False 973 | ``` 974 | 975 | ### -Quit 976 | Quits after processing command line to view parameters. 977 | 978 | ```yaml 979 | Type: SwitchParameter 980 | Parameter Sets: (All) 981 | Aliases: 982 | 983 | Required: False 984 | Position: Named 985 | Default value: False 986 | Accept pipeline input: False 987 | Accept wildcard characters: False 988 | ``` 989 | 990 | ### -RemoveAttribute 991 | Removes the specified attributes from copied files. 992 | 993 | ```yaml 994 | Type: String[] 995 | Parameter Sets: (All) 996 | Aliases: 997 | Accepted values: R, A, S, H, C, N, E, T 998 | 999 | Required: False 1000 | Position: 7 1001 | Default value: None 1002 | Accept pipeline input: False 1003 | Accept wildcard characters: False 1004 | ``` 1005 | 1006 | ### -ReportExtraFile 1007 | Report all eXtra files, not just those selected & copied. 1008 | 1009 | ```yaml 1010 | Type: SwitchParameter 1011 | Parameter Sets: (All) 1012 | Aliases: x 1013 | 1014 | Required: False 1015 | Position: Named 1016 | Default value: False 1017 | Accept pipeline input: False 1018 | Accept wildcard characters: False 1019 | ``` 1020 | 1021 | ### -ResetArchiveAttribute 1022 | Copies only files for which the Archive attribute is set, and resets the Archive attribute. 1023 | 1024 | ```yaml 1025 | Type: SwitchParameter 1026 | Parameter Sets: (All) 1027 | Aliases: m 1028 | 1029 | Required: False 1030 | Position: Named 1031 | Default value: False 1032 | Accept pipeline input: False 1033 | Accept wildcard characters: False 1034 | ``` 1035 | 1036 | ### -RestartAndBackupMode 1037 | Copies files in restartable mode. 1038 | If file access is denied, switches to backup mode. 1039 | 1040 | ```yaml 1041 | Type: SwitchParameter 1042 | Parameter Sets: (All) 1043 | Aliases: zb 1044 | 1045 | Required: False 1046 | Position: Named 1047 | Default value: False 1048 | Accept pipeline input: False 1049 | Accept wildcard characters: False 1050 | ``` 1051 | 1052 | ### -RestartMode 1053 | Copies files in restartable mode. 1054 | 1055 | ```yaml 1056 | Type: SwitchParameter 1057 | Parameter Sets: (All) 1058 | Aliases: z 1059 | 1060 | Required: False 1061 | Position: Named 1062 | Default value: False 1063 | Accept pipeline input: False 1064 | Accept wildcard characters: False 1065 | ``` 1066 | 1067 | ### -Retry 1068 | Specifies the number of retries on failed copies. 1069 | Default is 3. 1070 | 1071 | ```yaml 1072 | Type: Int32 1073 | Parameter Sets: (All) 1074 | Aliases: r 1075 | 1076 | Required: False 1077 | Position: 23 1078 | Default value: 3 1079 | Accept pipeline input: False 1080 | Accept wildcard characters: False 1081 | ``` 1082 | 1083 | ### -RunTimes 1084 | Specifies run times when new copies may be started. 1085 | 1086 | ```yaml 1087 | Type: String 1088 | Parameter Sets: (All) 1089 | Aliases: rh 1090 | 1091 | Required: False 1092 | Position: 11 1093 | Default value: None 1094 | Accept pipeline input: False 1095 | Accept wildcard characters: False 1096 | ``` 1097 | 1098 | ### -SaveJob 1099 | Specifies that parameters are to be saved to the named job file. 1100 | 1101 | ```yaml 1102 | Type: String 1103 | Parameter Sets: (All) 1104 | Aliases: Save 1105 | 1106 | Required: False 1107 | Position: 32 1108 | Default value: None 1109 | Accept pipeline input: False 1110 | Accept wildcard characters: False 1111 | ``` 1112 | 1113 | ### -SaveRetrySettings 1114 | Saves the values specified in the /r and /w options as default settings in the registry. 1115 | 1116 | ```yaml 1117 | Type: SwitchParameter 1118 | Parameter Sets: (All) 1119 | Aliases: reg 1120 | 1121 | Required: False 1122 | Position: Named 1123 | Default value: False 1124 | Accept pipeline input: False 1125 | Accept wildcard characters: False 1126 | ``` 1127 | 1128 | ### -SecurityFix 1129 | Fixes file security on all files, even skipped ones. 1130 | 1131 | ```yaml 1132 | Type: SwitchParameter 1133 | Parameter Sets: (All) 1134 | Aliases: secfix 1135 | 1136 | Required: False 1137 | Position: Named 1138 | Default value: False 1139 | Accept pipeline input: False 1140 | Accept wildcard characters: False 1141 | ``` 1142 | 1143 | ### -Source 1144 | Specifies the path to the source directory. 1145 | Must be a folder. 1146 | 1147 | ```yaml 1148 | Type: String 1149 | Parameter Sets: (All) 1150 | Aliases: Path, FullPath 1151 | 1152 | Required: True 1153 | Position: 0 1154 | Default value: None 1155 | Accept pipeline input: True (ByPropertyName, ByValue) 1156 | Accept wildcard characters: False 1157 | ``` 1158 | 1159 | ### -SymbolicLink 1160 | Copy Symbolic Links as links instead of as the link targets. 1161 | 1162 | ```yaml 1163 | Type: SwitchParameter 1164 | Parameter Sets: (All) 1165 | Aliases: sl 1166 | 1167 | Required: False 1168 | Position: Named 1169 | Default value: False 1170 | Accept pipeline input: False 1171 | Accept wildcard characters: False 1172 | ``` 1173 | 1174 | ### -Threads 1175 | Creates multi-threaded copies with N threads. 1176 | N must be an integer between 1 and 128. 1177 | Cannot be used with the InterPacketGap and EFSRAW parameters. 1178 | The /MT parameter applies to Windows Server 2008 R2 and Windows 7. 1179 | 1180 | ```yaml 1181 | Type: Int32 1182 | Parameter Sets: (All) 1183 | Aliases: MT, MultiThread 1184 | 1185 | Required: False 1186 | Position: 10 1187 | Default value: None 1188 | Accept pipeline input: False 1189 | Accept wildcard characters: False 1190 | ``` 1191 | 1192 | ### -Timefix 1193 | Fixes file times on all files, even skipped ones. 1194 | 1195 | ```yaml 1196 | Type: SwitchParameter 1197 | Parameter Sets: (All) 1198 | Aliases: timfix 1199 | 1200 | Required: False 1201 | Position: Named 1202 | Default value: False 1203 | Accept pipeline input: False 1204 | Accept wildcard characters: False 1205 | ``` 1206 | 1207 | ### -UnbufferedIO 1208 | Copies using unbuffered I/O (recommended for large files). 1209 | 1210 | ```yaml 1211 | Type: SwitchParameter 1212 | Parameter Sets: (All) 1213 | Aliases: j 1214 | 1215 | Required: False 1216 | Position: Named 1217 | Default value: False 1218 | Accept pipeline input: False 1219 | Accept wildcard characters: False 1220 | ``` 1221 | 1222 | ### -Unicode 1223 | Displays the status output as Unicode text. 1224 | 1225 | ```yaml 1226 | Type: SwitchParameter 1227 | Parameter Sets: (All) 1228 | Aliases: 1229 | 1230 | Required: False 1231 | Position: Named 1232 | Default value: False 1233 | Accept pipeline input: False 1234 | Accept wildcard characters: False 1235 | ``` 1236 | 1237 | ### -UnicodeLog 1238 | Writes the status output to the log file as Unicode text (overwrites the existing log file). 1239 | 1240 | ```yaml 1241 | Type: String 1242 | Parameter Sets: (All) 1243 | Aliases: unilog 1244 | 1245 | Required: False 1246 | Position: 29 1247 | Default value: None 1248 | Accept pipeline input: False 1249 | Accept wildcard characters: False 1250 | ``` 1251 | 1252 | ### -UnicodeLogWithAppend 1253 | Writes the status output to the log file as Unicode text (appends the output to the existing log file). 1254 | 1255 | ```yaml 1256 | Type: String 1257 | Parameter Sets: (All) 1258 | Aliases: 1259 | 1260 | Required: False 1261 | Position: 30 1262 | Default value: None 1263 | Accept pipeline input: False 1264 | Accept wildcard characters: False 1265 | ``` 1266 | 1267 | ### -Unit 1268 | What unit the sizes are shown as 1269 | 1270 | ```yaml 1271 | Type: String 1272 | Parameter Sets: (All) 1273 | Aliases: 1274 | Accepted values: Auto, PB, TB, GB, MB, KB, Bytes 1275 | 1276 | Required: False 1277 | Position: 34 1278 | Default value: Auto 1279 | Accept pipeline input: False 1280 | Accept wildcard characters: False 1281 | ``` 1282 | 1283 | ### -UsePerFileRunTimes 1284 | Checks run times on a per-file (not per-pass) basis. 1285 | 1286 | ```yaml 1287 | Type: SwitchParameter 1288 | Parameter Sets: (All) 1289 | Aliases: pf 1290 | 1291 | Required: False 1292 | Position: Named 1293 | Default value: False 1294 | Accept pipeline input: False 1295 | Accept wildcard characters: False 1296 | ``` 1297 | 1298 | ### -Wait 1299 | Specifies the wait time between retries, in seconds. 1300 | The default value of N is 3. 1301 | 1302 | ```yaml 1303 | Type: Int32 1304 | Parameter Sets: (All) 1305 | Aliases: w 1306 | 1307 | Required: False 1308 | Position: 24 1309 | Default value: 3 1310 | Accept pipeline input: False 1311 | Accept wildcard characters: False 1312 | ``` 1313 | 1314 | ### -WaitForShareName 1315 | Specifies that the system will wait for share names to be defined (retry error 67). 1316 | 1317 | ```yaml 1318 | Type: SwitchParameter 1319 | Parameter Sets: (All) 1320 | Aliases: tbd 1321 | 1322 | Required: False 1323 | Position: Named 1324 | Default value: False 1325 | Accept pipeline input: False 1326 | Accept wildcard characters: False 1327 | ``` 1328 | 1329 | ### -Confirm 1330 | Prompts you for confirmation before running the function. 1331 | 1332 | ```yaml 1333 | Type: SwitchParameter 1334 | Parameter Sets: (All) 1335 | Aliases: cf 1336 | 1337 | Required: False 1338 | Position: Named 1339 | Default value: None 1340 | Accept pipeline input: False 1341 | Accept wildcard characters: False 1342 | ``` 1343 | 1344 | ### -WhatIf 1345 | Shows what would happen if the function runs. 1346 | The function is not run. 1347 | 1348 | ```yaml 1349 | Type: SwitchParameter 1350 | Parameter Sets: (All) 1351 | Aliases: wi 1352 | 1353 | Required: False 1354 | Position: Named 1355 | Default value: None 1356 | Accept pipeline input: False 1357 | Accept wildcard characters: False 1358 | ``` 1359 | 1360 | ### -Force 1361 | If destination folder does not exist the Force parameter will try and create it. 1362 | 1363 | ```yaml 1364 | Type: SwitchParameter 1365 | Parameter Sets: (All) 1366 | Aliases: 1367 | 1368 | Required: False 1369 | Position: Named 1370 | Default value: None 1371 | Accept pipeline input: False 1372 | Accept wildcard characters: False 1373 | ``` 1374 | 1375 | ### -Precision 1376 | Number of digits after decimal point in rounded numbers. 1377 | 1378 | ```yaml 1379 | Type: Int64 1380 | Parameter Sets: (All) 1381 | Aliases: 1382 | 1383 | Required: False 1384 | Position: Named 1385 | Default value: None 1386 | Accept pipeline input: False 1387 | Accept wildcard characters: False 1388 | ``` 1389 | 1390 | ### -IoMaxSize 1391 | Requested max i/o size per {read,write} cycle, in n [KMG] bytes. 1392 | 1393 | ```yaml 1394 | Type: String 1395 | Parameter Sets: (All) 1396 | Aliases: 1397 | 1398 | Required: False 1399 | Position: Named 1400 | Default value: None 1401 | Accept pipeline input: False 1402 | Accept wildcard characters: False 1403 | ``` 1404 | 1405 | ### -IoRate 1406 | Requested i/o rate, in n [KMG] bytes per second. 1407 | 1408 | ```yaml 1409 | Type: String 1410 | Parameter Sets: (All) 1411 | Aliases: 1412 | 1413 | Required: False 1414 | Position: Named 1415 | Default value: None 1416 | Accept pipeline input: False 1417 | Accept wildcard characters: False 1418 | ``` 1419 | 1420 | ### -Threshold 1421 | File size threshold for throttling, in n [KMG] bytes. 1422 | 1423 | ```yaml 1424 | Type: String 1425 | Parameter Sets: (All) 1426 | Aliases: 1427 | 1428 | Required: False 1429 | Position: Named 1430 | Default value: None 1431 | Accept pipeline input: False 1432 | Accept wildcard characters: False 1433 | ``` 1434 | 1435 | ### -OutputType 1436 | Choose if output from Robocopy.exe should be parsed or not. 1437 | 1438 | ```yaml 1439 | Type: Object 1440 | Parameter Sets: (All) 1441 | Aliases: 1442 | 1443 | Required: False 1444 | Position: Named 1445 | Default value: None 1446 | Accept pipeline input: False 1447 | Accept wildcard characters: False 1448 | ``` 1449 | 1450 | ### -Sparse 1451 | Enable retaining sparse state during copy. 1452 | 1453 | ```yaml 1454 | Type: SwitchParameter 1455 | Parameter Sets: (All) 1456 | Aliases: 1457 | 1458 | Required: False 1459 | Position: Named 1460 | Default value: None 1461 | Accept pipeline input: False 1462 | Accept wildcard characters: False 1463 | ``` 1464 | 1465 | ### CommonParameters 1466 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 1467 | 1468 | ## INPUTS 1469 | 1470 | ### System.String 1471 | 1472 | ## OUTPUTS 1473 | 1474 | ### System.Object 1475 | ## NOTES 1476 | 1477 | ## RELATED LINKS 1478 | -------------------------------------------------------------------------------- /docs/Remove-RoboItem.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: RobocopyPS-help.xml 3 | Module Name: RobocopyPS 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Remove-RoboItem 9 | 10 | ## SYNOPSIS 11 | Remove directory. 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Remove-RoboItem [-Path] [-RestartMode] [-BackupMode] [-RestartAndBackupMode] [-Threads ] 17 | [[-Retry] ] [[-Wait] ] [-WhatIf] [-Confirm] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | Remove one or more directories with the help of Robocopy by creating a temporary directory and mirror the empty content to the specified directories. 22 | 23 | ## EXAMPLES 24 | 25 | ### Example 1 26 | ```powershell 27 | PS C:\> Remove-RoboItem -Path "D:\dir1","D:\dir2" 28 | ``` 29 | 30 | Remove multiple directories. 31 | 32 | ## PARAMETERS 33 | 34 | ### -BackupMode 35 | Remove directories in Backup mode. 36 | 37 | ```yaml 38 | Type: SwitchParameter 39 | Parameter Sets: (All) 40 | Aliases: b 41 | 42 | Required: False 43 | Position: Named 44 | Default value: None 45 | Accept pipeline input: False 46 | Accept wildcard characters: False 47 | ``` 48 | 49 | ### -Confirm 50 | Prompts you for confirmation before running the cmdlet. 51 | 52 | ```yaml 53 | Type: SwitchParameter 54 | Parameter Sets: (All) 55 | Aliases: cf 56 | 57 | Required: False 58 | Position: Named 59 | Default value: None 60 | Accept pipeline input: False 61 | Accept wildcard characters: False 62 | ``` 63 | 64 | ### -Path 65 | Specify which directory or directories you want to remove. 66 | 67 | ```yaml 68 | Type: String[] 69 | Parameter Sets: (All) 70 | Aliases: FullPath 71 | 72 | Required: True 73 | Position: 0 74 | Default value: None 75 | Accept pipeline input: True (ByPropertyName, ByValue) 76 | Accept wildcard characters: False 77 | ``` 78 | 79 | ### -RestartAndBackupMode 80 | Remove directories in restartable mode. If file access is denied, switches to backup mode. 81 | 82 | ```yaml 83 | Type: SwitchParameter 84 | Parameter Sets: (All) 85 | Aliases: zb 86 | 87 | Required: False 88 | Position: Named 89 | Default value: None 90 | Accept pipeline input: False 91 | Accept wildcard characters: False 92 | ``` 93 | 94 | ### -RestartMode 95 | Remove directories in restartable mode. 96 | 97 | ```yaml 98 | Type: SwitchParameter 99 | Parameter Sets: (All) 100 | Aliases: z 101 | 102 | Required: False 103 | Position: Named 104 | Default value: None 105 | Accept pipeline input: False 106 | Accept wildcard characters: False 107 | ``` 108 | 109 | ### -Retry 110 | Specifies the number of retries. Default is 3. 111 | 112 | ```yaml 113 | Type: Int32 114 | Parameter Sets: (All) 115 | Aliases: r 116 | 117 | Required: False 118 | Position: 1 119 | Default value: None 120 | Accept pipeline input: False 121 | Accept wildcard characters: False 122 | ``` 123 | 124 | ### -Wait 125 | Specifies the wait time between retries, in seconds. The default value of N is 3. 126 | 127 | ```yaml 128 | Type: Int32 129 | Parameter Sets: (All) 130 | Aliases: w 131 | 132 | Required: False 133 | Position: 2 134 | Default value: None 135 | Accept pipeline input: False 136 | Accept wildcard characters: False 137 | ``` 138 | 139 | ### -WhatIf 140 | Shows what would happen if the cmdlet runs. 141 | The cmdlet is not run. 142 | 143 | ```yaml 144 | Type: SwitchParameter 145 | Parameter Sets: (All) 146 | Aliases: wi 147 | 148 | Required: False 149 | Position: Named 150 | Default value: None 151 | Accept pipeline input: False 152 | Accept wildcard characters: False 153 | ``` 154 | 155 | ### -Threads 156 | Creates multi-threaded copies with N threads. N must be an integer between 1 and 128. 157 | 158 | ```yaml 159 | Type: Int32 160 | Parameter Sets: (All) 161 | Aliases: MT, MultiThread 162 | 163 | Required: False 164 | Position: Named 165 | Default value: None 166 | Accept pipeline input: False 167 | Accept wildcard characters: False 168 | ``` 169 | 170 | ### CommonParameters 171 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 172 | 173 | ## INPUTS 174 | 175 | ### System.String[] 176 | 177 | ## OUTPUTS 178 | 179 | ### System.Object 180 | ## NOTES 181 | 182 | ## RELATED LINKS 183 | -------------------------------------------------------------------------------- /docs/Sync-RoboItem.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: RobocopyPS-help.xml 3 | Module Name: RobocopyPS 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Sync-RoboItem 9 | 10 | ## SYNOPSIS 11 | Sync (mirror) a source directory to a destination directory. 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Sync-RoboItem [-WhatIf] [-Confirm] [-Source] [-Destination] [-Force] [[-Level] ] 17 | [-RestartMode] [-BackupMode] [-RestartAndBackupMode] [-UnbufferedIO] [-EFSRaw] [[-CopyFlags] ] 18 | [[-DirectoryCopyFlags] ] [-CopyWithSecurity] [-CopyAllFileInformation] [-NoCopy] [-SecurityFix] 19 | [-Timefix] [[-AddAttribute] ] [[-RemoveAttribute] ] [-Create] [-FAT] [-IgnoreLongPath] 20 | [[-MonitorChanges] ] [[-MonitorMinutes] ] [[-Threads] ] [[-RunTimes] ] 21 | [-UsePerFileRunTimes] [[-InterPacketGap] ] [-CopyJunction] [-SymbolicLink] [-NoDirectoryInformation] 22 | [-NoOffload] [-Compress] [-Sparse] [-IoMaxSize ] [-IoRate ] [-Threshold ] [-Archive] 23 | [-ResetArchiveAttribute] [[-IncludeAttribute] ] [[-ExcludeAttribute] ] 24 | [[-ExcludeFileName] ] [[-ExcludeDirectory] ] [-ExcludeChangedFiles] [-ExcludeNewerFiles] 25 | [-ExcludeOlderFiles] [-ExcludeExtraFiles] [-ExcludeLonelyFiles] [-IncludeModifiedFile] [-IncludeSameFiles] 26 | [-IncludeTweakedFiles] [[-MaximumFileSize] ] [[-MinimumFileSize] ] 27 | [[-MaximumFileAge] ] [[-MinimumFileAge] ] [[-MaximumFileLastAccessDate] ] 28 | [[-MinimumFileLastAccessDate] ] [-ExcludeJunctionPoints] [-AssumeFATFileTime] [-CompensateDST] 29 | [-ExcludeDirectoryJunctionPoints] [-ExcludeFileJunctionPoints] [[-Retry] ] [[-Wait] ] 30 | [-SaveRetrySettings] [-WaitForShareName] [-LowFreeSpaceMode] [[-LowFreeSpaceModeValue] ] [-List] 31 | [-ReportExtraFile] [-NoSizeToLog] [-NoClassToLog] [[-NoFileNameToLog] ] [[-LogFile] ] 32 | [[-LogFileWithAppend] ] [-Unicode] [[-UnicodeLog] ] [[-UnicodeLogWithAppend] ] 33 | [[-JobName] ] [[-SaveJob] ] [-Quit] [-NoSourceDirectory] [-NoDestinationDirectory] 34 | [[-IncludeFollowingFile] ] [[-Unit] ] [[-Precision] ] [-OutputType ] 35 | [] 36 | ``` 37 | 38 | ## DESCRIPTION 39 | Sync (mirror) a source directory to a destination directory using Robocopy /mir. The destination directory will be an exact copy of source and will add and remove all files and directories that is not in the source folder. 40 | 41 | ## EXAMPLES 42 | 43 | ### Example 1 44 | ```powershell 45 | PS C:\> Sync-RoboItem -Source C:\HR -Destination C:\backup\HR 46 | ``` 47 | 48 | Sync (mirror) directory C:\HR to C:\backup\HR. 49 | 50 | ### Example 2 51 | ```powershell 52 | PS C:\> $date = Get-Date -Format yyyyMMdd 53 | PS C:\> Sync-RoboItem -Source C:\HR -Destination C:\backup\HR\$date 54 | ``` 55 | 56 | Sync (mirror) directory C:\HR to C:\backup\HR\$date and create destination directories if they do not exist. 57 | 58 | ## PARAMETERS 59 | 60 | ### -AddAttribute 61 | Adds the specified attributes to copied files. 62 | 63 | ```yaml 64 | Type: String[] 65 | Parameter Sets: (All) 66 | Aliases: 67 | Accepted values: R, A, S, H, C, N, E, T 68 | 69 | Required: False 70 | Position: 6 71 | Default value: None 72 | Accept pipeline input: False 73 | Accept wildcard characters: False 74 | ``` 75 | 76 | ### -Archive 77 | Copies only files for which the Archive attribute is set. 78 | 79 | ```yaml 80 | Type: SwitchParameter 81 | Parameter Sets: (All) 82 | Aliases: a 83 | 84 | Required: False 85 | Position: Named 86 | Default value: None 87 | Accept pipeline input: False 88 | Accept wildcard characters: False 89 | ``` 90 | 91 | ### -AssumeFATFileTime 92 | Assumes FAT file times (two-second precision). 93 | 94 | ```yaml 95 | Type: SwitchParameter 96 | Parameter Sets: (All) 97 | Aliases: fft 98 | 99 | Required: False 100 | Position: Named 101 | Default value: None 102 | Accept pipeline input: False 103 | Accept wildcard characters: False 104 | ``` 105 | 106 | ### -BackupMode 107 | Copies files in Backup mode. 108 | 109 | ```yaml 110 | Type: SwitchParameter 111 | Parameter Sets: (All) 112 | Aliases: b 113 | 114 | Required: False 115 | Position: Named 116 | Default value: None 117 | Accept pipeline input: False 118 | Accept wildcard characters: False 119 | ``` 120 | 121 | ### -CompensateDST 122 | Compensates for one-hour DST time differences. 123 | 124 | ```yaml 125 | Type: SwitchParameter 126 | Parameter Sets: (All) 127 | Aliases: dst 128 | 129 | Required: False 130 | Position: Named 131 | Default value: None 132 | Accept pipeline input: False 133 | Accept wildcard characters: False 134 | ``` 135 | 136 | ### -Compress 137 | Requests network compression during file transfer, if applicable. 138 | 139 | ```yaml 140 | Type: SwitchParameter 141 | Parameter Sets: (All) 142 | Aliases: 143 | 144 | Required: False 145 | Position: Named 146 | Default value: None 147 | Accept pipeline input: False 148 | Accept wildcard characters: False 149 | ``` 150 | 151 | ### -Confirm 152 | Prompts you for confirmation before running the cmdlet. 153 | 154 | ```yaml 155 | Type: SwitchParameter 156 | Parameter Sets: (All) 157 | Aliases: cf 158 | 159 | Required: False 160 | Position: Named 161 | Default value: None 162 | Accept pipeline input: False 163 | Accept wildcard characters: False 164 | ``` 165 | 166 | ### -CopyAllFileInformation 167 | Copies all file information (equivalent to /copy:DATSOU). 168 | 169 | ```yaml 170 | Type: SwitchParameter 171 | Parameter Sets: (All) 172 | Aliases: copyall 173 | 174 | Required: False 175 | Position: Named 176 | Default value: None 177 | Accept pipeline input: False 178 | Accept wildcard characters: False 179 | ``` 180 | 181 | ### -CopyFlags 182 | Specifies the file properties to be copied. 183 | The default value for CopyFlags is DAT (data, attributes, and time stamps). 184 | D = Data. 185 | A = Attributes. 186 | T = Time stamps.S = NTFS access control list (ACL). 187 | O =Owner information. 188 | U = Auditing information 189 | 190 | ```yaml 191 | Type: String[] 192 | Parameter Sets: (All) 193 | Aliases: copy 194 | Accepted values: D, A, T, S, O, U 195 | 196 | Required: False 197 | Position: 4 198 | Default value: None 199 | Accept pipeline input: False 200 | Accept wildcard characters: False 201 | ``` 202 | 203 | ### -CopyJunction 204 | Copy Junctions as junctions instead of as the junction targets. 205 | 206 | ```yaml 207 | Type: SwitchParameter 208 | Parameter Sets: (All) 209 | Aliases: sj 210 | 211 | Required: False 212 | Position: Named 213 | Default value: None 214 | Accept pipeline input: False 215 | Accept wildcard characters: False 216 | ``` 217 | 218 | ### -CopyWithSecurity 219 | Copies files with security (equivalent to /copy:DATS). 220 | 221 | ```yaml 222 | Type: SwitchParameter 223 | Parameter Sets: (All) 224 | Aliases: sec 225 | 226 | Required: False 227 | Position: Named 228 | Default value: None 229 | Accept pipeline input: False 230 | Accept wildcard characters: False 231 | ``` 232 | 233 | ### -Create 234 | Creates a directory tree and zero-length files only. 235 | 236 | ```yaml 237 | Type: SwitchParameter 238 | Parameter Sets: (All) 239 | Aliases: 240 | 241 | Required: False 242 | Position: Named 243 | Default value: None 244 | Accept pipeline input: False 245 | Accept wildcard characters: False 246 | ``` 247 | 248 | ### -Destination 249 | Specifies the path to the destination directory. 250 | Must be a folder. 251 | 252 | ```yaml 253 | Type: String 254 | Parameter Sets: (All) 255 | Aliases: Target 256 | 257 | Required: True 258 | Position: 1 259 | Default value: None 260 | Accept pipeline input: True (ByPropertyName, ByValue) 261 | Accept wildcard characters: False 262 | ``` 263 | 264 | ### -DirectoryCopyFlags 265 | Specifies what to copy in directories. 266 | The valid values for this option are:D - Data, A - Attributes, T - Time stamps. 267 | The default value for this option is DA (data and attributes). 268 | 269 | ```yaml 270 | Type: String[] 271 | Parameter Sets: (All) 272 | Aliases: dcopy 273 | Accepted values: D, A, T 274 | 275 | Required: False 276 | Position: 5 277 | Default value: None 278 | Accept pipeline input: False 279 | Accept wildcard characters: False 280 | ``` 281 | 282 | ### -EFSRaw 283 | Copies all encrypted files in EFS RAW mode. 284 | 285 | ```yaml 286 | Type: SwitchParameter 287 | Parameter Sets: (All) 288 | Aliases: 289 | 290 | Required: False 291 | Position: Named 292 | Default value: None 293 | Accept pipeline input: False 294 | Accept wildcard characters: False 295 | ``` 296 | 297 | ### -ExcludeAttribute 298 | Excludes files for which any of the specified attributes are set. 299 | 300 | ```yaml 301 | Type: String[] 302 | Parameter Sets: (All) 303 | Aliases: xa 304 | Accepted values: R, A, S, C, H, N, E, T, O 305 | 306 | Required: False 307 | Position: 14 308 | Default value: None 309 | Accept pipeline input: False 310 | Accept wildcard characters: False 311 | ``` 312 | 313 | ### -ExcludeChangedFiles 314 | Excludes changed files. 315 | 316 | ```yaml 317 | Type: SwitchParameter 318 | Parameter Sets: (All) 319 | Aliases: xc 320 | 321 | Required: False 322 | Position: Named 323 | Default value: None 324 | Accept pipeline input: False 325 | Accept wildcard characters: False 326 | ``` 327 | 328 | ### -ExcludeDirectory 329 | Excludes directories that match the specified names and paths. 330 | 331 | ```yaml 332 | Type: String[] 333 | Parameter Sets: (All) 334 | Aliases: xd 335 | 336 | Required: False 337 | Position: 16 338 | Default value: None 339 | Accept pipeline input: False 340 | Accept wildcard characters: False 341 | ``` 342 | 343 | ### -ExcludeDirectoryJunctionPoints 344 | Excludes junction points for directories. 345 | 346 | ```yaml 347 | Type: SwitchParameter 348 | Parameter Sets: (All) 349 | Aliases: xjd 350 | 351 | Required: False 352 | Position: Named 353 | Default value: None 354 | Accept pipeline input: False 355 | Accept wildcard characters: False 356 | ``` 357 | 358 | ### -ExcludeExtraFiles 359 | Excludes extra files and directories. 360 | 361 | ```yaml 362 | Type: SwitchParameter 363 | Parameter Sets: (All) 364 | Aliases: xx 365 | 366 | Required: False 367 | Position: Named 368 | Default value: None 369 | Accept pipeline input: False 370 | Accept wildcard characters: False 371 | ``` 372 | 373 | ### -ExcludeFileJunctionPoints 374 | Excludes junction points for files. 375 | 376 | ```yaml 377 | Type: SwitchParameter 378 | Parameter Sets: (All) 379 | Aliases: xjf 380 | 381 | Required: False 382 | Position: Named 383 | Default value: None 384 | Accept pipeline input: False 385 | Accept wildcard characters: False 386 | ``` 387 | 388 | ### -ExcludeFileName 389 | Excludes files that match the specified names or paths. 390 | Note that FileName can include wildcard characters (* and ?). 391 | 392 | ```yaml 393 | Type: String[] 394 | Parameter Sets: (All) 395 | Aliases: xf 396 | 397 | Required: False 398 | Position: 15 399 | Default value: None 400 | Accept pipeline input: False 401 | Accept wildcard characters: False 402 | ``` 403 | 404 | ### -ExcludeJunctionPoints 405 | Excludes junction points, which are normally included by default. 406 | 407 | ```yaml 408 | Type: SwitchParameter 409 | Parameter Sets: (All) 410 | Aliases: xj 411 | 412 | Required: False 413 | Position: Named 414 | Default value: None 415 | Accept pipeline input: False 416 | Accept wildcard characters: False 417 | ``` 418 | 419 | ### -ExcludeLonelyFiles 420 | Excludes "lonely" files and directories. 421 | 422 | ```yaml 423 | Type: SwitchParameter 424 | Parameter Sets: (All) 425 | Aliases: xl 426 | 427 | Required: False 428 | Position: Named 429 | Default value: None 430 | Accept pipeline input: False 431 | Accept wildcard characters: False 432 | ``` 433 | 434 | ### -ExcludeNewerFiles 435 | Excludes newer files. 436 | 437 | ```yaml 438 | Type: SwitchParameter 439 | Parameter Sets: (All) 440 | Aliases: xn 441 | 442 | Required: False 443 | Position: Named 444 | Default value: None 445 | Accept pipeline input: False 446 | Accept wildcard characters: False 447 | ``` 448 | 449 | ### -ExcludeOlderFiles 450 | Excludes older files. 451 | 452 | ```yaml 453 | Type: SwitchParameter 454 | Parameter Sets: (All) 455 | Aliases: xo 456 | 457 | Required: False 458 | Position: Named 459 | Default value: None 460 | Accept pipeline input: False 461 | Accept wildcard characters: False 462 | ``` 463 | 464 | ### -FAT 465 | Creates destination files by using 8.3 character-length FAT file names only. 466 | 467 | ```yaml 468 | Type: SwitchParameter 469 | Parameter Sets: (All) 470 | Aliases: 471 | 472 | Required: False 473 | Position: Named 474 | Default value: None 475 | Accept pipeline input: False 476 | Accept wildcard characters: False 477 | ``` 478 | 479 | ### -Force 480 | If destination folder does not exist the Force parameter will try and create it. 481 | 482 | ```yaml 483 | Type: SwitchParameter 484 | Parameter Sets: (All) 485 | Aliases: 486 | 487 | Required: False 488 | Position: Named 489 | Default value: None 490 | Accept pipeline input: False 491 | Accept wildcard characters: False 492 | ``` 493 | 494 | ### -IgnoreLongPath 495 | Turns off support for very long paths. 496 | 497 | ```yaml 498 | Type: SwitchParameter 499 | Parameter Sets: (All) 500 | Aliases: 256 501 | 502 | Required: False 503 | Position: Named 504 | Default value: None 505 | Accept pipeline input: False 506 | Accept wildcard characters: False 507 | ``` 508 | 509 | ### -IncludeAttribute 510 | Includes only files for which any of the specified attributes are set. 511 | 512 | ```yaml 513 | Type: String[] 514 | Parameter Sets: (All) 515 | Aliases: ia 516 | Accepted values: R, A, S, C, H, N, E, T, O 517 | 518 | Required: False 519 | Position: 13 520 | Default value: None 521 | Accept pipeline input: False 522 | Accept wildcard characters: False 523 | ``` 524 | 525 | ### -IncludeFollowingFile 526 | Include the following Files. 527 | 528 | ```yaml 529 | Type: String 530 | Parameter Sets: (All) 531 | Aliases: IF 532 | 533 | Required: False 534 | Position: 33 535 | Default value: None 536 | Accept pipeline input: False 537 | Accept wildcard characters: False 538 | ``` 539 | 540 | ### -IncludeModifiedFile 541 | Include modified files (differing change times). 542 | 543 | ```yaml 544 | Type: SwitchParameter 545 | Parameter Sets: (All) 546 | Aliases: im 547 | 548 | Required: False 549 | Position: Named 550 | Default value: None 551 | Accept pipeline input: False 552 | Accept wildcard characters: False 553 | ``` 554 | 555 | ### -IncludeSameFiles 556 | Includes the same files. 557 | 558 | ```yaml 559 | Type: SwitchParameter 560 | Parameter Sets: (All) 561 | Aliases: is 562 | 563 | Required: False 564 | Position: Named 565 | Default value: None 566 | Accept pipeline input: False 567 | Accept wildcard characters: False 568 | ``` 569 | 570 | ### -IncludeTweakedFiles 571 | Includes "tweaked" files. 572 | 573 | ```yaml 574 | Type: SwitchParameter 575 | Parameter Sets: (All) 576 | Aliases: it 577 | 578 | Required: False 579 | Position: Named 580 | Default value: None 581 | Accept pipeline input: False 582 | Accept wildcard characters: False 583 | ``` 584 | 585 | ### -InterPacketGap 586 | Specifies the inter-packet gap to free bandwidth on slow lines. 587 | 588 | ```yaml 589 | Type: Int32 590 | Parameter Sets: (All) 591 | Aliases: ipg 592 | 593 | Required: False 594 | Position: 12 595 | Default value: None 596 | Accept pipeline input: False 597 | Accept wildcard characters: False 598 | ``` 599 | 600 | ### -JobName 601 | Specifies that parameters are to be derived from the named job file. 602 | 603 | ```yaml 604 | Type: String 605 | Parameter Sets: (All) 606 | Aliases: Job 607 | 608 | Required: False 609 | Position: 31 610 | Default value: None 611 | Accept pipeline input: False 612 | Accept wildcard characters: False 613 | ``` 614 | 615 | ### -Level 616 | Copies only the top N levels of the source directory tree. 617 | 618 | ```yaml 619 | Type: Int32 620 | Parameter Sets: (All) 621 | Aliases: lev, Depth 622 | 623 | Required: False 624 | Position: 3 625 | Default value: None 626 | Accept pipeline input: False 627 | Accept wildcard characters: False 628 | ``` 629 | 630 | ### -List 631 | Specifies that files are to be listed only (and not copied, deleted, or time stamped). 632 | 633 | ```yaml 634 | Type: SwitchParameter 635 | Parameter Sets: (All) 636 | Aliases: l 637 | 638 | Required: False 639 | Position: Named 640 | Default value: None 641 | Accept pipeline input: False 642 | Accept wildcard characters: False 643 | ``` 644 | 645 | ### -LogFile 646 | Writes the status output to the log file (overwrites the existing log file). 647 | 648 | ```yaml 649 | Type: String 650 | Parameter Sets: (All) 651 | Aliases: log 652 | 653 | Required: False 654 | Position: 27 655 | Default value: None 656 | Accept pipeline input: False 657 | Accept wildcard characters: False 658 | ``` 659 | 660 | ### -LogFileWithAppend 661 | Writes the status output to the log file (appends the output to the existing log file). 662 | 663 | ```yaml 664 | Type: String 665 | Parameter Sets: (All) 666 | Aliases: 667 | 668 | Required: False 669 | Position: 28 670 | Default value: None 671 | Accept pipeline input: False 672 | Accept wildcard characters: False 673 | ``` 674 | 675 | ### -LowFreeSpaceMode 676 | Using /LFSM requests robocopy to operate in 'low free space mode'. 677 | In that mode, robocopy will pause whenever a file copy would cause the destination volume's free space to go below ten percent of the destination volume's size. 678 | 679 | ```yaml 680 | Type: SwitchParameter 681 | Parameter Sets: (All) 682 | Aliases: lfsm 683 | 684 | Required: False 685 | Position: Named 686 | Default value: None 687 | Accept pipeline input: False 688 | Accept wildcard characters: False 689 | ``` 690 | 691 | ### -LowFreeSpaceModeValue 692 | Using /LFSM requests robocopy to operate in 'low free space mode'. 693 | In that mode, robocopy will pause whenever a file copy would cause the destination volume's free space to go below a 'floor' value, which can be explicitly specified by the n\[KMG\] form of the flag where n=number and K:kilobytes ,M:megabytes or G:gigabytes. 694 | 695 | ```yaml 696 | Type: String 697 | Parameter Sets: (All) 698 | Aliases: 699 | 700 | Required: False 701 | Position: 25 702 | Default value: None 703 | Accept pipeline input: False 704 | Accept wildcard characters: False 705 | ``` 706 | 707 | ### -MaximumFileAge 708 | Specifies the maximum file age (to exclude files older than N days or date). 709 | 710 | ```yaml 711 | Type: String 712 | Parameter Sets: (All) 713 | Aliases: maxage 714 | 715 | Required: False 716 | Position: 19 717 | Default value: None 718 | Accept pipeline input: False 719 | Accept wildcard characters: False 720 | ``` 721 | 722 | ### -MaximumFileLastAccessDate 723 | Specifies the maximum last access date (excludes files unused since N). 724 | 725 | ```yaml 726 | Type: String 727 | Parameter Sets: (All) 728 | Aliases: maxlad 729 | 730 | Required: False 731 | Position: 21 732 | Default value: None 733 | Accept pipeline input: False 734 | Accept wildcard characters: False 735 | ``` 736 | 737 | ### -MaximumFileSize 738 | Specifies the maximum file size (to exclude files bigger than N bytes). 739 | 740 | ```yaml 741 | Type: String 742 | Parameter Sets: (All) 743 | Aliases: max 744 | 745 | Required: False 746 | Position: 17 747 | Default value: None 748 | Accept pipeline input: False 749 | Accept wildcard characters: False 750 | ``` 751 | 752 | ### -MinimumFileAge 753 | Specifies the minimum file age (exclude files newer than N days or date). 754 | 755 | ```yaml 756 | Type: String 757 | Parameter Sets: (All) 758 | Aliases: minage 759 | 760 | Required: False 761 | Position: 20 762 | Default value: None 763 | Accept pipeline input: False 764 | Accept wildcard characters: False 765 | ``` 766 | 767 | ### -MinimumFileLastAccessDate 768 | Specifies the minimum last access date (excludes files used since N) If N is less than 1900, N specifies the number of days. 769 | Otherwise, N specifies a date in the format YYYYMMDD. 770 | 771 | ```yaml 772 | Type: String 773 | Parameter Sets: (All) 774 | Aliases: minlad 775 | 776 | Required: False 777 | Position: 22 778 | Default value: None 779 | Accept pipeline input: False 780 | Accept wildcard characters: False 781 | ``` 782 | 783 | ### -MinimumFileSize 784 | Specifies the minimum file size (to exclude files smaller than N bytes). 785 | 786 | ```yaml 787 | Type: String 788 | Parameter Sets: (All) 789 | Aliases: min 790 | 791 | Required: False 792 | Position: 18 793 | Default value: None 794 | Accept pipeline input: False 795 | Accept wildcard characters: False 796 | ``` 797 | 798 | ### -MonitorChanges 799 | Monitors the source, and runs again when more than N changes are detected. 800 | 801 | ```yaml 802 | Type: Int32 803 | Parameter Sets: (All) 804 | Aliases: mon 805 | 806 | Required: False 807 | Position: 8 808 | Default value: None 809 | Accept pipeline input: False 810 | Accept wildcard characters: False 811 | ``` 812 | 813 | ### -MonitorMinutes 814 | Monitors source, and runs again in M minutes if changes are detected. 815 | 816 | ```yaml 817 | Type: Int32 818 | Parameter Sets: (All) 819 | Aliases: mot 820 | 821 | Required: False 822 | Position: 9 823 | Default value: None 824 | Accept pipeline input: False 825 | Accept wildcard characters: False 826 | ``` 827 | 828 | ### -NoClassToLog 829 | Specifies that file sizes are not to be logged. 830 | 831 | ```yaml 832 | Type: SwitchParameter 833 | Parameter Sets: (All) 834 | Aliases: nc 835 | 836 | Required: False 837 | Position: Named 838 | Default value: None 839 | Accept pipeline input: False 840 | Accept wildcard characters: False 841 | ``` 842 | 843 | ### -NoCopy 844 | Copies no file information. 845 | 846 | ```yaml 847 | Type: SwitchParameter 848 | Parameter Sets: (All) 849 | Aliases: 850 | 851 | Required: False 852 | Position: Named 853 | Default value: None 854 | Accept pipeline input: False 855 | Accept wildcard characters: False 856 | ``` 857 | 858 | ### -NoDestinationDirectory 859 | NO Destination Directory is specified. 860 | 861 | ```yaml 862 | Type: SwitchParameter 863 | Parameter Sets: (All) 864 | Aliases: NODD 865 | 866 | Required: False 867 | Position: Named 868 | Default value: None 869 | Accept pipeline input: False 870 | Accept wildcard characters: False 871 | ``` 872 | 873 | ### -NoDirectoryInformation 874 | Copies no directory info (the default /dcopy:DA is done). 875 | 876 | ```yaml 877 | Type: SwitchParameter 878 | Parameter Sets: (All) 879 | Aliases: nodcopy 880 | 881 | Required: False 882 | Position: Named 883 | Default value: None 884 | Accept pipeline input: False 885 | Accept wildcard characters: False 886 | ``` 887 | 888 | ### -NoFileNameToLog 889 | Specifies that file names are not to be logged. 890 | 891 | ```yaml 892 | Type: Object 893 | Parameter Sets: (All) 894 | Aliases: nfl 895 | 896 | Required: False 897 | Position: 26 898 | Default value: None 899 | Accept pipeline input: False 900 | Accept wildcard characters: False 901 | ``` 902 | 903 | ### -NoOffload 904 | Copies files without using the Windows Copy Offload mechanism. 905 | 906 | ```yaml 907 | Type: SwitchParameter 908 | Parameter Sets: (All) 909 | Aliases: 910 | 911 | Required: False 912 | Position: Named 913 | Default value: None 914 | Accept pipeline input: False 915 | Accept wildcard characters: False 916 | ``` 917 | 918 | ### -NoSizeToLog 919 | Specifies that file sizes are not to be logged. 920 | 921 | ```yaml 922 | Type: SwitchParameter 923 | Parameter Sets: (All) 924 | Aliases: ns 925 | 926 | Required: False 927 | Position: Named 928 | Default value: None 929 | Accept pipeline input: False 930 | Accept wildcard characters: False 931 | ``` 932 | 933 | ### -NoSourceDirectory 934 | NO Source Directory is specified. 935 | 936 | ```yaml 937 | Type: SwitchParameter 938 | Parameter Sets: (All) 939 | Aliases: NOSD 940 | 941 | Required: False 942 | Position: Named 943 | Default value: None 944 | Accept pipeline input: False 945 | Accept wildcard characters: False 946 | ``` 947 | 948 | ### -Precision 949 | Number of digits after decimal point in rounded numbers. 950 | 951 | ```yaml 952 | Type: Int64 953 | Parameter Sets: (All) 954 | Aliases: 955 | 956 | Required: False 957 | Position: 35 958 | Default value: None 959 | Accept pipeline input: False 960 | Accept wildcard characters: False 961 | ``` 962 | 963 | ### -Quit 964 | Quits after processing command line to view parameters. 965 | 966 | ```yaml 967 | Type: SwitchParameter 968 | Parameter Sets: (All) 969 | Aliases: 970 | 971 | Required: False 972 | Position: Named 973 | Default value: None 974 | Accept pipeline input: False 975 | Accept wildcard characters: False 976 | ``` 977 | 978 | ### -RemoveAttribute 979 | Removes the specified attributes from copied files. 980 | 981 | ```yaml 982 | Type: String[] 983 | Parameter Sets: (All) 984 | Aliases: 985 | Accepted values: R, A, S, H, C, N, E, T 986 | 987 | Required: False 988 | Position: 7 989 | Default value: None 990 | Accept pipeline input: False 991 | Accept wildcard characters: False 992 | ``` 993 | 994 | ### -ReportExtraFile 995 | Report all eXtra files, not just those selected & copied. 996 | 997 | ```yaml 998 | Type: SwitchParameter 999 | Parameter Sets: (All) 1000 | Aliases: x 1001 | 1002 | Required: False 1003 | Position: Named 1004 | Default value: None 1005 | Accept pipeline input: False 1006 | Accept wildcard characters: False 1007 | ``` 1008 | 1009 | ### -ResetArchiveAttribute 1010 | Copies only files for which the Archive attribute is set, and resets the Archive attribute. 1011 | 1012 | ```yaml 1013 | Type: SwitchParameter 1014 | Parameter Sets: (All) 1015 | Aliases: m 1016 | 1017 | Required: False 1018 | Position: Named 1019 | Default value: None 1020 | Accept pipeline input: False 1021 | Accept wildcard characters: False 1022 | ``` 1023 | 1024 | ### -RestartAndBackupMode 1025 | Copies files in restartable mode. 1026 | If file access is denied, switches to backup mode. 1027 | 1028 | ```yaml 1029 | Type: SwitchParameter 1030 | Parameter Sets: (All) 1031 | Aliases: zb 1032 | 1033 | Required: False 1034 | Position: Named 1035 | Default value: None 1036 | Accept pipeline input: False 1037 | Accept wildcard characters: False 1038 | ``` 1039 | 1040 | ### -RestartMode 1041 | Copies files in restartable mode. 1042 | 1043 | ```yaml 1044 | Type: SwitchParameter 1045 | Parameter Sets: (All) 1046 | Aliases: z 1047 | 1048 | Required: False 1049 | Position: Named 1050 | Default value: None 1051 | Accept pipeline input: False 1052 | Accept wildcard characters: False 1053 | ``` 1054 | 1055 | ### -Retry 1056 | Specifies the number of retries on failed copies. 1057 | Default is 3. 1058 | 1059 | ```yaml 1060 | Type: Int32 1061 | Parameter Sets: (All) 1062 | Aliases: r 1063 | 1064 | Required: False 1065 | Position: 23 1066 | Default value: None 1067 | Accept pipeline input: False 1068 | Accept wildcard characters: False 1069 | ``` 1070 | 1071 | ### -RunTimes 1072 | Specifies run times when new copies may be started. 1073 | 1074 | ```yaml 1075 | Type: String 1076 | Parameter Sets: (All) 1077 | Aliases: rh 1078 | 1079 | Required: False 1080 | Position: 11 1081 | Default value: None 1082 | Accept pipeline input: False 1083 | Accept wildcard characters: False 1084 | ``` 1085 | 1086 | ### -SaveJob 1087 | Specifies that parameters are to be saved to the named job file. 1088 | 1089 | ```yaml 1090 | Type: String 1091 | Parameter Sets: (All) 1092 | Aliases: Save 1093 | 1094 | Required: False 1095 | Position: 32 1096 | Default value: None 1097 | Accept pipeline input: False 1098 | Accept wildcard characters: False 1099 | ``` 1100 | 1101 | ### -SaveRetrySettings 1102 | Saves the values specified in the /r and /w options as default settings in the registry. 1103 | 1104 | ```yaml 1105 | Type: SwitchParameter 1106 | Parameter Sets: (All) 1107 | Aliases: reg 1108 | 1109 | Required: False 1110 | Position: Named 1111 | Default value: None 1112 | Accept pipeline input: False 1113 | Accept wildcard characters: False 1114 | ``` 1115 | 1116 | ### -SecurityFix 1117 | Fixes file security on all files, even skipped ones. 1118 | 1119 | ```yaml 1120 | Type: SwitchParameter 1121 | Parameter Sets: (All) 1122 | Aliases: secfix 1123 | 1124 | Required: False 1125 | Position: Named 1126 | Default value: None 1127 | Accept pipeline input: False 1128 | Accept wildcard characters: False 1129 | ``` 1130 | 1131 | ### -Source 1132 | Specifies the path to the source directory. 1133 | Must be a folder. 1134 | 1135 | ```yaml 1136 | Type: String 1137 | Parameter Sets: (All) 1138 | Aliases: Path, FullPath 1139 | 1140 | Required: True 1141 | Position: 0 1142 | Default value: None 1143 | Accept pipeline input: True (ByPropertyName, ByValue) 1144 | Accept wildcard characters: False 1145 | ``` 1146 | 1147 | ### -SymbolicLink 1148 | Copy Symbolic Links as links instead of as the link targets. 1149 | 1150 | ```yaml 1151 | Type: SwitchParameter 1152 | Parameter Sets: (All) 1153 | Aliases: sl 1154 | 1155 | Required: False 1156 | Position: Named 1157 | Default value: None 1158 | Accept pipeline input: False 1159 | Accept wildcard characters: False 1160 | ``` 1161 | 1162 | ### -Threads 1163 | Creates multi-threaded copies with N threads. 1164 | N must be an integer between 1 and 128. 1165 | Cannot be used with the InterPacketGap and EFSRAW parameters. 1166 | The /MT parameter applies to Windows Server 2008 R2 and Windows 7. 1167 | 1168 | ```yaml 1169 | Type: Int32 1170 | Parameter Sets: (All) 1171 | Aliases: MT, MultiThread 1172 | 1173 | Required: False 1174 | Position: 10 1175 | Default value: None 1176 | Accept pipeline input: False 1177 | Accept wildcard characters: False 1178 | ``` 1179 | 1180 | ### -Timefix 1181 | Fixes file times on all files, even skipped ones. 1182 | 1183 | ```yaml 1184 | Type: SwitchParameter 1185 | Parameter Sets: (All) 1186 | Aliases: timfix 1187 | 1188 | Required: False 1189 | Position: Named 1190 | Default value: None 1191 | Accept pipeline input: False 1192 | Accept wildcard characters: False 1193 | ``` 1194 | 1195 | ### -UnbufferedIO 1196 | Copies using unbuffered I/O (recommended for large files). 1197 | 1198 | ```yaml 1199 | Type: SwitchParameter 1200 | Parameter Sets: (All) 1201 | Aliases: j 1202 | 1203 | Required: False 1204 | Position: Named 1205 | Default value: None 1206 | Accept pipeline input: False 1207 | Accept wildcard characters: False 1208 | ``` 1209 | 1210 | ### -Unicode 1211 | Displays the status output as Unicode text. 1212 | 1213 | ```yaml 1214 | Type: SwitchParameter 1215 | Parameter Sets: (All) 1216 | Aliases: 1217 | 1218 | Required: False 1219 | Position: Named 1220 | Default value: None 1221 | Accept pipeline input: False 1222 | Accept wildcard characters: False 1223 | ``` 1224 | 1225 | ### -UnicodeLog 1226 | Writes the status output to the log file as Unicode text (overwrites the existing log file). 1227 | 1228 | ```yaml 1229 | Type: String 1230 | Parameter Sets: (All) 1231 | Aliases: unilog 1232 | 1233 | Required: False 1234 | Position: 29 1235 | Default value: None 1236 | Accept pipeline input: False 1237 | Accept wildcard characters: False 1238 | ``` 1239 | 1240 | ### -UnicodeLogWithAppend 1241 | Writes the status output to the log file as Unicode text (appends the output to the existing log file). 1242 | 1243 | ```yaml 1244 | Type: String 1245 | Parameter Sets: (All) 1246 | Aliases: 1247 | 1248 | Required: False 1249 | Position: 30 1250 | Default value: None 1251 | Accept pipeline input: False 1252 | Accept wildcard characters: False 1253 | ``` 1254 | 1255 | ### -Unit 1256 | What unit the sizes are shown as 1257 | 1258 | ```yaml 1259 | Type: String 1260 | Parameter Sets: (All) 1261 | Aliases: 1262 | Accepted values: Auto, PB, TB, GB, MB, KB, Bytes 1263 | 1264 | Required: False 1265 | Position: 34 1266 | Default value: None 1267 | Accept pipeline input: False 1268 | Accept wildcard characters: False 1269 | ``` 1270 | 1271 | ### -UsePerFileRunTimes 1272 | Checks run times on a per-file (not per-pass) basis. 1273 | 1274 | ```yaml 1275 | Type: SwitchParameter 1276 | Parameter Sets: (All) 1277 | Aliases: pf 1278 | 1279 | Required: False 1280 | Position: Named 1281 | Default value: None 1282 | Accept pipeline input: False 1283 | Accept wildcard characters: False 1284 | ``` 1285 | 1286 | ### -Wait 1287 | Specifies the wait time between retries, in seconds. 1288 | The default value of N is 3. 1289 | 1290 | ```yaml 1291 | Type: Int32 1292 | Parameter Sets: (All) 1293 | Aliases: w 1294 | 1295 | Required: False 1296 | Position: 24 1297 | Default value: None 1298 | Accept pipeline input: False 1299 | Accept wildcard characters: False 1300 | ``` 1301 | 1302 | ### -WaitForShareName 1303 | Specifies that the system will wait for share names to be defined (retry error 67). 1304 | 1305 | ```yaml 1306 | Type: SwitchParameter 1307 | Parameter Sets: (All) 1308 | Aliases: tbd 1309 | 1310 | Required: False 1311 | Position: Named 1312 | Default value: None 1313 | Accept pipeline input: False 1314 | Accept wildcard characters: False 1315 | ``` 1316 | 1317 | ### -WhatIf 1318 | Shows what would happen if the cmdlet runs. 1319 | The cmdlet is not run. 1320 | 1321 | ```yaml 1322 | Type: SwitchParameter 1323 | Parameter Sets: (All) 1324 | Aliases: wi 1325 | 1326 | Required: False 1327 | Position: Named 1328 | Default value: None 1329 | Accept pipeline input: False 1330 | Accept wildcard characters: False 1331 | ``` 1332 | 1333 | ### -IoMaxSize 1334 | Requested max i/o size per {read,write} cycle, in n [KMG] bytes. 1335 | 1336 | ```yaml 1337 | Type: String 1338 | Parameter Sets: (All) 1339 | Aliases: 1340 | 1341 | Required: False 1342 | Position: Named 1343 | Default value: None 1344 | Accept pipeline input: False 1345 | Accept wildcard characters: False 1346 | ``` 1347 | 1348 | ### -IoRate 1349 | Requested i/o rate, in n [KMG] bytes per second. 1350 | 1351 | ```yaml 1352 | Type: String 1353 | Parameter Sets: (All) 1354 | Aliases: 1355 | 1356 | Required: False 1357 | Position: Named 1358 | Default value: None 1359 | Accept pipeline input: False 1360 | Accept wildcard characters: False 1361 | ``` 1362 | 1363 | ### -Threshold 1364 | File size threshold for throttling, in n [KMG] bytes. 1365 | 1366 | ```yaml 1367 | Type: String 1368 | Parameter Sets: (All) 1369 | Aliases: 1370 | 1371 | Required: False 1372 | Position: Named 1373 | Default value: None 1374 | Accept pipeline input: False 1375 | Accept wildcard characters: False 1376 | ``` 1377 | 1378 | ### -OutputType 1379 | Choose if output from Robocopy.exe should be parsed or not. 1380 | 1381 | ```yaml 1382 | Type: Object 1383 | Parameter Sets: (All) 1384 | Aliases: 1385 | 1386 | Required: False 1387 | Position: Named 1388 | Default value: None 1389 | Accept pipeline input: False 1390 | Accept wildcard characters: False 1391 | ``` 1392 | 1393 | ### -Sparse 1394 | Enable retaining sparse state during copy. 1395 | 1396 | ```yaml 1397 | Type: SwitchParameter 1398 | Parameter Sets: (All) 1399 | Aliases: 1400 | 1401 | Required: False 1402 | Position: Named 1403 | Default value: None 1404 | Accept pipeline input: False 1405 | Accept wildcard characters: False 1406 | ``` 1407 | 1408 | ### CommonParameters 1409 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 1410 | 1411 | ## INPUTS 1412 | 1413 | ### System.String 1414 | 1415 | ## OUTPUTS 1416 | 1417 | ### System.Object 1418 | ## NOTES 1419 | 1420 | ## RELATED LINKS 1421 | -------------------------------------------------------------------------------- /tests/CompabilitySettings.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | Rules = @{ 3 | PSUseCompatibleCommands = @{ 4 | # Turns the rule on 5 | Enable = $true 6 | 7 | # Lists the PowerShell platforms we want to check compatibility with 8 | TargetProfiles = @( 9 | 10 | 'win-8_x64_10.0.17763.0_5.1.17763.316_x64_4.0.30319.42000_framework', # Windows Server 2019 5.1 11 | 'win-48_x64_10.0.17763.0_5.1.17763.316_x64_4.0.30319.42000_framework' # Windows 10 5.1 12 | ) 13 | } 14 | PSUseCompatibleSyntax = @{ 15 | # This turns the rule on (setting it to false will turn it off) 16 | Enable = $true 17 | 18 | # Simply list the targeted versions of PowerShell here 19 | TargetVersions = @( 20 | '5.1', 21 | '6.2', 22 | '7.1' 23 | ) 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /tests/Help.Tests.ps1: -------------------------------------------------------------------------------- 1 | $ModuleName = 'RobocopyPS' 2 | 3 | BeforeDiscovery { 4 | $ModuleName = 'RobocopyPS' 5 | $ModuleBase = Split-Path -Parent $PSScriptRoot 6 | $ModulePath = Join-Path $ModuleBase -ChildPath $ModuleName 7 | 8 | # Removes all versions of the module from the session before importing 9 | Get-Module $ModuleName | Remove-Module 10 | Import-Module $ModulePath -PassThru -ErrorAction Stop 11 | 12 | $commands = Get-Command -Module $ModuleName -CommandType Cmdlet, Function # Not alias 13 | } 14 | 15 | Describe "$ModuleName" { 16 | 17 | $ModuleName = 'RobocopyPS' 18 | $commands = Get-Command -Module $ModuleName -CommandType Cmdlet, Function # Not alias 19 | 20 | foreach ($command in $commands) { 21 | Context "$command" { 22 | 23 | $Help = @{ Help = Get-Help -Name $Command -Full | Select-Object -Property * } 24 | 25 | It "Has Synopsis and not have synopsis from PlatyPS" -TestCases $Help { 26 | $Help.Synopsis | Should -Not -BeNullOrEmpty 27 | $Help.Synopsis | should -Not -BeLike "*{{ Fill in the Synopsis }}*" 28 | } 29 | 30 | It "Has Description and not have description from PlatyPS" -TestCases $Help { 31 | $Help.Description | Should -Not -BeNullOrEmpty 32 | $Help.Description | should -Not -BeLike "*{{ Fill in the Description }}*" 33 | } 34 | 35 | It "Has Examples and not have examples from PlatyPS" -TestCases $Help { 36 | $help.Examples.Example | Should -Not -BeNullOrEmpty 37 | $Help.Examples.Example | should -Not -BeLike "*{{ Add example code here }}*" 38 | } 39 | } 40 | } 41 | } 42 | 43 | 44 | Describe "Invoke-Robocopy" { 45 | 46 | $ModuleName = 'RobocopyPS' 47 | $ModuleBase = Split-Path -Parent $PSScriptRoot 48 | $ModulePath = Join-Path $ModuleBase -ChildPath $ModuleName 49 | 50 | # Removes all versions of the module from the session before importing 51 | Get-Module $ModuleName | Remove-Module 52 | Import-Module $ModulePath -PassThru -ErrorAction Stop 53 | 54 | $Command = get-command -Name "Invoke-Robocopy" -Module "RobocopyPS" 55 | $parameters = $command.ParameterSets.Parameters | Sort-Object -Property Name -Unique 56 | $allParameterNameAndAlias = $parameters.Name + $parameters.aliases 57 | 58 | # Get all Robocopy options without slash 59 | $RobocopyHelp = Robocopy.exe /? 60 | $RobocopyOptionsIgnore = "/bytes", "/TEE", "/np", "/njh", "/fp", "/v", "/ndl", "/ts", "/NJS", "/ETA" 61 | $RobocopyOptions = $RobocopyHelp | ForEach-Object { $_ -split ("`r`n") -split (" ") -split ("\[") -split (" :: ") -split (":") -replace ("\s", "") } | ForEach-Object { $_ | Where-Object { $_ -match "^/[A-Z]{1,}\b$|^/[0-9]{1,}\b$" -and $_ -notin $RobocopyOptionsIgnore } } | Sort-Object -Unique | ForEach-Object { $_ -replace ("/", "") } 62 | 63 | foreach ($Option in $RobocopyOptions) { 64 | It "$Option has a parameter or alias" -TestCases @{'o' = $Option ; 'all' = $allParameterNameAndAlias} { 65 | $o | Should -BeIn $all 66 | } 67 | } 68 | } 69 | 70 | Describe "$ModuleName" -ForEach $commands { 71 | BeforeDiscovery { 72 | $commandName = $_.Name 73 | $help = Get-Help $_.Name 74 | $examples = $help.Examples.example 75 | $parameters = $help.parameters.parameter 76 | } 77 | 78 | Context "$commandname parameters" -Foreach @{param = $parameters} { 79 | It "<_.Name> Should not have auto filled description from PlatyPS" -TestCases $param { 80 | $param.description | should -Not -BeLike "*{{ Fill * Description }}*" 81 | } 82 | } 83 | } -------------------------------------------------------------------------------- /tests/Invoke-RobocopyParser.Tests.ps1: -------------------------------------------------------------------------------- 1 | BeforeDiscovery { 2 | $ModuleName = 'RobocopyPS' 3 | $ModuleBase = Split-Path -Parent $PSScriptRoot 4 | $ModulePath = Join-Path $ModuleBase -ChildPath $ModuleName 5 | 6 | # Removes all versions of the module from the session before importing 7 | Get-Module $ModuleName | Remove-Module 8 | Import-Module $ModulePath -PassThru -ErrorAction Stop 9 | } 10 | Describe "when parsing robocopy output" { 11 | InModuleScope $ModuleName { 12 | It "should not raise exception when parsing fails" -ForEach @( 13 | @{ line = ' New File 4924 1988/10/11 13:40:54 C:\Source\New-Credential2.ps1'; source='C:\Source'; destination='C:\Temp';Status='New File' } 14 | @{ line = ' Newer 82424 2022/01/01 23:40:54 C:\Source\New-Credential2.ps1'; source='C:\Source'; destination='C:\Temp';Status='Newer' } 15 | @{ line = ' *EXTRA File 42804 2022/10/11 03:40:54 C:\Temp\New-Credential2.ps1'; source='C:\Source'; destination='C:\Temp';Status='*EXTRA File' } 16 | @{ line = ' 42804 2022/10/11 03:40:54 C:\Temp\New-Credential2.ps1'; source='C:\Source'; destination='C:\Temp';Status='' } 17 | ) { 18 | 19 | { $parsed = Invoke-RobocopyParser -InputObject $line } | Should -Not -Throw 20 | $parsed = Invoke-RobocopyParser -InputObject $line 21 | #Write-Warning "$($parsed | ConvertTo-Json)" # Commented out this block as it just write to the host, but I'll keep it as a comment if needed further down the line 22 | $parsed[0].Status | Should -Be $Status 23 | } 24 | } 25 | } 26 | 27 | Describe "Parsing Robocopy Speed output" { 28 | InModuleScope $ModuleName { 29 | It 'Should parse speed information from native Robocopy' -ForEach @( 30 | @{ line = ' Speed : 22,361,666 Bytes/sec.'; Out = '22361666 B/s'} 31 | @{ line = ' Speed : 22,361 Bytes/sec.'; Out = '22361 B/s'} 32 | @{ line = ' Speed : 8385625 Bytes/sec.'; Out = '8385625 B/s'} 33 | @{ line = ' Speed : 989 125 Bytes/sec.'; Out = '989125 B/s'} 34 | @{ line = ' Speed : 13,417,000 Bytes/sec.'; Out = '13417000 B/s'} 35 | ) { 36 | $Output = Invoke-RobocopyParser -InputObject $line -Unit Bytes 37 | $Output[0].Speed | Should -Be $Out 38 | } 39 | } 40 | } --------------------------------------------------------------------------------