[ACCEPTED]-Can I copy files to a Network Place from a script or the command line?-wss

Accepted answer
Score: 19

Using a batch file, you can both log on 2 to the resource and copy the file:

The Batch 1 File would contain the following:

net use \\{dest-machine}\{destfolder} {password} /user:{username}
copy {file} \\{dest-machine}\{destfolder}

e.g.

net use \\Development\myfolder mypassword /user:Administrator
copy newfile.c \\development\myfolder
Score: 6

If you are referring to a windows box, just use xcopy. It 1 is pretty standard to have xcopy available.

xcopy src \\dest-machine\shared-library-name\dest
xcopy \\src-machine\shared-library-name\dest src
Score: 3

Powershell uses the abstraction of Providers 9 to provide a common interface into datastores. These 8 seem to stick with the common noun "Item", so 7 you can get a complete list with man *item*. If you 6 know another way to copy and otherwise work 5 with data from a store, you might as well 4 use it, but using the cmdlets provides a 3 better "learn-once, use-often" approach. In 2 your case you could:

Copy-Item test.txt -Destination \\dest-machine\share

Copy-item also supports 1 the -Credential parameter if you need it.

Score: 2

"Network Places" doesn't really 5 have an API, it's just a bunch of shortcuts, and 4 the SharePoint share uses a Shell Extension, if 3 I recall correctly.

All of that to say: accessing 2 Sharepoint as a file system from PowerShell 1 also requires an extension, the SharePoint Provider.

Score: 1

you could use the 'net' commands to authenticate 2 and then copy the files.

copy src \\dest-machine\shared-library-name\dest

I'm not really sure exactly 1 how to handle authentication if it's needed.

Score: 1

From what I'm seeing, it seems that it's 15 not possible to directly access/ manipulate 14 a Network Place from the command line, be 13 it in PowerShell or the plain ol' command 12 prompt.

@slipsec (#13899): Thanks for the 11 suggestion, but PowerShell doesn't support 10 the port number in the destination path 9 any more than the net use command does.

So the best 8 thing I can figure to do in my particular 7 situation is bite the bullet and buy something 6 like WebDrive to enable drive mapping via 5 WebDAV on non-standard ports, or do some 4 different configuration (e.g. separate web 3 app with a different IP address and host 2 headers) in SharePoint to expose the site 1 via NTLM on a standard port.

Score: 0

If it's something you need to script, you 4 should consider NAnt.

It's a mainly used for 3 build scripts, but it's very powerful and 2 reasonably easy to get started with.

There's 1 also NAntContrib and the nant ftp task which should help you out.

Score: 0

I could be wrong about this, but I think 13 that neither Nick's robocopy solution or 12 Nathan's copy command solution will work. Robocopy 11 seems to want a mapped drive, which I can't 10 do because it's not running on port 80 or 9 443, and Windows can't handle a path that 8 includes the port in a UNC-style name:

copy src \\dest-machine:45000\shared-library-name\dest

I 7 didn't see a NAnt task that would handle 6 this situation, either.

I also know there 5 are tools that will allow me to map WebDAV 4 drives. I was more wondering if there was 3 some way to make use of the Network Places 2 that have been set up without using the 1 GUI.

More Related questions