title: Powershell New-SmbMapping with variable
body: <p>I´m planning to connect a network drive via Powershell. The whole script should be highly dynamic, so I want/have to use variable.</p>
  
  <p>Example:</p>
  
  <pre><code>$dhcpserver="192.168.0.1"
  $dhcpshare="$dhcpserver\share"
  $shareletter="X:"
  $shareuser="$dhcpserver\user"
  $sharepasswd="passwd"
  
  New-SmbMapping -LocalPath $shareletter -RemotePath $shareletter -Username 
  $shareuser -Password $sharepasswd -Persistent $true
  </code></pre>
  
  <p>This doesn´t work because of the <code>-RemotePath</code> Parameter, if I replace this with <code>\\192.168.0.1\share</code> it's ok, but not this way. But why?</p>
  
  <p>Yes, probably it will work via <code>net use</code> - that's what I'm going to do next. But the question why remains....</p>