filecopy with PSdrive

Welcome Forums General PowerShell Q&A filecopy with PSdrive

Viewing 2 reply threads
  • Author
    Posts
    • #221715
      Participant
      Topics: 30
      Replies: 74
      Points: 402
      Rank: Contributor

      Hi All,
      I’m busy testing if a network drive is correctly mapped

      $destination1=”\\server\domain.com\ITglobal\MDM”
      #$destination2 = “\\backup.domain.com\laptop-backup-01\username$”
      if(!(test-path Z:)){
      write-host “checking if networkdrive is mapped”
      $cred = Import-Clixml -Path “${env:\userprofile}\Paulst.Cred”
      
      New-PSDrive -name Z -root $destination -PSProvider FileSystem -Credential $cred
      }Else {
      Write-Host “drive is mapped”
      }
      

      When I do use the destination2 location it’s working like a charm
      however when I use destination location it will fail even when I have this drive correctly mapped in my windows explorer and can access it.
      how can I check where it goes wrong?

      thanks Paul

    • #221844
      Participant
      Topics: 12
      Replies: 1623
      Points: 2,565
      Helping Hand
      Rank: Community Hero
      $destination1=”\\server\domain.com\ITglobal\MDM”
      

      has a \ that should be a .

      $destination1=”\\server.domain.com\ITglobal\MDM”
      
    • #221913
      Participant
      Topics: 30
      Replies: 74
      Points: 402
      Rank: Contributor

      Hi

      no it’s suppose to be like this

      $destination=”\\nas\companyname.com\itglobal\MDM”
      
      

      I adapted the names for not reveling the company name

      Paul

Viewing 2 reply threads
  • You must be logged in to reply to this topic.