Geeks With Blogs

News
Joe Mayo

Still getting into Windows Subsystem for Linux (WSL). I was using PowerShell to execute NET USE commands to access remote shares. Having tried this on WSL, it wasn’t immediately obvious how to get it to work, though I knew it should be possible. e.g. here was my first try

$net use \\sharename password /USER:domain\username
  

Which resulted in:

Invalid command: net use
 
  Usage: 
  net rpc             Run functions using RPC transport
  net rap             Run functions using RAP transport 
  …
  net help            Print usage information

  

Clearly, WSL is not impressed. After some trial and error, I landed on the following command line:

$net.exe use '\\sharename' password '/USER:domain\username'

First, notice that I used net.exe, instead of just net. That’s because we’re talking about two different tools. The net.exe is a Windows tool for working with users, groups, file shares, and more, but net is a Linux tool for working with Samba and CIFS servers (type man net in WSL for more details).

Next, I added quotes around the options with back-slashes. This keeps from needing to escape the back-slashes. Alternatively, you could write:

$net.exe use \\\\sharename password /USER:domain\\username

That explicitly escapes the back-slashes. Now, I’m able to access secure file shares through WSL.

@JoeMayo on Twitter

Bot Framework Video + Book Posted on Wednesday, October 18, 2017 2:03 PM wsl | Back to top

Related Posts on Geeks With Blogs Matching Categories
Copyright © Joe Mayo | Powered by: GeeksWithBlogs.net