Get List of Videos from Microsoft Stream
-
Twan van Beers
-
02 February, 2022
Getting a list of videos from Stream, so that you can look to migrate them or just to see what is there is hard. There is not much information on the Web about how to go about doing this, especially on large tenants.
My colleague Conrad has been working with the script from Powershell Script to list A LL videos in your 365 Stream environment – Microsoft Tech Community and has helped improve that script. He set me a challenge to remove the manual tasks like getting the data center location and copying/pasting URLs…
At first I was a bit daunted since obviously the author Dorje McKinnon would have spent time researching how this could be done. Anyway I set to work. At first I tried to see if I could get an access token from graph and then use that, but in the end Bing (or more to the point Google) came to the rescue. I found a script Export a csv report on all Microsoft Stream videos | PnP Samples. This looked very promising when looking through the code, unfortunately it didn’t work…
However, the idea was sound, so I played with some of the internal logic to try to work out what was broken. The key piece I looked at was
function CaptureToken() {
var tenantInfo = new Object();
tenantInfo.AccessToken =''
if (sessionInfo != undefined) {
tenantInfo = new Object();
token=sessionInfo.AccessToken;
tenantInfo.AccessToken = sessionInfo.AccessToken;
tenantInfo.TenantId = sessionInfo.UserClaim.TenantId;
tenantInfo.ApiGatewayUri =sessionInfo.ApiGatewayUri;
tenantInfo.ApiGatewayVersion=sessionInfo.ApiGatewayVersion;
return (JSON.stringify(tenantInfo));
}
return (JSON.stringify(tenantInfo));
}
This was failing, and turning on the javascript warnings in the browser and fixing some syntax issues, it turned out that MS must have removed the JSON object from their pages. Never fear though since we only have a simple object to create. I updated the code to
@'
function CaptureToken() {
if( typeof sessionInfo === undefined ) {
return '';
} else {
outputString = '{';
outputString += '"AccessToken":"' + sessionInfo.AccessToken + '",';
outputString += '"TenantId":"' + sessionInfo.UserClaim.TenantId + '",';
outputString += '"ApiGatewayUri":"' + sessionInfo.ApiGatewayUri + '",';
outputString += '"ApiGatewayVersion":"' + sessionInfo.ApiGatewayVersion + '"';
outputString += '}';
return outputString;
}
}
'@;
and I managed to get an access token returned! After that it was plain sailing, well relatively. I tidied up the rest of the code (since every developer has their own style) and removed some unnecessary pieces.
In the end the script runs well and no more looking for data centers or copying/pasting urls. Instead you get the output as objects, or if you specify a csv filename then it will export to that csv. Some useful bits of info include the URL where that video is at, it’s size, duration, height, width, count of likes, etc.
You do need to be a Stream admin or Global Admin so that we can grab the videos in admin mode, but even for a large tenant the process takes only seconds to run!
Thanks to Dorte and Rodrigo for the original scripts and some of the ideas, and thanks to Conrad for setting the challenge!
As always the script is provided on an as is basis, while it does only issue get requests it still always pays to test the script in a non production environment first.
Enjoy!
Twan van Beers
Twan is a senior consultant with over 30 years of experience. He has a wide range of skills including Messaging, Active Directory, SQL, Networking and Firewalls. Twan loves to write scripts and get deep and dirty into debugging code, in order to understand and resolve the most complex of problems.
News & Insights
Trusted insights on technology and innovation to power your business growth.
-
03/06/2026
A practical engineering guide to owners, assignment, consent, credentials and ...
Read More
-
19/05/2026
Domain migrations in Microsoft 365 are rarely as simple as shifting email ...
Read More
-
12/05/2026
Over the past 10 to 15 years, Microsoft 365 has fundamentally reshaped how ...
Read More
-
07/05/2026
Yesterday we had an all company meeting and I thought it would be cool to kick ...
Read More
-
07/05/2026
Planning a tenant-to-tenant migration? Talk to us
Read More
-
31/03/2026
In tenant-to-tenant (T2T) and Google-to-Microsoft 365 migration projects, ...
Read More
-
27/03/2026
You’d think this would be easy and not an uncommon request. There are genuine ...
Read More
-
23/03/2026
Managing Google to Microsoft Migration with GAM7 and PowerShell
Read More
-
16/03/2026
When a user leaves an organisation in Microsoft 365, administrators have ...
Read MoreSubscribe to our newsletter for the latest updates and insights.
Like what you see? Stay in touch! Subscribers to our email list are among the first to receive the latest news, views and updates from Nero Blanco
Get List of Videos from Microsoft Stream">