title: Powershell : Accessing shared drive from remote server
body: <p>I am trying to access shared drive vai remote server in my Powershell script. My code is below:</p>
  
  <pre><code>$bypass1 = "config"
  $bypass2 = "web.config"
  $Username = "test\newtest"
  $Password = "xxxxxxxxx"
  $srv = "xxx.xxx.xxx.xxx"
  
  $securePassword = ConvertTo-SecureString -AsPlainText -Force $Password 
  $cred = New-Object System.Management.Automation.PSCredential $Username, $securePassword
  $session = New-PSSession -ComputerName $srv -port 22 -Credential $cred
  Invoke-Command -Session $session -ScriptBlock {
      $computer = "xxx.xxx.xxx.xxx"
      test-path \\$computer\netlog\php
      Get-ChildItem \\$computer\netlog\
  }
  Remove-PSSession -Session $session
  </code></pre>
  
  <p>When I tried to access shared from Remote Desktop Connection on the server it is working but through powershell it is throwing following error.</p>
  
  <pre><code>False
  Cannot find path '\\xxx.xxx.xxx.xxx\netlog\' because it does not exist.
      + CategoryInfo          : ObjectNotFound: (\\xxx.xxx.xxx.xxx\netlog\:String) [Get-Ch 
     ildItem], ItemNotFoundException
      + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCom 
     mand
      + PSComputerName        : xxx.xxx.xxx.xxx
  </code></pre>
  
  <p>I am having Powershell 4 and remote server is windows 2008 R2. </p>
  
  <p>Regards,
  Vj</p>