bits-transfer - Script fails manual code works..?

by Symbiot at 2012-12-21 09:29:54


Maybe it’s simple … I hope so… but I have a problem…
I am copying some files from one server to another (running script from a 3rd)
If I manually enter the code… It works… Yay…
When I put it in a ps1 file it fails.
Script is running on a Windows server 2008R2 with Powershell 1

the error is:

Start-BitsTransfer : Cannot find Path ‘\Server2\C$\inetpub\wwwroot\images\signature\employees’ because it does not exist etc etc.

The Scripts is:

Import-Module Bitstransfer

$cred = New-Object System.Management.Automation.PSCredential $User, (Get-Content C:\Batch\pass.txt | ConvertTo-SecureString)


Start-BitsTransfer -Source $Source -Destination $Destination -Credential $cred

as written… if I manually run these lines by entering them into my powershell window it works…
when I use the EXACT same code(I tried copy pasting just to make sure)… it fails with the above error (I ONLY see the error when I run the script in an administrator powershell)

What could be causing this? The way ps interprets scripts?
by Klaas at 2012-12-23 02:20:01
Did you debug the script in PowershellISE (or PowerGUI,…)? You can check the content of the variables at every step.
I’m thinking $cred might not contain what you expect.

Did you run the shell commands on the same computer as where the script runs?
If you run it on the source or destination server, the following could be important, allthough I don’t know what it means for a 3rd computer:
"The Start-BitsTransfer cmdlet supports downloading multiple files from a server to a client computer, but it does not generally support uploading multiple files from a client computer to a server. If you need to upload more than one file, you can use the Import-CSV cmdlet to pipe the output to the Add-BitsFile cmdlet to upload multiple files. Or, if you need to upload more than one file, consider using a cabinet file (.cab) or a compressed file (.zip)."