I am working on a script that needs RoboCopy switches to be passed in dynamically based on user input, hence using array
seems like the best option. However I see the following issue when using I specify parameters like /XF
that have a space and value.
This works as expected:
RoboCopy C:\Dir1 C:\Dir2 /NP /NFL /NS /NDL /NJH /NJS /XF *.config
This works as expected:
$Switches = @("/NP", "/NFL", "/NS", "/NDL", "/NJH", "/NJS", "/E")
RoboCopy C:\Dir1 C:\Dir2 $Switches
This throws ERROR : Invalid Parameter #10 : "/XF *.config"
:
$Switches = @("/NP", "/NFL", "/NS", "/NDL", "/NJH", "/NJS", "/E", "/XF *.config")
RoboCopy C:\Dir1 C:\Dir2 $Switches
I tried few things like using quotes with /XF
parameter but no success. Any hint/help is appreciated.
Can you try this, I can't test it but let me know..:
$Switches = @("/NP", "/NFL", "/NS", "/NDL", "/NJH", "/NJS", "/E", "/XF", "*.config")
My variant (more XD/XF parameters):
$RobocopyParams = @("/NP", "/NFL", "/NS", "/NDL", "/NJH", "/NJS", "/E")
$XD = @("Cookies", "His6", "SendTo", "Temp", "Temporary Internet Files", "Windows")
$XF = @("*.pif", "$UserName.INI", "$UserName.OPS", "$UserName.INI.*")
robocopy.exe @params /XD @XD /XF @XF
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With