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

4 years, 10 months ago.

  • Author
  • #17899

    Topics: 3
    Replies: 2
    Points: 0
    Rank: Member


    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

    Topics: 13
    Replies: 4872
    Points: 1,812
    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

    Topics: 3
    Replies: 2
    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.