Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

NET USE in WSL

Originally posted on: http://geekswithblogs.net/WinAZ/archive/2017/10/18/net-use-in-wsl.aspx

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


This post first appeared on , please read the originial post: here

Share the post

NET USE in WSL

×

Subscribe to

Get updates delivered right to your inbox!

Thank you for your subscription

×