Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 8583

BitsTransfer: Transferring a Directory to a Remote Machine

$
0
0

I would be grateful if someone could show me the syntax forBitsTransfer to send a directory to a remote machine. The following is what I have attempted.

 Import-Module BitsTransfer

$username = "RemoteComputer\myusername"

$password = cat password.txt | convertto-securestring

$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password

$serverIp = "XXX.XXX.XXX.XXX"

Invoke-Command -ComputerName $serverIp -Credential $cred -Command { Remove-Item -Recurse "C:\Documents and Settings\myusername\Desktop\FolderToTransfer" -Force }

Start-BitsTransfer -Source "C:\Users\localusername\FolderToTransfer" -Destination "\\$serverIp\C:\Documents and Settings\myusername\Desktop\" -Credential $cred

I get the following error

 Start-BitsTransfer : Cannot find path '\\XXX.XXX.XXX.XXX\Documents and Settings\myusername\Desktop' because it does not exist.

At line:1 char:19

+ Start-BitsTransfer <<<<  -Source "C:\Users\localusername\FolderToTransfer" -Destination "\\$serverIp\C:\Documents and Settings\myusername\Desktop\" -Credential $cred

    + CategoryInfo          : ObjectNotFound: (\\108.174.48.14...clanubp\Desktop:String) [Start-BitsTransfer], ParentContainsErrorRecordException

    + FullyQualifiedErrorId : PathNotFound,Microsoft.BackgroundIntelligentTransfer.Management.NewBitsTransferCommand

Am I doing this correctly? The Invoke-Command works i.e. the directory on the remote machine gets deleted. However I could not get theStart-BitsTransfer  to work.

The remote machine is not in the same domain as the local computer. Am I specifying the destination path "\\$serverIp\C:\Documents and Settings\myusername\Desktop\" correctly ? 

Thank you for your help.

O. O.


Viewing all articles
Browse latest Browse all 8583

Trending Articles