I am working on a script that requires RoboCopy switches to be passed dynamically based on user input, so using arrayseems like the best option. However, when used, I specify the following parameters: /XFwhich have a space and a value.
It works as expected:
RoboCopy C:\Dir1 C:\Dir2 /NP /NFL /NS /NDL /NJH /NJS /XF *.config
It works as expected:
$Switches = @("/NP", "/NFL", "/NS", "/NDL", "/NJH", "/NJS", "/E")
RoboCopy C:\Dir1 C:\Dir2 $Switches
This causes ERROR : Invalid Parameter #10 : "/XF *.config":
$Switches = @("/NP", "/NFL", "/NS", "/NDL", "/NJH", "/NJS", "/E", "/XF *.config")
RoboCopy C:\Dir1 C:\Dir2 $Switches
I tried several things, such as using quotation marks with a parameter /XF, but without success. Any hints / help are appreciated.
source
share