Error in copying Files to Remote PC using Powershell

This topic contains 1 reply, has 2 voices, and was last updated by  Jaapie bakker 5 months ago.

  • Author
    Posts
  • #70967

    Rishabh Verma
    Participant
    $ip = '\\192.168.233.128\Test'
     $password = "abc123!" | ConvertTo-SecureString -asPlainText -Force
     $username = "Administrator" 
     $credential = New-Object System.Management.Automation.PSCredential($username,$password)
     New-PSDrive -Name Z -PSProvider FileSystem -Root $ip -Credential $credential -ErrorAction Stop 
     dir C:\File_One.txt | copy -Destination Z: -PassThru
     Remove-PSDrive -name Z
    

    This Code Works fine between my base machine and VM, It also worked with another PC connected to my router.
    But when i tried Implementing it on clients network it doesn't let me create the PSDrive, and Script Failed.
    The credentials provided were correct.

    Any help would be beneficial.

  • #70997

    Jaapie bakker
    Participant

    if you do the action manaul does it give an error? Then you can see if it has to do something with rights/policy

You must be logged in to reply to this topic.