<p>Is it possible, in Windows XP, to copy files to a Network Place from the command line, a batch file or, even better, a PowerShell script?</p>

<p>What sent me down this road of research was trying to publish files to a WSS 3.0 document library from a user's machine. I can't map a drive to the library in question because the WSS site is only available to authenticate via NTLM on a port other than 80 or 443. I suppose I could alternately use the WSS web services to push the files out, but I'm really curious about the answer to this question now.</p>

[{'answer_id': 10315, 'author': 'Nick Berardi', 'author_id': 17, 'author_profile': 'https://Stackoverflow.com/users/17', 'pm_score': -1, 'selected': False, 'text': '<p>Yes you can.  I suggest using a tool like robocopy.</p>\n'}, {'answer_id': 10317, 'author': 'Nathan Fellman', 'author_id': 1084, 'author_profile': 'https://Stackoverflow.com/users/1084', 'pm_score': 1, 'selected': False, 'text': "<p>you could use the 'net' commands to authenticate and then copy the files.</p>\n\n<pre><code>copy src \\\\dest-machine\\shared-library-name\\dest\n</code></pre>\n\n<p>I'm not <em>really</em> sure exactly how to handle authentication if it's needed.</p>\n"}, {'answer_id': 10355, 'author': 'Iain Holder', 'author_id': 1122, 'author_profile': 'https://Stackoverflow.com/users/1122', 'pm_score': 0, 'selected': False, 'text': '<p>If it\'s something you need to script, you should consider <a href="http://nant.sourceforge.net/" rel="nofollow noreferrer">NAnt</a>.</p>\n<p>It\'s a mainly used for build scripts, but it\'s very powerful and reasonably easy to get started with.</p>\n<p>There\'s also <a href="http://nantcontrib.sourceforge.net/" rel="nofollow noreferrer">NAntContrib</a> and the <a href="http://web.archive.org/web/20110319094509/http://www.spinthemoose.com:80/%7Eftptask/help/tasks/ftp.html" rel="nofollow noreferrer">nant ftp task</a> which should help you out.</p>\n'}, {'answer_id': 10385, 'author': 'Abs', 'author_id': 1245, 'author_profile': 'https://Stackoverflow.com/users/1245', 'pm_score': 0, 'selected': False, 'text': "<p>I could be wrong about this, but I think that neither Nick's robocopy solution or Nathan's copy command solution will work. Robocopy seems to want a mapped drive, which I can't do because it's not running on port 80 or 443, and Windows can't handle a path that includes the port in a UNC-style name:</p>\n\n<pre><code>copy src \\\\dest-machine:45000\\shared-library-name\\dest\n</code></pre>\n\n<p>I didn't see a NAnt task that would handle this situation, either.</p>\n\n<p>I also know there are tools that will allow me to map WebDAV drives. I was more wondering if there was some way to make use of the Network Places that have been set up without using the GUI.</p>\n"}, {'answer_id': 13899, 'author': 'slipsec', 'author_id': 1635, 'author_profile': 'https://Stackoverflow.com/users/1635', 'pm_score': 2, 'selected': False, 'text': '<p>Powershell uses the abstraction of Providers to provide a common interface into datastores.  These seem to stick with the common noun "Item", so you can get a complete list with <code>man *item*</code>.  If you know another way to copy and otherwise work with data from a store, you might as well use it, but using the cmdlets provides a better "learn-once, use-often" approach.  In your case you could:</p>\n\n<pre><code>Copy-Item test.txt -Destination \\\\dest-machine\\share\n</code></pre>\n\n<p>Copy-item also supports the -Credential parameter if you need it.</p>\n'}, {'answer_id': 14461, 'author': 'seanyboy', 'author_id': 1726, 'author_profile': 'https://Stackoverflow.com/users/1726', 'pm_score': 4, 'selected': False, 'text': '<p>Using a batch file, you can both log on to the resource and copy the file: </p>\n\n<p>The Batch File would contain the following: </p>\n\n<pre><code>net use \\\\{dest-machine}\\{destfolder} {password} /user:{username}\ncopy {file} \\\\{dest-machine}\\{destfolder}\n</code></pre>\n\n<p>e.g.</p>\n\n<pre><code>net use \\\\Development\\myfolder mypassword /user:Administrator\ncopy newfile.c \\\\development\\myfolder\n</code></pre>\n'}, {'answer_id': 30296, 'author': 'Abs', 'author_id': 1245, 'author_profile': 'https://Stackoverflow.com/users/1245', 'pm_score': 2, 'selected': True, 'text': "<p>From what I'm seeing, it seems that it's not possible to directly access/ manipulate a Network Place from the command line, be it in PowerShell or the plain ol' command prompt. </p>\n\n<p>@slipsec (#13899):\nThanks for the suggestion, but PowerShell doesn't support the port number in the destination path any more than the <code>net use</code> command does.</p>\n\n<p>So the best thing I can figure to do in my particular situation is bite the bullet and buy something like WebDrive to enable drive mapping via WebDAV on non-standard ports, or do some different configuration (e.g. separate web app with a different IP address and host headers) in SharePoint to expose the site via NTLM on a standard port.</p>\n"}, {'answer_id': 68889, 'author': 'Jaykul', 'author_id': 8718, 'author_profile': 'https://Stackoverflow.com/users/8718', 'pm_score': 2, 'selected': False, 'text': '<p>"Network Places" doesn\'t really have an API, it\'s just a bunch of shortcuts, and the SharePoint share uses a Shell Extension, if I recall correctly. </p>\n\n<p>All of that to say: accessing Sharepoint as a file system from PowerShell <em>also</em> requires an extension, the <a href="http://www.codeplex.com/PSSharePoint" rel="nofollow noreferrer">SharePoint Provider</a>.</p>\n'}, {'answer_id': 8193290, 'author': 'jetzdax', 'author_id': 1055163, 'author_profile': 'https://Stackoverflow.com/users/1055163', 'pm_score': 3, 'selected': False, 'text': '<p>If you are referring to a <code>windows box</code>, just use <code>xcopy</code>. It is pretty standard to have <code>xcopy</code> available.</p>\n\n<pre><code>xcopy src \\\\dest-machine\\shared-library-name\\dest\nxcopy \\\\src-machine\\shared-library-name\\dest src\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/10313', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1245/']