Copy file remotely with PowerShell

后端 未结 5 584
失恋的感觉
失恋的感觉 2020-11-28 03:03

I am writing a PowerShell script that I want to run from Server A. I want to connect to Server B and copy a file to Server A as a backup.

If that can\'t be

5条回答
  •  离开以前
    2020-11-28 03:27

    Use net use or New-PSDrive to create a new drive:

    New-PsDrive: create a new PsDrive only visible in PowerShell environment:

    New-PSDrive -Name Y -PSProvider filesystem -Root \\ServerName\Share
    Copy-Item BigFile Y:\BigFileCopy
    

    Net use: create a new drive visible in all parts of the OS.

    Net use y: \\ServerName\Share
    Copy-Item BigFile Y:\BigFileCopy
    

提交回复
热议问题