PS-Drive and move-item

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Rene Falkenberg Rene Falkenberg 2 years, 4 months ago.

  • Author
    Posts
  • #17899
    Profile photo of Rene Falkenberg
    Rene Falkenberg
    Participant

    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
    Profile photo of Don Jones
    Don Jones
    Keymaster

    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
    Profile photo of Rene Falkenberg
    Rene Falkenberg
    Participant

    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.

You must be logged in to reply to this topic.