Copy file remotely with PowerShell

后端 未结 5 593
失恋的感觉
失恋的感觉 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:24

    None of the above answers worked for me. I kept getting this error:

    Copy-Item : Access is denied
    + CategoryInfo          : PermissionDenied: (\\192.168.1.100\Shared\test.txt:String) [Copy-Item], UnauthorizedAccessException>   
    + FullyQualifiedErrorId : ItemExistsUnauthorizedAccessError,Microsoft.PowerShell.Commands.CopyItemCommand
    

    So this did it for me:

    netsh advfirewall firewall set rule group="File and Printer Sharing" new enable=yes
    

    Then from my host my machine in the Run box I just did this:

    \\{IP address of nanoserver}\C$
    

提交回复
热议问题