Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources: Active Threads
Viewing all articles
Browse latest Browse all 8411

Variables for DOS parameters with function

$
0
0

Hi,

I would like to create a function with dos command(xcopy) and to create for this DOS command paramaters in variables (

original dos command with paramters: "xcopy C:\Temp\Force2.csv C:\ssm /S /E >>c:\Temp\xcopylog.txt"

) something like this:

function copyonefile {
$source = "C:\Temp\Force2.csv"

$destination = "C:\ssm"
$options = "/S /E"
$log = ">>c:\Temp\xcopylog.txt"
$argarray = @("$source","$destination","$options","$log")
C:\Windows\System32\xcopy.exe $argarray }

Unfortunately, it's not working, can you advise?


Viewing all articles
Browse latest Browse all 8411