Start-BitsTransfer : Object reference not set to an instance of an object.

category: [ Powershell ] tags: [ PowerShell ] [ Requires Admin ]
created: 04 Jan 2014 @ 18:03 modified: 02 Aug 2018 @ 19:25


Today I find myself with yet another bit of functionality that only works when you are running in Administrator Mode. A while back I had Full Admin Mode always enabled, downside of this is the store apps don't work at all. Up side is your PC works as expected Smile with tongue out. I created a PowerShell script to download Channel 9 videos as described in my post Easily download Ch9 videos, this script worked perfectly but recently started breaking with the error

Start-BitsTransfer : Object reference not set to an instance of an object.
At C:\s\ch9$\Download All.ps1:90 char:21
+                     Start-BitsTransfer $url $($destination + $mp4fileName)
+                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Start-BitsTransfer], NullReferenceException
    + FullyQualifiedErrorId : System.NullReferenceException,Microsoft.BackgroundIntelligentTransfer.Management.NewBitsTransferCommand

What changed? Only switching back to not full admin mode, before realizing this however I added a bit switch into my script so that it would use the WebClient object for downloads if set to 1. But today is when I thought to myself, maybe this is just another one of those "needs to be admin mode" things.

And guess what, it was. Switched to run as Administrator and everything works great.

ABOUT ME

Gordon Beeming works at Nologo Studios in the sunny city of Durban, South Africa. He is the Lead for the Data and Services Team and has a strong focus on Developer Efficiencies and R&D. When he's not hacking away at a keyboard in Visual Studio he'll generally be relaxing with his family or hitting the black top getting in some mileage. He is a Visual Studio ALM Ranger and Visual Studio ALM MVP.

Follow me on Strava