Copying a File From Share Drive To Remote Desktop Using PowerShell

0

Im currently running the task of putting a start up script that i have on every computer on the network using powershell and this is what i have so far

robocopy "S:\03 - Section Folders\04 - SCM\scripts\startupscript.vbs" 
"$cheese\c$\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup" /r:1 /w:0

so far when i run it i get an error

2020/06/23 14:40:56 ERROR 267 (0x0000010B) Accessing Source Directory S:\03 - Section Folders\04 - 
SCM\scripts\startupscript.vbs\
The directory name is invalid.

the intended outcome for this script is to pull the file i need form a network drive and save it to all of the computers on the network. as far as i can tell my only problem is that the file path from the network drive isn't being recognized.

powershell
remote-access
filepath
network-drive
asked on Stack Overflow Jun 23, 2020 by Zizzay

1 Answer

0

Zizzay,

Since you're only copying a single file I would recommend not using RoboCopy but rather Copy-Item.

$CIArgs = @{
    Path        = $("S:\03 - Section Folders\04 - " +
                     "SCM\scripts\startupscript.vbs")
    Destination = $("$cheese\c$\ProgramData\Microsoft\" +
                    "Windows\Start Menu\Programs\Startup")
    Force       = $True
}

Copy-Item @CIArgs

HTH

answered on Stack Overflow Jun 30, 2020 by RetiredGeek

User contributions licensed under CC BY-SA 3.0