├── .gitignore ├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ ├── General.md │ ├── Resource_proposal.md │ └── Problem_with_resource.md ├── stale.yml └── PULL_REQUEST_TEMPLATE.md ├── .codecov.yml ├── .vscode ├── settings.json └── analyzersettings.psd1 ├── Examples ├── xRobocopy.NetworkAndCredentials.ps1 └── xRobocopy.SimpleCopyOptions.ps1 ├── LICENSE ├── appveyor.yml ├── DSCResources └── MSFT_xRobocopy │ ├── MSFT_xRobocopy.schema.mof │ └── MSFT_xRobocopy.psm1 ├── Tests └── Unit │ └── MSFT_xRobocopy.Tests.ps1 ├── xRobocopy.psd1 ├── README.md └── Resources └── xDscResourceDesigner_CreateScript.ps1 /.gitignore: -------------------------------------------------------------------------------- 1 | DSCResource.Tests 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Needed for publishing of examples, build worker defaults to core.autocrlf=input. 2 | * text eol=crlf 3 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/General.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: General question or documentation update 3 | about: If you have a general question or documentation update suggestion around the resource module. 4 | --- 5 | 8 | -------------------------------------------------------------------------------- /.codecov.yml: -------------------------------------------------------------------------------- 1 | codecov: 2 | notify: 3 | require_ci_to_pass: no 4 | 5 | comment: 6 | layout: "reach, diff" 7 | behavior: default 8 | 9 | coverage: 10 | range: 50..80 11 | round: down 12 | precision: 0 13 | 14 | status: 15 | project: 16 | default: 17 | # Set the overall project code coverage requirement to 70% 18 | target: 70 19 | patch: 20 | default: 21 | # Set the pull request requirement to not regress overall coverage by more than 5% 22 | # and let codecov.io set the goal for the code changed in the patch. 23 | target: auto 24 | threshold: 5 25 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/Resource_proposal.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: New resource proposal 3 | about: If you have a new resource proposal that you think should be added to this resource module. 4 | --- 5 | 17 | ### Description 18 | 19 | ### Proposed properties 20 | 21 | ### Special considerations or limitations 22 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "powershell.codeFormatting.openBraceOnSameLine": false, 3 | "powershell.codeFormatting.newLineAfterOpenBrace": false, 4 | "powershell.codeFormatting.newLineAfterCloseBrace": true, 5 | "powershell.codeFormatting.whitespaceBeforeOpenBrace": true, 6 | "powershell.codeFormatting.whitespaceBeforeOpenParen": true, 7 | "powershell.codeFormatting.whitespaceAroundOperator": true, 8 | "powershell.codeFormatting.whitespaceAfterSeparator": true, 9 | "powershell.codeFormatting.ignoreOneLineBlock": false, 10 | "powershell.codeFormatting.preset": "Custom", 11 | "files.trimTrailingWhitespace": true, 12 | "files.insertFinalNewline": true, 13 | "powershell.scriptAnalysis.settingsPath": ".vscode\\analyzersettings.psd1" 14 | } 15 | -------------------------------------------------------------------------------- /Examples/xRobocopy.NetworkAndCredentials.ps1: -------------------------------------------------------------------------------- 1 | configuration DeployContent 2 | { 3 | param ( 4 | [Parameter(Mandatory=$true)] 5 | [ValidateNotNullorEmpty()] 6 | [PsCredential] $Credential 7 | ) 8 | 9 | Import-DscResource -ModuleName xRobocopy 10 | Node 'localhost' 11 | { 12 | xRobocopy Content 13 | { 14 | Source = '\\server\share\ReleaseVersion' 15 | Destination = 'C:\inetpub\wwwroot\sitename' 16 | MultiThreaded = $true 17 | Restartable = $true 18 | PsDscRunAsCredential = $Credential 19 | } 20 | } 21 | } 22 | $configData = @{ 23 | AllNodes = @( 24 | @{ 25 | NodeName = 'localhost'; 26 | CertificateId = 'Your Certificate thumbprint here' 27 | } 28 | ) 29 | } 30 | DeployContent -ConfigurationData $configData -Credential (get-credential) -OutputPath 'c:\DSC' 31 | Start-DscConfiguration -Wait -Force -Verbose -Path 'c:\DSC' 32 | 33 | # Validate results 34 | # Get-ChildItem C:\inetpub\wwwroot\sitename 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Michael Greene 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | #---------------------------------# 2 | # environment configuration # 3 | #---------------------------------# 4 | 5 | version: 2.0.{build}.0 6 | environment: 7 | gallery_api: 8 | secure: 9ekJzfsPCDBkyLrfmov83XbbhZ6E2N3z+B/Io8NbDetbHc6hWS19zsDmy7t0Vvxv 9 | 10 | install: 11 | - git clone https://github.com/PowerShell/DscResource.Tests 12 | - ps: Write-Verbose -Message "PowerShell version $($PSVersionTable.PSVersion)" -Verbose 13 | - ps: Import-Module -Name "$env:APPVEYOR_BUILD_FOLDER\DscResource.Tests\AppVeyor.psm1" 14 | - ps: Invoke-AppveyorInstallTask 15 | 16 | #---------------------------------# 17 | # build configuration # 18 | #---------------------------------# 19 | 20 | build: false 21 | 22 | #---------------------------------# 23 | # test configuration # 24 | #---------------------------------# 25 | 26 | test_script: 27 | - ps: | 28 | Invoke-AppveyorTestScriptTask -CodeCoverage -CodeCovIo 29 | 30 | # scripts to run before deployment 31 | after_test: 32 | - ps: | 33 | Import-Module -Name "$env:APPVEYOR_BUILD_FOLDER\DscResource.Tests\AppVeyor.psm1" 34 | Invoke-AppveyorAfterTestTask 35 | 36 | #---------------------------------# 37 | # deployment configuration # 38 | #---------------------------------# 39 | 40 | deploy_script: 41 | - ps: | 42 | Invoke-AppVeyorDeployTask 43 | -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | # Configuration for probot-stale - https://github.com/probot/stale 2 | 3 | limitPerRun: 30 4 | 5 | pulls: 6 | daysUntilStale: 14 7 | daysUntilClose: false 8 | exemptProjects: true 9 | exemptMilestones: true 10 | staleLabel: abandoned 11 | exemptLabels: 12 | - needs review 13 | - on hold 14 | - waiting for CLA pass 15 | 16 | markComment: > 17 | Labeling this pull request (PR) as abandoned since it has gone 14 days or more 18 | since the last update. An abandoned PR can be continued by another contributor. 19 | The abandoned label will be removed if work on this PR is taken up again. 20 | 21 | issues: 22 | daysUntilStale: 30 23 | daysUntilClose: 40 24 | exemptProjects: true 25 | exemptMilestones: true 26 | staleLabel: stale 27 | exemptLabels: 28 | - bug 29 | - enhancement 30 | - tests 31 | - documentation 32 | - resource proposal 33 | - on hold 34 | 35 | markComment: > 36 | This issue has been automatically marked as stale because 37 | it has not had activity from the community in the last 30 days. It will be 38 | closed if no further activity occurs within 10 days. If the issue is labelled 39 | with any of the work labels (e.g bug, enhancement, documentation, or tests) 40 | then the issue will not auto-close. 41 | 42 | closeComment: > 43 | This issue has been automatically closed because it is has not had activity 44 | from the community in the last 40 days. 45 | -------------------------------------------------------------------------------- /DSCResources/MSFT_xRobocopy/MSFT_xRobocopy.schema.mof: -------------------------------------------------------------------------------- 1 | [ClassVersion("0.1.0.0"), FriendlyName("xRobocopy")] 2 | class MSFT_xRobocopy : OMI_BaseResource 3 | { 4 | [Key, Description("Source Directory, Drive or UNC path.")] String Source; 5 | [Key, Description("Destination Dir, Drive or UNC path.")] String Destination; 6 | [Write, Description("File(s) to copy (names/wildcards: default is all files).")] String Files; 7 | [Write, Description("Number of Retries on failed copies: default 1 million.")] UInt32 Retry; 8 | [Write, Description("Wait time between retries: default is 30 seconds.")] UInt32 Wait; 9 | [Write, Description("Copy subdirectories, including Empty ones.")] Boolean SubdirectoriesIncludingEmpty; 10 | [Write, Description("Copy files in restartable mode.")] Boolean Restartable; 11 | [Write, Description("Do multi-threaded copies with n threads (default 8). N 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.")] Boolean MultiThreaded; 12 | [Write, Description("Exclude Files matching given names/paths/wildcards.")] String ExcludeFiles; 13 | [Write, Description("Output status to LOG file.")] String LogOutput; 14 | [Write, Description("Determine whether to overwrite log file or append.")] Boolean AppendLog; 15 | [Write, Description("Robocopy has MANY configuration options. Too many to present them all as DSC parameters effectively. Use this option to set additional parameters. Each parameter should be a separate array member. This array will be combined with main argument array. For a list of options run Robocopy /??? in a shell window.")] String AdditionalArgs[]; 16 | [Read, ValueMap{"Present", "Absent"}, Values{"Present", "Absent"}, Description("Will indicate whether Destination is in sync with Source")] String Ensure; 17 | }; 18 | 19 | -------------------------------------------------------------------------------- /Examples/xRobocopy.SimpleCopyOptions.ps1: -------------------------------------------------------------------------------- 1 | #some sample usage of xRobocopy module to sync folders 2 | #for all possible options please refer to robocopy documentation https://technet.microsoft.com/en-us/library/cc733145.aspx 3 | 4 | configuration RobocopyExample 5 | { 6 | Import-DscResource -ModuleName xRobocopy 7 | Node 'localhost' 8 | { 9 | 10 | LocalConfigurationManager 11 | { 12 | #this option should only be used during testing, remove it in production environment 13 | DebugMode = 'ForceModuleImport' 14 | } 15 | 16 | #this will copy all files in root, subfolders are ignored 17 | xRobocopy CopyAllFilesInRoot 18 | { 19 | Source = 'C:\temp\source' 20 | Destination = 'C:\temp\destination' 21 | } 22 | 23 | #other common use cases, uncomment one at time and comment above one to test them out 24 | <# 25 | #this will copy only sql files in root directory, subfolders are ignored 26 | xRobocopy CopyByUsingFilesFilter 27 | { 28 | Source = 'C:\temp\source' 29 | Destination = 'C:\temp\destination' 30 | Files = '*.sql' 31 | } 32 | 33 | #this is equivalent of using /e option 34 | xRobocopy CopyFilesAndSubfolders 35 | { 36 | Source = 'C:\temp\source' 37 | Destination = 'C:\temp\destination' 38 | SubdirectoriesIncludingEmpty = $true 39 | } 40 | 41 | #this will sync folders and all subfolders will remove any folders/files not in source 42 | xRobocopy SyncFolders 43 | { 44 | Source = 'C:\temp\source' 45 | Destination = 'C:\temp\destination' 46 | AdditionalArgs = '/mir' 47 | } 48 | #> 49 | } 50 | } 51 | 52 | RobocopyExample 53 | Set-DscLocalConfigurationManager .\RobocopyExample -Force -Verbose #only needed if using DebugMode 54 | Start-DscConfiguration .\RobocopyExample -Wait -Force -Verbose 55 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/Problem_with_resource.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Problem with a resource 3 | about: If you have a problem, bug, or enhancement with a resource in this resource module. 4 | --- 5 | 24 | #### Details of the scenario you tried and the problem that is occurring 25 | 26 | #### Verbose logs showing the problem 27 | 28 | #### Suggested solution to the issue 29 | 30 | #### The DSC configuration that is used to reproduce the issue (as detailed as possible) 31 | ```powershell 32 | # insert configuration here 33 | ``` 34 | 35 | #### The operating system the target node is running 36 | 50 | 51 | #### Version and build of PowerShell the target node is running 52 | 56 | 57 | #### Version of the DSC module that was used ('dev' if using current dev branch) 58 | -------------------------------------------------------------------------------- /Tests/Unit/MSFT_xRobocopy.Tests.ps1: -------------------------------------------------------------------------------- 1 | #region HEADER 2 | # TODO: Update to correct module name and resource name. 3 | $script:DSCModuleName = 'xRobocopy' 4 | $script:DSCResourceName = 'MSFT_xRobocopy' 5 | 6 | # Unit Test Template Version: 1.2.2 7 | $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) 8 | if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` 9 | (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) 10 | { 11 | & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests')) 12 | } 13 | 14 | Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force 15 | 16 | # TODO: Insert the correct and for your resource 17 | $TestEnvironment = Initialize-TestEnvironment ` 18 | -DSCModuleName $script:DSCModuleName ` 19 | -DSCResourceName $script:DSCResourceName ` 20 | -ResourceType 'Mof' ` 21 | -TestType Unit 22 | 23 | #endregion HEADER 24 | 25 | function Invoke-TestSetup 26 | { 27 | } 28 | 29 | function Invoke-TestCleanup 30 | { 31 | Restore-TestEnvironment -TestEnvironment $TestEnvironment 32 | } 33 | 34 | # Begin Testing 35 | try 36 | { 37 | Invoke-TestSetup 38 | 39 | InModuleScope $script:DSCResourceName { 40 | Describe 'MSFT_xRobocopy\Get-RobocopyArguments' -Tag 'Helper' { 41 | Context 'When only providing source and destination parameters' { 42 | It 'Should return the correct arguments' { 43 | $result = Get-RobocopyArguments -Source 'C:\' -Destination 'D:\' 44 | $result.Count | Should -Be 2 45 | $result[0] | Should -Be 'C:\' 46 | $result[1] | Should -Be 'D:\' 47 | } 48 | } 49 | } 50 | } 51 | } 52 | finally 53 | { 54 | Invoke-TestCleanup 55 | } 56 | -------------------------------------------------------------------------------- /.vscode/analyzersettings.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | <# 3 | For the custom rules to work, the DscResource.Tests repo must be 4 | cloned. It is automatically clone as soon as any unit or 5 | integration tests are run. 6 | #> 7 | CustomRulePath = '.\DSCResource.Tests\DscResource.AnalyzerRules' 8 | 9 | IncludeRules = @( 10 | # DSC Resource Kit style guideline rules. 11 | 'PSAvoidDefaultValueForMandatoryParameter', 12 | 'PSAvoidDefaultValueSwitchParameter', 13 | 'PSAvoidInvokingEmptyMembers', 14 | 'PSAvoidNullOrEmptyHelpMessageAttribute', 15 | 'PSAvoidUsingCmdletAliases', 16 | 'PSAvoidUsingComputerNameHardcoded', 17 | 'PSAvoidUsingDeprecatedManifestFields', 18 | 'PSAvoidUsingEmptyCatchBlock', 19 | 'PSAvoidUsingInvokeExpression', 20 | 'PSAvoidUsingPositionalParameters', 21 | 'PSAvoidShouldContinueWithoutForce', 22 | 'PSAvoidUsingWMICmdlet', 23 | 'PSAvoidUsingWriteHost', 24 | 'PSDSCReturnCorrectTypesForDSCFunctions', 25 | 'PSDSCStandardDSCFunctionsInResource', 26 | 'PSDSCUseIdenticalMandatoryParametersForDSC', 27 | 'PSDSCUseIdenticalParametersForDSC', 28 | 'PSMisleadingBacktick', 29 | 'PSMissingModuleManifestField', 30 | 'PSPossibleIncorrectComparisonWithNull', 31 | 'PSProvideCommentHelp', 32 | 'PSReservedCmdletChar', 33 | 'PSReservedParams', 34 | 'PSUseApprovedVerbs', 35 | 'PSUseCmdletCorrectly', 36 | 'PSUseOutputTypeCorrectly', 37 | 'PSAvoidGlobalVars', 38 | 'PSAvoidUsingConvertToSecureStringWithPlainText', 39 | 'PSAvoidUsingPlainTextForPassword', 40 | 'PSAvoidUsingUsernameAndPasswordParams', 41 | 'PSDSCUseVerboseMessageInDSCResource', 42 | 'PSShouldProcess', 43 | 'PSUseDeclaredVarsMoreThanAssignments', 44 | 'PSUsePSCredentialType', 45 | 46 | <# 47 | This is to test all the DSC Resource Kit custom rules. 48 | The name of the function-blocks of each custom rule start 49 | with 'Measure*'. 50 | #> 51 | 'Measure-*' 52 | ) 53 | } 54 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 14 | #### Pull Request (PR) description 15 | 18 | 19 | #### This Pull Request (PR) fixes the following issues 20 | 27 | 28 | #### Task list 29 | 37 | - [ ] Added an entry under the Unreleased section of the change log in the README.md. 38 | Entry should say what was changed, and how that affects users (if applicable). 39 | - [ ] Resource documentation added/updated in README.md. 40 | - [ ] Resource parameter descriptions added/updated in README.md, schema.mof 41 | and comment-based help. 42 | - [ ] Comment-based help added/updated. 43 | - [ ] Localization strings added/updated in all localization files as appropriate. 44 | - [ ] Examples appropriately added/updated. 45 | - [ ] Unit tests added/updated. See [DSC Resource Testing Guidelines](https://github.com/PowerShell/DscResources/blob/master/TestsGuidelines.md). 46 | - [ ] Integration tests added/updated (where possible). See [DSC Resource Testing Guidelines](https://github.com/PowerShell/DscResources/blob/master/TestsGuidelines.md). 47 | - [ ] New/changed code adheres to [DSC Resource Style Guidelines](https://github.com/PowerShell/DscResources/blob/master/StyleGuidelines.md) and [Best Practices](https://github.com/PowerShell/DscResources/blob/master/BestPractices.md). 48 | -------------------------------------------------------------------------------- /xRobocopy.psd1: -------------------------------------------------------------------------------- 1 | # 2 | # Module manifest for module 'xRobocopy' 3 | # 4 | # Generated by: PowerShell DSC 5 | # 6 | # Generated on: 6/15/2015 7 | # 8 | 9 | @{ 10 | 11 | # Script module or binary module file associated with this manifest. 12 | # RootModule = '' 13 | 14 | # Version number of this module. 15 | ModuleVersion = '2.0.0.0' 16 | 17 | # ID used to uniquely identify this module 18 | GUID = '3c743236-35b8-4225-b76b-5e6117c0e477' 19 | 20 | # Author of this module 21 | Author = 'PowerShell DSC' 22 | 23 | # Company or vendor of this module 24 | CompanyName = 'Microsoft Corporation' 25 | 26 | # Copyright statement for this module 27 | Copyright = '2015' 28 | 29 | # Description of the functionality provided by this module 30 | Description = 'This module is used to facilitate large file copies with complex requirements such as multithreading, restarts, and exclusions when recursing content.' 31 | 32 | # Minimum version of the Windows PowerShell engine required by this module 33 | PowerShellVersion = '4.0' 34 | 35 | # Name of the Windows PowerShell host required by this module 36 | # PowerShellHostName = '' 37 | 38 | # Minimum version of the Windows PowerShell host required by this module 39 | # PowerShellHostVersion = '' 40 | 41 | # Minimum version of Microsoft .NET Framework required by this module 42 | # DotNetFrameworkVersion = '' 43 | 44 | # Minimum version of the common language runtime (CLR) required by this module 45 | # CLRVersion = '' 46 | 47 | # Processor architecture (None, X86, Amd64) required by this module 48 | # ProcessorArchitecture = '' 49 | 50 | # Modules that must be imported into the global environment prior to importing this module 51 | # RequiredModules = @() 52 | 53 | # Assemblies that must be loaded prior to importing this module 54 | # RequiredAssemblies = @() 55 | 56 | # Script files (.ps1) that are run in the caller's environment prior to importing this module. 57 | # ScriptsToProcess = @() 58 | 59 | # Type files (.ps1xml) to be loaded when importing this module 60 | # TypesToProcess = @() 61 | 62 | # Format files (.ps1xml) to be loaded when importing this module 63 | # FormatsToProcess = @() 64 | 65 | # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess 66 | # NestedModules = @() 67 | 68 | # Functions to export from this module 69 | FunctionsToExport = '*' 70 | 71 | # Cmdlets to export from this module 72 | CmdletsToExport = '*' 73 | 74 | # Variables to export from this module 75 | VariablesToExport = '*' 76 | 77 | # Aliases to export from this module 78 | AliasesToExport = '*' 79 | 80 | # DSC resources to export from this module 81 | # DscResourcesToExport = @() 82 | 83 | # List of all modules packaged with this module 84 | # ModuleList = @() 85 | 86 | # List of all files packaged with this module 87 | # FileList = @() 88 | 89 | # 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. 90 | PrivateData = @{ 91 | 92 | PSData = @{ 93 | 94 | # Tags applied to this module. These help with module discovery in online galleries. 95 | Tags = @('DesiredStateConfiguration', 'DSC', 'DSCResourceKit', 'DSCResource') 96 | 97 | # A URL to the license for this module. 98 | LicenseUri = 'https://github.com/PowerShell/xRobocopy/blob/master/LICENSE' 99 | 100 | # A URL to the main website for this project. 101 | ProjectUri = 'https://github.com/PowerShell/xRobocopy' 102 | 103 | # A URL to an icon representing this module. 104 | # IconUri = '' 105 | 106 | # ReleaseNotes of this module 107 | ReleaseNotes = '* Improved Test-TargetResource method to run robocopy with the same parameters as in Set-TargetResource 108 | * Bug fix in Test-TargetResource when evaluating return code from robocopy 109 | * Updated example to use correct PsDscRunAsCredential parameter 110 | * **Breaking Change:** Changed AditionalArgs parameter to Array of String 111 | * Added additional examples with different copy options. 112 | 113 | ' 114 | 115 | } # End of PSData hashtable 116 | 117 | } # End of PrivateData hashtable 118 | 119 | # HelpInfo URI of this module 120 | # HelpInfoURI = '' 121 | 122 | # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. 123 | # DefaultCommandPrefix = '' 124 | 125 | } 126 | 127 | -------------------------------------------------------------------------------- /DSCResources/MSFT_xRobocopy/MSFT_xRobocopy.psm1: -------------------------------------------------------------------------------- 1 | function Get-TargetResource 2 | { 3 | [CmdletBinding()] 4 | [OutputType([System.Collections.Hashtable])] 5 | param 6 | ( 7 | [parameter(Mandatory = $true)] 8 | [System.String] 9 | $Source, 10 | 11 | [parameter(Mandatory = $true)] 12 | [System.String] 13 | $Destination, 14 | 15 | [System.String] 16 | $Files, 17 | 18 | [System.UInt32] 19 | $Retry, 20 | 21 | [System.UInt32] 22 | $Wait, 23 | 24 | [System.Boolean] 25 | $SubdirectoriesIncludingEmpty = $False, 26 | 27 | [System.Boolean] 28 | $Restartable = $False, 29 | 30 | [System.Boolean] 31 | $MultiThreaded = $False, 32 | 33 | [System.String] 34 | $ExcludeFiles, 35 | 36 | [System.String] 37 | $LogOutput, 38 | 39 | [System.Boolean] 40 | $AppendLog = $False, 41 | 42 | [System.String[]] 43 | $AdditionalArgs 44 | ) 45 | 46 | $result = Test-TargetResource $Source $Destination $Files $Retry $Wait $SubdirectoriesIncludingEmpty $Restartable $MultiThreaded $ExcludeFiles $LogOutput $AppendLog $AdditionalArgs 47 | $ensure = 'Absent' 48 | if($result -eq $true) 49 | { 50 | $ensure = 'Present' 51 | } 52 | 53 | $returnValue = @{ 54 | Source = $Source 55 | Destination = $Destination 56 | Files = $Files 57 | Retry = $Retry 58 | Wait = $Wait 59 | SubdirectoriesIncludingEmpty = $SubdirectoriesIncludingEmpty 60 | Restartable = $Restartable 61 | MultiThreaded = $MultiThreaded 62 | ExcludeFiles = $ExcludeFiles 63 | LogOutput = $LogOutput 64 | AppendLog = $AppendLog 65 | AdditionalArgs = $AdditionalArgs 66 | Ensure = $ensure 67 | } 68 | 69 | return $returnValue 70 | } 71 | 72 | function Set-TargetResource 73 | { 74 | [CmdletBinding()] 75 | param 76 | ( 77 | [parameter(Mandatory = $true)] 78 | [System.String] 79 | $Source, 80 | 81 | [parameter(Mandatory = $true)] 82 | [System.String] 83 | $Destination, 84 | 85 | [System.String] 86 | $Files, 87 | 88 | [System.UInt32] 89 | $Retry, 90 | 91 | [System.UInt32] 92 | $Wait, 93 | 94 | [System.Boolean] 95 | $SubdirectoriesIncludingEmpty = $False, 96 | 97 | [System.Boolean] 98 | $Restartable = $False, 99 | 100 | [System.Boolean] 101 | $MultiThreaded = $False, 102 | 103 | [System.String] 104 | $ExcludeFiles, 105 | 106 | [System.String] 107 | $LogOutput, 108 | 109 | [System.Boolean] 110 | $AppendLog = $False, 111 | 112 | [System.String[]] 113 | $AdditionalArgs 114 | ) 115 | 116 | $arguments = Get-RobocopyArguments $Source $Destination $Files $Retry $Wait $SubdirectoriesIncludingEmpty $Restartable $MultiThreaded $ExcludeFiles $LogOutput $AppendLog $AdditionalArgs 117 | 118 | Write-Verbose "Executing robocopy.exe with: $arguments" 119 | &robocopy $arguments | Out-Null 120 | if($LASTEXITCODE -ge 8) 121 | { 122 | throw "robocopy returned with errors! Exit code: $LASTEXITCODE! More info here:https://support.microsoft.com/en-us/kb/954404" 123 | } 124 | } 125 | 126 | function Test-TargetResource 127 | { 128 | [CmdletBinding()] 129 | [OutputType([System.Boolean])] 130 | param 131 | ( 132 | [parameter(Mandatory = $true)] 133 | [System.String] 134 | $Source, 135 | 136 | [parameter(Mandatory = $true)] 137 | [System.String] 138 | $Destination, 139 | 140 | [System.String] 141 | $Files, 142 | 143 | [System.UInt32] 144 | $Retry, 145 | 146 | [System.UInt32] 147 | $Wait, 148 | 149 | [System.Boolean] 150 | $SubdirectoriesIncludingEmpty = $False, 151 | 152 | [System.Boolean] 153 | $Restartable = $False, 154 | 155 | [System.Boolean] 156 | $MultiThreaded = $False, 157 | 158 | [System.String] 159 | $ExcludeFiles, 160 | 161 | [System.String] 162 | $LogOutput, 163 | 164 | [System.Boolean] 165 | $AppendLog = $False, 166 | 167 | [System.String[]] 168 | $AdditionalArgs 169 | ) 170 | 171 | $arguments = Get-RobocopyArguments $Source $Destination $Files $Retry $Wait $SubdirectoriesIncludingEmpty $Restartable $MultiThreaded $ExcludeFiles $LogOutput $AppendLog $AdditionalArgs 172 | 173 | if(!$arguments.Contains('/L') -and !$arguments.Contains('/l')) 174 | { 175 | $arguments += '/L' 176 | } 177 | 178 | &robocopy $arguments | Out-Null 179 | 180 | # https://support.microsoft.com/en-us/kb/954404 181 | # ROBOCOPY $LASTEXITCODE is a bitflag: 182 | # 0: Source and destination are completely synchronized 183 | # 1: One or more files were copied successfully (new files present) 184 | # 2: extra files/directories detected 185 | # 4: mismatched files/directories 186 | # 8: copy errors and retries exceeded 187 | # 16: serious error 188 | if ($LASTEXITCODE -ge 1 -and $LASTEXITCODE -lt 8) 189 | { 190 | Write-Verbose "Source and destination are out of sync" 191 | $result = $false 192 | } 193 | elseif ($LASTEXITCODE -eq 0) 194 | { 195 | Write-Verbose "Source and destination are completely synchronized" 196 | $result = $true 197 | } 198 | else 199 | { 200 | throw "robocopy returned with errors! Exit code: $result! More info here:https://support.microsoft.com/en-us/kb/954404" 201 | } 202 | 203 | return $result 204 | } 205 | 206 | # Helper Functions 207 | function Get-RobocopyArguments 208 | { 209 | [CmdletBinding()] 210 | [OutputType([System.String[]])] 211 | param 212 | ( 213 | [parameter(Mandatory = $true)] 214 | [System.String] 215 | $Source, 216 | 217 | [parameter(Mandatory = $true)] 218 | [System.String] 219 | $Destination, 220 | 221 | [System.String] 222 | $Files, 223 | 224 | [System.UInt32] 225 | $Retry, 226 | 227 | [System.UInt32] 228 | $Wait, 229 | 230 | [System.Boolean] 231 | $SubdirectoriesIncludingEmpty, 232 | 233 | [System.Boolean] 234 | $Restartable, 235 | 236 | [System.Boolean] 237 | $MultiThreaded, 238 | 239 | [System.String] 240 | $ExcludeFiles, 241 | 242 | [System.String] 243 | $LogOutput, 244 | 245 | [System.Boolean] 246 | $AppendLog, 247 | 248 | [System.String[]] 249 | $AdditionalArgs 250 | ) 251 | 252 | [System.String[]]$arguments = @($Source, $Destination) 253 | if($Files) 254 | { 255 | $arguments += $Files 256 | } 257 | if ($Retry) 258 | { 259 | $arguments += "/R:$Retry" 260 | } 261 | if ($Wait) 262 | { 263 | $arguments += "/W:$Wait" 264 | } 265 | if ($SubdirectoriesIncludingEmpty) 266 | { 267 | $arguments += '/E' 268 | } 269 | if ($Restartable) 270 | { 271 | $arguments += '/Z' 272 | } 273 | if ($MultiThreaded) 274 | { 275 | $arguments += '/MT' 276 | } 277 | if ($ExcludeFiles) 278 | { 279 | $arguments += @('/XF', $ExcludeFiles) 280 | } 281 | if ($ExcludeDirs) 282 | { 283 | $arguments += @('/XD', $ExcludeDirs) 284 | } 285 | if ($LogOutput -AND $AppendLog) 286 | { 287 | $arguments += "/LOG+:$LogOutput" 288 | } 289 | if ($LogOutput -AND !$AppendLog) 290 | { 291 | $arguments += "/LOG:$LogOutput" 292 | } 293 | if ($AdditionalArgs) 294 | { 295 | $arguments += $AdditionalArgs 296 | } 297 | 298 | return $arguments 299 | } 300 | 301 | Export-ModuleMember -Function *-TargetResource 302 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build status](https://ci.appveyor.com/api/projects/status/gooo7e8b374v45j6/branch/master?svg=true)](https://ci.appveyor.com/project/PowerShell/xrobocopy/branch/master) 2 | 3 | # xRobocopy 4 | 5 | The **xRobocopy** module is a part of the Windows PowerShell Desired State Configuration (DSC) Resource Kit, which is a collection of DSC Resources. This module is used to facilitate large file copies with complex requirements such as multithreading, restarts, and exclusions when recursing content., with simple declarative language. 6 | 7 | **All of the resources in the DSC Resource Kit are provided AS IS, and are not supported through any Microsoft standard support program or service. The "x" in xRobocopy stands for experimental**, which means that these resources will be **fix forward** and monitored by the module owner(s). 8 | 9 | Please leave comments, feature requests, and bug reports in the Q & A tab for 10 | this module. 11 | 12 | If you would like to modify the **xRobocopy** module, feel free. When modifying, please update the module name, resource friendly name, and MOF class name (instructions below). As specified in the license, you may copy or modify this resource as long as they are used on the Windows Platform. 13 | 14 | For more information about Windows PowerShell Desired State Configuration, check out the blog posts on the [PowerShell Blog](http://blogs.msdn.com/b/powershell/) ([this](http://blogs.msdn.com/b/powershell/archive/2013/11/01/configuration-in-a-devops-world-windows-powershell-desired-state-configuration.aspx) is a good starting point). There are also great community resources, such as [PowerShell.org](http://powershell.org/wp/tag/dsc/), or [PowerShell Magazine](http://www.powershellmagazine.com/tag/dsc/). For more information on the DSC Resource Kit, checkout [this blog post](http://go.microsoft.com/fwlink/?LinkID=389546). 15 | 16 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 17 | For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. 18 | 19 | Installation 20 | ------------ 21 | 22 | To install **xRobocopy** module 23 | 24 | - If you are using WMF4 / PowerShell Version 4: Unzip the content under the C:\Program Files\WindowsPowerShell\Modules folder 25 | 26 | - If you are using WMF5 Preview: From an elevated PowerShell session run "Install-Module xRobocopy" 27 | 28 | To confirm installation 29 | 30 | - Run Get-DSCResource to see that the resources listed above are among the DSC Resources displayed 31 | 32 | Requirements 33 | ------------ 34 | 35 | This module requires the latest version of PowerShell (v4.0, which ships in 36 | Windows 8.1 or Windows Server 2012R2). To easily use PowerShell 4.0 on older 37 | operating systems, install WMF 4.0. Please read the installation instructions 38 | that are present on both the download page and the release notes for WMF 4.0. 39 | 40 | Details 41 | ------- 42 | **xRobocopy** resource has following properties 43 | - **Source**: Source Directory, Drive or UNC path. 44 | - **Destination**: Destination Dir, Drive or UNC path. 45 | - **Files**: File(s) to copy (names/wildcards: default is all files). 46 | - **Retry**: Number of Retries on failed copies: default 1 million. 47 | - **Wait**: Wait time between retries: default is 30 seconds. 48 | - **SubdirectoriesIncludingEmpty**: Copy subdirectories, including Empty ones. 49 | - **Restartable**: Copy files in restartable mode. 50 | - **MultiThreaded**: Do multi-threaded copies with n threads (default 8). N 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. 51 | - **ExcludeFiles**: Exclude Files matching given names/paths/wildcards. 52 | - **LogOutput**: Output status to LOG file. 53 | - **AppendLog**: Determine whether to overwrite log file or append. 54 | - **AdditionalArgs**: Robocopy has MANY configuration options. Too many to present them all as DSC parameters effectively. Use this option to set additional parameters. Each parameter should be a separate array member. This array will be combined with main argument array. For a list of options run Robocopy /??? in a shell window. 55 | - **Ensure**: (Readonly). Will indicate whether Destination is in sync with Source. 56 | 57 | Renaming Requirements 58 | --------------------- 59 | 60 | When making changes to these resources, we suggest the following practice 61 | 62 | 1. Update the following names by replacing MSFT with your company/community name 63 | and replacing the **"x" with **"c" (short for "Community") or another prefix of your 64 | choice 65 | - Module name (ex: xModule becomes cModule) 66 | - Resource folder (ex: MSFT\_xResource becomes Contoso\_xResource) 67 | - Resource Name (ex: MSFT\_xResource becomes Contoso\_cResource) 68 | - Resource Friendly Name (ex: xResource becomes cResource) 69 | - MOF class name (ex: MSFT\_xResource becomes Contoso\_cResource) 70 | - Filename for the .schema.mof (ex: MSFT\_xResource.schema.mof becomes Contoso\_cResource.schema.mof) 71 | 72 | 2. Update module and metadata information in the module manifest 73 | 3. Update any configuration that use these resources 74 | 75 | We reserve resource and module names without prefixes ("x" or "c") for future use (e.g. "MSFT_Resource"). If the next version of Windows Server ships with a "WindowsEventForwarding" resource, we don't want to break any configurations that use any community modifications. Please keep a prefix such as "c" on all community modifications. 76 | 77 | ## Versions 78 | 79 | ### Unreleased 80 | 81 | * Update appveyor.yml to use the default template. 82 | * Activated the GitHub App Stale on the GitHub repository. 83 | * Fixed new line in example xRobocopy.NetworkAndCredentials.ps1 that failed tests. 84 | * Added .gitignore file. 85 | * Added default template files .codecov.yml, .gitattributes, and .gitignore, and 86 | .vscode folder. 87 | 88 | ### 2.0.0.0 89 | 90 | * Improved Test-TargetResource method to run robocopy with the same parameters as in Set-TargetResource 91 | * Bug fix in Test-TargetResource when evaluating return code from robocopy 92 | * Updated example to use correct PsDscRunAsCredential parameter 93 | * **Breaking Change:** Changed AditionalArgs parameter to Array of String 94 | * Added additional examples with different copy options. 95 | 96 | ### 1.2.0.0 97 | 98 | * Improvements in error handling 99 | 100 | ### 1.1.0.0 101 | 102 | * Updated Get-TargetResource function 103 | 104 | ### 1.0.0.0 105 | 106 | * Initial public release of xRobocopy module with following resources: 107 | * xRobocopy 108 | 109 | Examples 110 | -------- 111 | 112 | **Example 1**: Copy a directory from one location to another with multithreading and restartable mode. Note that this example is using PSRunAsCredential which is a common parameter only available in WMF5 and later. 113 | ```powershell 114 | configuration DeployContent 115 | { 116 | param ( 117 | [Parameter(Mandatory=$true)] 118 | [ValidateNotNullorEmpty()] 119 | [PsCredential] $Credential 120 | ) 121 | 122 | Import-DscResource -ModuleName xRobocopy 123 | Node 'localhost' 124 | { 125 | xRobocopy Content 126 | { 127 | Source = '\\server\share\ReleaseVersion' 128 | Destination = 'C:\inetpub\wwwroot\sitename' 129 | MultiThreaded = $true 130 | Restartable = $true 131 | PsDscRunAsCredential = $Credential 132 | } 133 | } 134 | } 135 | $configData = @{ 136 | AllNodes = @( 137 | @{ 138 | NodeName = 'localhost'; 139 | CertificateId = 'Your Certificate thumbprint here' 140 | } 141 | ) 142 | } 143 | DeployContent -ConfigurationData $configData -Credential (get-credential) -OutputPath 'c:\DSC' 144 | Start-DscConfiguration -Wait -Force -Verbose -Path 'c:\DSC' 145 | 146 | # Validate results 147 | Get-ChildItem C:\inetpub\wwwroot\sitename 148 | ``` 149 | 150 | ## Contributing 151 | Please check out common DSC Resources [contributing guidelines](https://github.com/PowerShell/DscResource.Kit/blob/master/CONTRIBUTING.md). 152 | -------------------------------------------------------------------------------- /Resources/xDscResourceDesigner_CreateScript.ps1: -------------------------------------------------------------------------------- 1 | $modules = 'C:\Program Files\WindowsPowerShell\Modules\' 2 | $modulename = 'xRobocopy' 3 | $Description = 'This module is used to facilitate large file copies with complex requirements such as multithreading, restarts, and exclusions when recursing content.' 4 | 5 | if (!(test-path (join-path $modules $modulename))) { 6 | 7 | $modulefolder = mkdir (join-path $modules $modulename) 8 | New-ModuleManifest -Path (join-path $modulefolder "$modulename.psd1") -Guid $([system.guid]::newguid().guid) -Author 'PowerShell DSC' -CompanyName 'Microsoft Corporation' -Copyright '2015' -ModuleVersion '0.1.0.0' -Description $Description -PowerShellVersion '4.0' 9 | 10 | $standard = @{ModuleName = $modulename 11 | ClassVersion = '0.1.0.0' 12 | Path = $modules 13 | } 14 | $P1 = @() 15 | $P1 += New-xDscResourceProperty -Name Source -Type String -Attribute Key -Description 'Source Directory, Drive or UNC path.' 16 | $P1 += New-xDscResourceProperty -Name Destination -Type String -Attribute Key -Description 'Destination Dir, Drive or UNC path.' 17 | $P1 += New-xDscResourceProperty -Name Files -Type String -Attribute Write -Description 'File(s) to copy (names/wildcards: default is all files).' 18 | $P1 += New-xDscResourceProperty -Name Retry -Type UInt32 -Attribute Write -Description 'Number of Retries on failed copies: default 1 million.' 19 | $P1 += New-xDscResourceProperty -Name Wait -Type UInt32 -Attribute Write -Description 'Wait time between retries: default is 30 seconds.' 20 | $P1 += New-xDscResourceProperty -Name SubdirectoriesIncludingEmpty -Type Boolean -Attribute Write -Description 'Copy subdirectories, including Empty ones.' 21 | $P1 += New-xDscResourceProperty -Name Restartable -Type Boolean -Attribute Write -Description 'Copy files in restartable mode.' 22 | $P1 += New-xDscResourceProperty -Name MultiThreaded -Type Boolean -Attribute Write -Description 'Do multi-threaded copies with n threads (default 8). N 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.' 23 | $P1 += New-xDscResourceProperty -Name ExcludeFiles -Type String -Attribute Write -Description 'Exclude Files matching given names/paths/wildcards.' 24 | $P1 += New-xDscResourceProperty -Name LogOutput -Type String -Attribute Write -Description 'Output status to LOG file.' 25 | $P1 += New-xDscResourceProperty -Name AppendLog -Type Boolean -Attribute Write -Description 'Determine whether to overwrite log file or append.' 26 | $P1 += New-xDscResourceProperty -Name AdditionalArgs -Type String -Attribute Write -Description 'Robocopy has MANY configuration options. Too many to present them all as DSC parameters effectively. Use this option to set additional parameters. The string will be appended to the arguements list. For a list of options run Robocopy /??? in a shell window.' 27 | New-xDscResource -Name MSFT_xRobocopy -Property $P1 -FriendlyName xRobocopy @standard 28 | } 29 | 30 | 31 | # Markdown Generator # 32 | # This is a first draft. Expected to become 100% efficient in future version. Loop resources, import example from script, etc. 33 | 34 | if (!(test-path "$modules\$modulename\Resources\")){mkdir "$modules\$modulename\Resources\"} 35 | 36 | $MD = @" 37 | Introduction 38 | ============ 39 | 40 | The **$ModuleName** module is a part of the Windows PowerShell Desired State Configuration (DSC) Resource Kit, which is a collection of DSC Resources. $Description, with simple declarative language. 41 | 42 | **All of the resources in the DSC Resource Kit are provided AS IS, and are not supported through any Microsoft standard support program or service. The "x" in $ModuleName stands for experimental**, which means that these resources will be **fix forward** and monitored by the module owner(s). 43 | 44 | Please leave comments, feature requests, and bug reports in the Q & A tab for 45 | this module. 46 | 47 | If you would like to modify the **$ModuleName** module, feel free. When modifying, please update the module name, resource friendly name, and MOF class name (instructions below). As specified in the license, you may copy or modify this resource as long as they are used on the Windows Platform. 48 | 49 | For more information about Windows PowerShell Desired State Configuration, check out the blog posts on the [PowerShell Blog](http://blogs.msdn.com/b/powershell/) ([this](http://blogs.msdn.com/b/powershell/archive/2013/11/01/configuration-in-a-devops-world-windows-powershell-desired-state-configuration.aspx) is a good starting point). There are also great community resources, such as [PowerShell.org](http://powershell.org/wp/tag/dsc/), or [PowerShell Magazine](http://www.powershellmagazine.com/tag/dsc/). For more information on the DSC Resource Kit, checkout [this blog post](http://go.microsoft.com/fwlink/?LinkID=389546). 50 | 51 | Installation 52 | ------------ 53 | 54 | To install **$ModuleName** module 55 | 56 | - If you are using WMF4 / PowerShell Version 4: Unzip the content under the $env:ProgramFiles\WindowsPowerShell\Modules folder 57 | 58 | - If you are using WMF5 Preview: From an elevated PowerShell session run "Install-Module $ModuleName" 59 | 60 | To confirm installation 61 | 62 | - Run Get-DSCResource to see that the resources listed above are among the DSC Resources displayed 63 | 64 | Requirements 65 | ------------ 66 | 67 | This module requires the latest version of PowerShell (v4.0, which ships in 68 | Windows 8.1 or Windows Server 2012R2). To easily use PowerShell 4.0 on older 69 | operating systems, install WMF 4.0. Please read the installation instructions 70 | that are present on both the download page and the release notes for WMF 4.0. 71 | 72 | Details 73 | ------- 74 | **$Resource1** resource has following properties 75 | 76 | "@ 77 | foreach ($res in $P1) {$MD += @" 78 | - **$($res.Name)**: $($res.Description) 79 | 80 | "@ 81 | } 82 | $MD += @" 83 | 84 | Renaming Requirements 85 | --------------------- 86 | 87 | When making changes to these resources, we suggest the following practice 88 | 89 | 1. Update the following names by replacing MSFT with your company/community name 90 | and replacing the **"x" with **"c" (short for "Community") or another prefix of your 91 | choice 92 | - Module name (ex: xModule becomes cModule) 93 | - Resource folder (ex: MSFT\_xResource becomes Contoso\_xResource) 94 | - Resource Name (ex: MSFT\_xResource becomes Contoso\_cResource) 95 | - Resource Friendly Name (ex: xResource becomes cResource) 96 | - MOF class name (ex: MSFT\_xResource becomes Contoso\_cResource) 97 | - Filename for the .schema.mof (ex: MSFT\_xResource.schema.mof becomes Contoso\_cResource.schema.mof) 98 | 99 | 2. Update module and metadata information in the module manifest 100 | 3. Update any configuration that use these resources 101 | 102 | We reserve resource and module names without prefixes ("x" or "c") for future use (e.g. "MSFT_Resource"). If the next version of Windows Server ships with a "WindowsEventForwarding" resource, we don't want to break any configurations that use any community modifications. Please keep a prefix such as "c" on all community modifications. 103 | 104 | Versions 105 | -------- 106 | 107 | **0.1.0.0** 108 | 109 | - Initial release with the following resources 110 | "@ 111 | foreach ($res in $P1) {$MD += @" 112 | - $($res.Name) 113 | 114 | "@ 115 | } 116 | $MD += @' 117 | 118 | Examples 119 | -------- 120 | 121 | **Example 1**: Copy a directory from one location to another with multithreading and restartable mode. Note that this example is using PSRunAsCredential which is a common parameter only available in WMF5 and later. 122 | ```powershell 123 | configuration DeployContent 124 | { 125 | param ( 126 | [Parameter(Mandatory=$true)] 127 | [ValidateNotNullorEmpty()] 128 | [PsCredential] $Credential 129 | ) 130 | 131 | Import-DscResource -ModuleName xRobocopy 132 | Node 'localhost' 133 | { 134 | xRobocopy Content 135 | { 136 | Source = '\\server\share\ReleaseVersion' 137 | Destination = 'C:\inetpub\wwwroot\sitename' 138 | Multithread = $true 139 | Restartable = $true 140 | PSRunAsCredential = $Credential 141 | } 142 | } 143 | } 144 | $configData = @{ 145 | AllNodes = @( 146 | @{ 147 | NodeName = 'localhost'; 148 | CertificateId = 'Your Certificate thumbprint here' 149 | } 150 | ) 151 | } 152 | DeployContent -ConfigurationData $configData -Credential (get-credential) -OutputPath 'c:\DSC' 153 | Start-DscConfiguration -Wait -Force -Verbose -Path 'c:\DSC' 154 | 155 | # Validate results 156 | Get-ChildItem C:\inetpub\wwwroot\sitename 157 | ``` 158 | 159 | ## Contributing 160 | Please check out common DSC Resources [contributing guidelines](https://github.com/PowerShell/DscResource.Kit/blob/master/CONTRIBUTING.md). 161 | '@ 162 | $MD | Out-File "$modules\$modulename\Resources\ReadMe.md" 163 | --------------------------------------------------------------------------------