Skip to content

Not splatting properly for ExcludeDirs and ExcludeFiles on Dev branch #19

@gerane

Description

@gerane

These two params are not working properly. If excluding multiple Files or Directories it thinks they are a single file.

if ($ExcludeFiles) 
    {
        $arguments += @('/XF', $ExcludeFiles)
    }
    if ($ExcludeDirs) 
    {
        $arguments += @('/XD', $ExcludeDirs)
    }

Exclude Directories is actually missing from the parameters as well, so it is being checked for, but not actually available.

Currently, when robocopy runs, the output looks like this

Exclude Dirs

Files : *.*

Exc Dirs : Files Private

Options : *.* /S /E /DCOPY:DA /COPY:DAT /PURGE /MIR /R:1000000 /W:30 

Exclude Files

Files : *.*

Exc Files : Invoke-test.ps1xml Test-*

Options : *.* /S /E /DCOPY:DA /COPY:DAT /PURGE /MIR /R:1000000 /W:30

The files should be on separate lines line the following output.

Exclude Dirs

Files : *.*

Exc Dirs : Files
           Private

Options : *.* /S /E /DCOPY:DA /COPY:DAT /PURGE /MIR /R:1000000 /W:30

Exclude Files

Files : *.*

Exc Files : Invoke-test.format.ps1xml
            Test-*

Options : *.* /S /E /DCOPY:DA /COPY:DAT /PURGE /MIR /R:1000000 /W:30

One way you could handle this is to take ExcludeFolders and ExcludeFiles as arrays, and then add them to the arguments like this.

    if ($ExcludeFiles) 
    {
        $arguments += '/XF'
        $arguments += $ExcludeFiles
    }
    if ($ExcludeDirs) 
    {
        $arguments += '/XD'
        $arguments += $ExcludeDirs
    }

Then even if the files or folders have spaces in their names it works without issue.

An Example when passing arrays:

Files : *.*

Exc Files : Invoke-test.format.ps1xml
             Test-*

Exc Dirs : Files
            Private with spaces

Options : *.* /S /E /DCOPY:DA /COPY:DAT /PURGE /MIR /R:1000000 /W:30

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThe issue is a bug.help wantedThe issue is up for grabs for anyone in the community.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions