A few months back, I had the need to tell a bunch of machines to start a BITS transfer.  Sadly, BITS reported that it cannot be started remotely.  So after trying a bunch of stuff, I have come up with a workaround for getting the job done.

$ComputerName = "192.168.1.1"
    
    $Session = New-PSSession -ComputerName $ComputerName -Credential Get-Credential
    
    Invoke-Command -Session $Session -ScriptBlock {
        
        $start = (Get-Date).AddMinutes(1).ToString("HH:mm:ss")
        [string]$Result = schtasks /create /tn "Start Bits" /tr "$PSHome\powershell.exe -File C:\Start-Bits.ps1" /sc once /st $start /ru "username" /rp "password"
        
        $Result
    
    }

While the transfer doesn’t start until 1 minute after you run the command.  IT DOES START.  You can also replace the –File with –Command when starting Powershell to do ad hock stuff.

Note:  This is a workaround and not an elegant solution.  You still won’t have access to Get-BitsTransfer.

-Shane

Advertisements