PS-Drive and move-item

Welcome Forums General PowerShell Q&A PS-Drive and move-item

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
4 years, 4 months ago.

  • Author
    Posts
  • #17899

    Participant
    Points: 0
    Rank: Member

    Hello,

    I need to move some files from Server A (Workgroup) to Server B (Domain)

    I have created the following PSDrive on ServerB:

    New-PSDrive -Name A -PSProvider FileSystem -Root '\\ServerA\Files' -Credential servera\usera

    When i change directory to the PSDrive A and do a move-item *.* c:\temp then i just received an access denied. Presumeable because it's using my ServerB Credentials.

    Does anyone have an idea to get around this?

  • #17902

    Keymaster
    Points: 1,673
    Helping HandTeam Member
    Rank: Community Hero

    Is it denying you access on the reading of the source files, or the writing of the target files? Or denying you access on deleting the source files after the copy?

  • #17939

    Participant
    Points: 0
    Rank: Member

    I can read the files from the source and I can create new files in the target directory.

    If I break the script and do a New-Item -filetype test.txt in the target directory I get:

    New-Item : Access to the path '\\ServerA\Files\test.txt' is denied.

    So it seems that the PS-Drive is mapped with a set of credentials, but when I move-item/new-item then it's using the credentials of the account that runs PowerShell.

The topic ‘PS-Drive and move-item’ is closed to new replies.