title: New-PSDrive : The network path was not found
body: <p>I am having an issue to connect to the remote server using <code>New-PSDrive</code>. The remote server is Windows-based, and only <code>userA</code> has access to write.</p>
  
  <p>By saying that, the following code throws an "access denied" error:</p>
  
  <blockquote>
    <p>Access to the path '$remoteServerPath' is denied on line3</p>
  </blockquote>
  
  <p>Code:</p>
  
  <pre><code>New-PSDrive -Name remote -Root $remoteServerPath -PSProvider FileSystem 
  $destination = [IO.Path]::Combine('remote:', $fileName)
  Copy-Item -Path $source -Destination $destination -Force
  </code></pre>
  
  <p>Now, I am trying to include credential information, but I get a different error!</p>
  
  <blockquote>
    <p>The network path was not found on line3</p>
  </blockquote>
  
  <pre><code>$secpass = ConvertTo-SecureString 'myPassword' -AsPlainText -Force
  $cred = New-Object System.Management.Automation.PSCredential ('domain\userA', $secpass)
  New-PSDrive -Name remote -Root $remoteServerPath-PSProvider FileSystem -Credential $cred
  $destination = [IO.Path]::Combine('remote:', $fileName)
  Copy-Item -Path $source -Destination $destination -Force
  </code></pre>
  
  <p>Can anyone please help me out? <strong>Powershell Ver. 5</strong></p>