Home

PowerShell script to audit and export all content details of your Office Video Portal

%3CLINGO-SUB%20id%3D%22lingo-sub-352594%22%20slang%3D%22en-US%22%3EPowerShell%20script%20to%20audit%20and%20export%20all%20content%20details%20of%20your%20Office%20Video%20Portal%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-352594%22%20slang%3D%22en-US%22%3E%3CP%3EAs%20you%20probably%20know%20now%2C%20Office%20365%20Video%20Portal%20is%20an%20old%20product%20of%20Office%20365%2C%20and%20the%20new%20solution%20to%20use%20for%20any%20Video%20need%20is%20now%20Office%20365%20Stream.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20question%20is%20clear%20for%20any%20tenant%20admin%2C%20or%20for%20any%20assessment%20request%20how%20to%20have%20a%20clear%20view%20of%20the%20current%20Video%20Portal%20usage%20in%20a%20tenant.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20wrote%20that%20PowerShell%20script%20to%20export%20in%20only%20one%20CSV%20the%20following%20details%20(you%20can%20import%20and%20manipulate%20later%20with%20Excel)%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EChannelName%3C%2FLI%3E%0A%3CLI%3EChannelURL%3C%2FLI%3E%0A%3CLI%3EChannelStorageinMB%3C%2FLI%3E%0A%3CLI%3EFileTotal%3C%2FLI%3E%0A%3CLI%3EFileName%3C%2FLI%3E%0A%3CLI%3EFileType%3C%2FLI%3E%0A%3CLI%3EFileSizeMB%3C%2FLI%3E%0A%3CLI%3EFileAbsoluteURL%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EYou%20can%20easily%20use%20it%20or%20adapt%20it%20as%20you%20need%20to.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3Efunction%20Invoke-RestSPO%0A%7B%0A%20Param(%0A%20%5BParameter(Mandatory%3D%24True)%5D%0A%20%5BString%5D%24AdminPortalUrl%2C%0A%0A%20%5BParameter(Mandatory%3D%24True)%5D%0A%20%5BString%5D%24SPOUrl%2C%0A%0A%20%5BParameter(Mandatory%3D%24True)%5D%0A%20%5BString%5D%24UserName%2C%0A%0A%20%5BParameter(Mandatory%3D%24True)%5D%0A%20%5BString%5D%24Password%0A%20)%0A%0A%20%5Bstring%5D%24VideoListName%20%3D%20%22Videos%22%0A%20%0A%20Add-Type%20-Path%20(%5BSystem.Reflection.Assembly%5D%3A%3ALoadWithPartialName(%22Microsoft.SharePoint.Client%22).location)%0A%20Add-Type%20-Path%20(%5BSystem.Reflection.Assembly%5D%3A%3ALoadWithPartialName(%22Microsoft.SharePoint.Client.runtime%22).location)%0A%0A%20%24SecurePassword%20%3D%20ConvertTo-SecureString%20-string%20(Get-Content%20%24Password)%0A%20%24creds%20%3D%20New-Object%20System.Management.Automation.PSCredential%20-ArgumentList%20%24username%2C%20%24SecurePassword%0A%20%23%24creds%20%3D%20Get-Credential%0A%0A%20%24SPOQueryUrl%3D%20%24SPOUrl%20%2B%20%22%2F_api%2Fsearch%2Fquery%3Fquerytext%3D%2527contentclass%3Asts_site%20WebTemplate%3APOINTPUBLISHINGTOPIC%2527%26amp%3BSelectProperties%3D%2527Sitename%2527%26amp%3Browlimit%3D5000%22%0A%20%0A%20%20%20%20Write-Host%20%22Performing%20the%20SPO%20Search%20Query%20to%20get%20all%20the%20Office%20365%20Video%20Channels...%22%20-ForegroundColor%20Green%0A%20%24request%20%3D%20%5BSystem.Net.WebRequest%5D%3A%3ACreate(%24SPOQueryUrl)%0A%20%24request.Credentials%20%3D%20New-Object%20Microsoft.SharePoint.Client.SharePointOnlineCredentials(%24creds.UserName%2C%24creds.Password)%0A%20%24request.Headers.Add(%22X-FORMS_BASED_AUTH_ACCEPTED%22%2C%20%22f%22)%0A%20%24request.Accept%20%3D%20%22application%2Fjson%3Bodata%3Dverbose%22%0A%20%23%24request.Method%3D%24Method%0A%20%24request.Method%3D%5BMicrosoft.PowerShell.Commands.WebRequestMethod%5D%3A%3AGet%0A%20%24response%20%3D%20%24request.GetResponse()%0A%20%24requestStream%20%3D%20%24response.GetResponseStream()%0A%20%24readStream%20%3D%20New-Object%20System.IO.StreamReader%20%24requestStream%0A%20%24data%3D%24readStream.ReadToEnd()%0A%20%0A%20%24results%20%3D%20%24data%20%7C%20ConvertFrom-Json%0A%20%24N4result%3D%24results.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results.Cells.results%0A%20%24Channels%20%3D%20%40()%0A%20%20%20%20%20%20foreach(%24r%20in%20%24N4result)%7B%0A%20%20%20%20%20%20%20If(%24r.Key%20-eq%20%22SiteName%22)%0A%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%24Channels%20%2B%3D%24r.Value%0A%20%20%20%20%20%20%20%7D%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%7D%0A%0A%20%20%20%20Write-Host%20%22Collecting%20the%20Office%20365%20Video%20Channel%20Storage%20Details...%22%20-ForegroundColor%20Green%0A%20Connect-SPOService%20-Url%20%24AdminPortalUrl%20-Credential%20%24creds%0A%0A%20%24data%3D%40()%0A%20%20%20%20Write-Host%20%0A%20%20%20%20Write-Host%20%22Office%20365%20Video%20Channel%20Storage%20Details%3A%22%20-ForegroundColor%20Green%0A%20%20%20%20Write-Host%20%22-----------------------------------------%22%20-ForegroundColor%20Green%0A%20%20%20%20Write-Host%20%0A%20foreach(%24chname%20in%20%24Channels)%0A%20%7B%0A%20%20Write-Host%20%22%20%20---------------------------------------------------------------------------%20%20%22%0A%20%20Write-Host%20%22Channel%20URL%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3A%22%2C%20%20%24chname%0A%20%20%24site%20%3D%20Get-SPOSite%20-Identity%20%24chname%20-Detailed%0A%20%20%0A%20%20%24ctx%3DNew-Object%20Microsoft.SharePoint.Client.ClientContext(%24site.URL)%0A%20%20%23%24creds%20%3D%20New-Object%20System.Management.Automation.PSCredential%20-ArgumentList%20(%24Username%2C%20%24AdminPassword)%0A%20%20%24ctx.Credentials%20%3D%20New-Object%20Microsoft.SharePoint.Client.SharePointOnlineCredentials(%24creds.UserName%2C%24creds.Password)%0A%20%20%24ctx.RequestTimeout%20%3D%201000000%20%23%20milliseconds%0A%20%20%24spoweb%20%3D%20%24ctx.Web%0A%20%20%24ctx.Load(%24spoweb)%0A%20%20%24ctx.ExecuteQuery()%0A%20%20Write-Host%0A%20%20%23write-host%20%22Channel%20Name%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3A%22%2C%20%24spoweb.Title%0A%20%20%23Write-Host%20%22Site%20collection%20Url%20%20%20%20%20%20%20%20%20%20%3A%22%2C%20%24ctx.Url%20%23-BackgroundColor%20White%20-ForegroundColor%20DarkGreen%0A%20%20%0A%20%20Write-Host%20%22Channel%20Name%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3A%22%2C%20%24site.Title%20-foregroundcolor%20Green%0A%20%20Write-Host%20%22Channel%20URL%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3A%22%2C%20%24site.URL%20-foregroundcolor%20Yellow%0A%20%20Write-Host%20%22ChannelStorageinMB%20%20%20%20%20%20%20%20%20%20%20%3A%22%2C%20%24site.StorageUsageCurrent%20-foregroundcolor%20Yellow%0A%20%20write-host%20%22Total%20Files%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3A%22%2C%20%24ListItems.Count%20-foregroundcolor%20Yellow%0A%0A%20%20%24MyVideoslist%20%3D%20%24spoweb.Lists.GetByTitle(%24VideoListName)%0A%20%20%24ListItems%20%3D%20%24MyVideoslist.GetItems(%5BMicrosoft.SharePoint.Client.CamlQuery%5D%3A%3ACreateAllItemsQuery())%0A%20%20%24ctx.Load(%24ListItems)%0A%20%20%24ctx.ExecuteQuery()%0A%0A%20%20foreach(%24MyListItem%20in%20%24ListItems)%0A%20%20%7B%0A%20%20%20%24datum%20%3D%20New-Object%20-TypeName%20PSObject%0A%20%20%20Write-Host%20%22%20%20%20%26gt%3B%20file%3A%22%2C%20%24MyListItem%5B%22Title%22%5D%2C%20%22-%20FileType%3A%22%2C%20%20%24MyListItem%5B%22File_x0020_Type%22%5D%2C%20%22-%20Size%20(MB)%3A%22%2C%20(%5Bmath%5D%3A%3Around((%24MyListItem%5B%22File_x0020_Size%22%5D%2F(1024*1024))%2C%202))%2C%20%22-%20FileURL%3A%22%2C%20%24(%24MyListItem%5B%22FileDirRef%22%5D%20%2B%22%2F%22%2B%20%24MyListItem%5B%22FileLeafRef%22%5D)%0A%20%20%20%0A%20%20%20%24datum%20%7C%20Add-Member%20-MemberType%20NoteProperty%20-Name%20ChannelName%20-Value%20%24site.Title%0A%20%20%20%24datum%20%7C%20Add-Member%20-MemberType%20NoteProperty%20-Name%20ChannelURL%20-Value%20%24site.URL%0A%20%20%20%24datum%20%7C%20Add-Member%20-MemberType%20NoteProperty%20-Name%20ChannelStorageinMB%20-Value%20%24site.StorageUsageCurrent%0A%20%20%20%24datum%20%7C%20Add-Member%20-MemberType%20NoteProperty%20-Name%20FileTotal%20-Value%20%24ListItems.Count%0A%20%20%20%24datum%20%7C%20Add-Member%20-MemberType%20NoteProperty%20-Name%20FileName%20-Value%20%24MyListItem%5B%22Title%22%5D%0A%20%20%20%24datum%20%7C%20Add-Member%20-MemberType%20NoteProperty%20-Name%20FileType%20-Value%20%24MyListItem%5B%22File_x0020_Type%22%5D%0A%20%20%20%24datum%20%7C%20Add-Member%20-MemberType%20NoteProperty%20-Name%20FileSizeMB%20-Value%20(%5Bmath%5D%3A%3Around((%24MyListItem%5B%22File_x0020_Size%22%5D%2F(1024*1024))%2C%202))%0A%20%20%20%24datum%20%7C%20Add-Member%20-MemberType%20NoteProperty%20-Name%20FileAbsoluteURL%20-Value%20%20%24(%24MyListItem%5B%22FileDirRef%22%5D%20%2B%22%2F%22%2B%20%24MyListItem%5B%22FileLeafRef%22%5D)%0A%20%20%20%24data%20%2B%3D%20%24datum%0A%20%20%7D%0A%20%20%0A%20%20%23Write-Host%20%22StorageQuotainGB%20%20%20%20%20%20%20%20%20%20%20%20%20%3A%22%2C%20(%24site.StorageQuota%2F1024)%20-foregroundcolor%20Green%0A%20%20%23Write-Host%20%22StorageQuotaWarningLevelinGB%20%3A%22%2C%20(%24site.StorageQuotaWarningLevel%2F1024)%20-foregroundcolor%20Green%0A%20%20Write-Host%20%22%22%0A%20%20Write-Host%20%22%20%20---------------------------------------------------------------------------%20%20%22%0A%20%20%20%20%7D%0A%0A%20%24datestring%20%3D%20(get-date).ToString(%22yyyyMMdd-hhmm%22)%0A%20%24fileName%20%3D%20(%22C%3A%5CVideoPortal%5CVideoPortalDetails_%22%20%2B%20%24datestring%20%2B%20%22.csv%22)%0A%20%0A%20Write-host%20%22%20-----------------------------------------%22%20-ForegroundColor%20Green%0A%20Write-Host%20(%22%20%26gt%3B%26gt%3B%26gt%3B%20writing%20to%20file%20%7B0%7D%22%20-f%20%24fileName)%20-ForegroundColor%20Green%0A%20%24data%20%7C%20Export-csv%20%24fileName%20-NoTypeInformation%0A%20Write-host%20%22%20-----------------------------------------%22%20-ForegroundColor%20Green%0A%20%20%0A%7D%0A%0A%0A%5Bstring%5D%24username%20%3D%20%22admin%40yourtenant.onmicrosoft.com%22%0A%5Bstring%5D%24PwdTXTPath%20%3D%20%22C%3A%5CSECUREDPWD%5CExportedPWD-%24(%24username).txt%22%0A%0A%23%20Get%20needed%20information%20from%20end%20user%0A%5Bstring%5D%24SPOAdminPortal%20%3D%20%22https%3A%2F%2Fyourtenant-admin.sharepoint.com%22%0A%5Bstring%5D%24SPOSiteURL%20%3D%20%22https%3A%2F%2Fyourtenant.sharepoint.com%22%0A%0AInvoke-RestSPO%20-AdminPortalUrl%20%24SPOAdminPortal%20-SPOUrl%20%24SPOSiteURL%20-UserName%20%24username%20-Password%20%24PwdTXTPath%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20CSV%20can%20be%20used%20in%20Excel%20and%20a%20Pivot%20Table%20will%20give%20you%20that%20kind%20of%20usage%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20655px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F83482i8F5410C8F17BAF96%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Capture-ListOfFile.JPG%22%20title%3D%22Capture-ListOfFile.JPG%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EFileType%20for%20a%20Channel%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThat%20will%20give%20you%20an%20idea%20about%20the%20task%20force%20to%20organize%20for%20your%20migration%20project%20or%20Integration%20project.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFabrice%20Romelard%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CEM%3EFrench%20version%3A%3C%2FEM%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CEM%3E%3CA%20href%3D%22http%3A%2F%2Fblogs.developpeur.org%2Ffabrice69%2Farchive%2F2019%2F02%2F18%2Foffice-365-script-powershell-pour-auditer-le-contenu-de-son-office-365-video-portal.aspx%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fblogs.developpeur.org%2Ffabrice69%2Farchive%2F2019%2F02%2F18%2Foffice-365-script-powershell-pour-auditer-le-contenu-de-son-office-365-video-portal.aspx%3C%2FA%3E%3C%2FEM%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CEM%3ESome%20articles%20used%20to%20build%20it%3A%3C%2FEM%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CEM%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.spiceworks.com%2Fhow_to%2F127063-how-to-check-channel-storage-space-in-office-365-video-portal-using-powershell%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fcommunity.spiceworks.com%2Fhow_to%2F127063-how-to-check-channel-storage-space-in-office-365-video-portal-using-powershell%3C%2FA%3E%3C%2FEM%3E%3C%2FLI%3E%0A%3CLI%3E%3CEM%3E%3CA%20href%3D%22http%3A%2F%2Fwww.jijitechnologies.com%2Fblogs%2Fhow-to-get-the-storage-used-in-all-office365-video-channels%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fwww.jijitechnologies.com%2Fblogs%2Fhow-to-get-the-storage-used-in-all-office365-video-channels%3C%2FA%3E%3C%2FEM%3E%3C%2FLI%3E%0A%3CLI%3E%3CEM%3E%3CA%20href%3D%22https%3A%2F%2Fgallery.technet.microsoft.com%2Foffice%2FHow-To-Check-Channel-ac2a9b34%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgallery.technet.microsoft.com%2Foffice%2FHow-To-Check-Channel-ac2a9b34%3C%2FA%3E%3C%2FEM%3E%3C%2FLI%3E%0A%3CLI%3E%3CEM%3E%3CA%20href%3D%22https%3A%2F%2Fgallery.technet.microsoft.com%2Foffice%2FExport-all-Office-365-53f8105b%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgallery.technet.microsoft.com%2Foffice%2FExport-all-Office-365-53f8105b%3C%2FA%3E%3C%2FEM%3E%3C%2FLI%3E%0A%3C%2FUL%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-352594%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAdmin%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFiles%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%20Video%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharePoint%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EStorage%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-354836%22%20slang%3D%22en-US%22%3ERe%3A%20PowerShell%20script%20to%20audit%20and%20export%20all%20content%20details%20of%20your%20Office%20Video%20Portal%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-354836%22%20slang%3D%22en-US%22%3E%3CP%3EAnother%20script%20related%20to%20extract%20O365%20Stream%20Channels%20information%20is%20available%20here%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B-%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FMicrosoft-Stream-Forum%2FPowerShell-script-to-audit-and-export-Channel-content-details-of%2Fm-p%2F354832%23M3011%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FMicrosoft-Stream-Forum%2FPowerShell-script-to-audit-and-export-Channel-content-details-of%2Fm-p%2F354832%23M3011%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFab%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-353900%22%20slang%3D%22en-US%22%3ERe%3A%20PowerShell%20script%20to%20audit%20and%20export%20all%20content%20details%20of%20your%20Office%20Video%20Portal%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-353900%22%20slang%3D%22en-US%22%3E%3CP%3EDear%20all%2C%3C%2FP%3E%0A%3CP%3EI%20updated%20the%20script%20adding%20export%20option%20to%20list%20the%20dates%20(creation%20and%20modification)%20and%20also%20get%20the%20viewcount.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3EFunction%20Get-RestContents%20(%24url%2C%20%24cred)%20%7B%0A%20%20%20%20%24r%20%3D%20%5BSystem.Net.WebRequest%5D%3A%3ACreate(%24url)%3B%0A%20%20%20%20%24r.Credentials%20%3D%20%24cred%0A%20%20%20%20%24r.Accept%20%3D%20%22application%2Fjson%3Bodata%3Dverbose%22%0A%20%20%20%20%24r.Headers.Add(%22X-FORMS_BASED_AUTH_ACCEPTED%22%2C%20%22f%22)%0A%0A%20%20%20%20%24res%20%3D%20%24r.GetResponse()%0A%20%20%20%20%24stream%20%3D%20New-Object%20System.IO.StreamReader%20%24res.GetResponseStream()%0A%20%20%20%20%24results%20%3D%20%24stream.ReadToEnd()%0A%20%20%20%20%24stream.Dispose()%0A%20%20%20%20return%20(%24results%20%7C%20ConvertFrom-Json).d%0A%7D%0A%0Afunction%20Invoke-RestSPO%0A%7B%0A%20Param(%0A%20%5BParameter(Mandatory%3D%24True)%5D%20%5BString%5D%24AdminPortalUrl%2C%20%5BParameter(Mandatory%3D%24True)%5D%20%5BString%5D%24SPOUrl%2C%20%5BParameter(Mandatory%3D%24True)%5D%20%5BString%5D%24UserName%2C%20%5BParameter(Mandatory%3D%24True)%5D%20%5BString%5D%24Password%2C%20%5BParameter(Mandatory%3D%24True)%5D%20%5BString%5D%24TenantName%0A%20)%0A%0A%20%5Bstring%5D%24VideoListName%20%3D%20%22Videos%22%0A%20%5Bstring%5D%24videoPortalUrl%20%3D%20%22https%3A%2F%2F%24(%24TenantName).sharepoint.com%2Fportals%2Fhub%2F_api%2FVideoService%2F%22%0A%20%0A%20Add-Type%20-Path%20(%5BSystem.Reflection.Assembly%5D%3A%3ALoadWithPartialName(%22Microsoft.SharePoint.Client%22).location)%0A%20Add-Type%20-Path%20(%5BSystem.Reflection.Assembly%5D%3A%3ALoadWithPartialName(%22Microsoft.SharePoint.Client.runtime%22).location)%0A%0A%20%24SecurePassword%20%3D%20ConvertTo-SecureString%20-string%20(Get-Content%20%24Password)%0A%20%24creds%20%3D%20New-Object%20System.Management.Automation.PSCredential%20-ArgumentList%20%24username%2C%20%24SecurePassword%0A%20%23%24creds%20%3D%20Get-Credential%0A%20%24StandardUsercreds%20%3D%20New-Object%20Microsoft.SharePoint.Client.SharePointOnlineCredentials(%24creds.UserName%2C%20%24creds.Password)%3B%0A%0A%20%24SPOQueryUrl%3D%20%24SPOUrl%20%2B%20%22%2F_api%2Fsearch%2Fquery%3Fquerytext%3D%2527contentclass%3Asts_site%20WebTemplate%3APOINTPUBLISHINGTOPIC%2527%26amp%3BSelectProperties%3D%2527Sitename%2527%26amp%3Browlimit%3D5000%22%0A%20%0A%20%20%20%20Write-Host%20%22Performing%20the%20SPO%20Search%20Query%20to%20get%20all%20the%20Office%20365%20Video%20Channels...%22%20-ForegroundColor%20Green%0A%20Write-Host%20%22APISearch%3A%22%2C%20%20%24SPOQueryUrl%20-ForegroundColor%20Green%0A%0A%20%24request%20%3D%20%5BSystem.Net.WebRequest%5D%3A%3ACreate(%24SPOQueryUrl)%0A%20%24request.Credentials%20%3D%20%24StandardUsercreds%0A%20%24request.Headers.Add(%22X-FORMS_BASED_AUTH_ACCEPTED%22%2C%20%22f%22)%0A%20%24request.Accept%20%3D%20%22application%2Fjson%3Bodata%3Dverbose%22%0A%20%23%24request.Method%3D%24Method%0A%20%24request.Method%3D%5BMicrosoft.PowerShell.Commands.WebRequestMethod%5D%3A%3AGet%0A%20%24response%20%3D%20%24request.GetResponse()%0A%20%24requestStream%20%3D%20%24response.GetResponseStream()%0A%20%24readStream%20%3D%20New-Object%20System.IO.StreamReader%20%24requestStream%0A%20%24data%3D%24readStream.ReadToEnd()%0A%20%0A%20%24results%20%3D%20%24data%20%7C%20ConvertFrom-Json%0A%20%24N4result%3D%24results.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results.Cells.results%0A%20%24Channels%20%3D%20%40()%0A%20%20%20%20%20%20foreach(%24r%20in%20%24N4result)%7B%0A%20%20%20%20%20%20%20If(%24r.Key%20-eq%20%22SiteName%22)%0A%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%24Channels%20%2B%3D%24r.Value%0A%20%20%20%20%20%20%20%7D%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%7D%0A%0A%20%20%20%20Write-Host%20%22Collecting%20the%20Office%20365%20Video%20Channel%20Storage%20Details...%22%20-ForegroundColor%20Green%0A%20Connect-SPOService%20-Url%20%24AdminPortalUrl%20-Credential%20%24creds%0A%0A%20%24data%3D%40()%0A%20%20%20%20Write-Host%20%0A%20%20%20%20Write-Host%20%22Office%20365%20Video%20Channel%20Storage%20Details%3A%22%20-ForegroundColor%20Green%0A%20%20%20%20Write-Host%20%22-----------------------------------------%22%20-ForegroundColor%20Green%0A%20%20%20%20Write-Host%20%0A%20foreach(%24chname%20in%20%24Channels)%0A%20%7B%0A%20%20Write-Host%20%22%20%20---------------------------------------------------------------------------%20%20%22%0A%20%20Write-Host%20%22Channel%20URL%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3A%22%2C%20%20%24chname%0A%20%20%24site%20%3D%20Get-SPOSite%20-Identity%20%24chname%20-Detailed%0A%20%20%0A%20%20%24ctx%3DNew-Object%20Microsoft.SharePoint.Client.ClientContext(%24site.URL)%0A%20%20%24ctx.Credentials%20%3D%20New-Object%20Microsoft.SharePoint.Client.SharePointOnlineCredentials(%24creds.UserName%2C%24creds.Password)%0A%20%20%24ctx.RequestTimeout%20%3D%201000000%20%23%20milliseconds%0A%20%20%24sposite%20%3D%20%24ctx.Site%0A%20%20%24spoweb%20%3D%20%24ctx.Web%0A%20%20%24ctx.Load(%24spoweb)%0A%20%20%24ctx.Load(%24sposite)%0A%20%20%24ctx.ExecuteQuery()%0A%20%20Write-Host%0A%20%20%23write-host%20%22Channel%20Name%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3A%22%2C%20%24spoweb.Title%0A%20%20%23Write-Host%20%22Site%20collection%20Url%20%20%20%20%20%20%20%20%20%20%3A%22%2C%20%24ctx.Url%20%23-BackgroundColor%20White%20-ForegroundColor%20DarkGreen%0A%20%20%0A%20%20Write-Host%20%22SPOSite%20%26amp%3B%20Channel%20ID%20%20%20%20%20%20%20%20%20%3A%22%2C%20%24sposite.id%20-foregroundcolor%20Green%0A%23%20%20Write-Host%20%22SPOWeb%20ID%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3A%22%2C%20%24spoweb.id%20-foregroundcolor%20Green%0A%20%20Write-Host%20%22Channel%20Name%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3A%22%2C%20%24site.Title%20-foregroundcolor%20Green%0A%20%20Write-Host%20%22Channel%20URL%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3A%22%2C%20%24site.URL%20-foregroundcolor%20Yellow%0A%20%20Write-Host%20%22ChannelStorageinMB%20%20%20%20%20%20%20%20%20%20%20%3A%22%2C%20%24site.StorageUsageCurrent%20-foregroundcolor%20Yellow%0A%20%20write-host%20%22Total%20Files%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3A%22%2C%20%24ListItems.Count%20-foregroundcolor%20Yellow%0A%0A%20%20%24MyVideoslist%20%3D%20%24spoweb.Lists.GetByTitle(%24VideoListName)%0A%20%20%24ListItems%20%3D%20%24MyVideoslist.GetItems(%5BMicrosoft.SharePoint.Client.CamlQuery%5D%3A%3ACreateAllItemsQuery())%0A%20%20%24ctx.Load(%24ListItems)%0A%20%20%24ctx.ExecuteQuery()%0A%0A%20%20foreach(%24MyListItem%20in%20%24ListItems)%0A%20%20%7B%0A%20%20%20%5Bstring%5D%24ChannelId%20%3D%20%24sposite.id%0A%20%20%20%5Bstring%5D%24videoId%20%3D%20%24MyListItem%5B%22UniqueId%22%5D%0A%20%20%20%24datum%20%3D%20New-Object%20-TypeName%20PSObject%0A%20%20%20Write-Host%20%22%20%20%20%26gt%3B%20file%3A%22%2C%20%24MyListItem%5B%22Title%22%5D%2C%20%22-%20FileType%3A%22%2C%20%20%24MyListItem%5B%22File_x0020_Type%22%5D%2C%20%22-%20Size%20(MB)%3A%22%2C%20(%5Bmath%5D%3A%3Around((%24MyListItem%5B%22File_x0020_Size%22%5D%2F(1024*1024))%2C%202))%0A%20%20%20Write-Host%20%22%20%20%20%26gt%3B%20FileURL%3A%22%2C%20%24(%24MyListItem%5B%22FileDirRef%22%5D%20%2B%22%2F%22%2B%20%24MyListItem%5B%22FileLeafRef%22%5D)%0A%20%20%20Write-Host%20%22%20%20%20%26gt%3B%20fileID%3A%22%2C%20%24MyListItem%5B%22UniqueId%22%5D%2C%20%22-%20Creation%20Date%3A%22%2C%20%24MyListItem%5B%22Created%22%5D%20%2C%20%22-%20Modification%20Date%3A%22%2C%20%24MyListItem%5B%22Modified%22%5D%0A%20%20%20Write-Host%20%22%20%20%20%26gt%3B%20FileCreator%3A%22%2C%20%24MyListItem%5B%22Created_x0020_By%22%5D%2C%20%22-%20FileModifier%3A%22%2C%20%24MyListItem%5B%22Modified_x0020_By%22%5D%0A%0A%20%20%20%23Get%20the%20ViewCount%20need%20to%20call%20Video%20RESTAPI%20similar%20to%3A%0A%20%20%20%23https%3A%2F%2Fyourtenant.sharepoint.com%2Fportals%2Fhub%2F_api%2FVideoService%2FChannels(guid'63216c90-3f31-4cf0-8abe-c01855a2a794')%2Fsearch%2Fquery(guid'3bc6342d-5e77-42cf-bc25-63117efc5c6d')%3F%24Select%3DViewCount%0A%20%20%20try%0A%20%20%20%7B%0A%20%20%20%20%24viewCounturl%20%3D%20%24videoPortalUrl%20%2B%22Channels(guid'%22%2B%20%24ChannelId%20%2B%22')%2Fsearch%2Fquery(guid'%22%2B%20%24videoId%20%2B%22')%3F%60%24Select%3DViewCount%22%0A%20%20%20%20%24viewCountSource%20%3D%20Get-RestContents%20%24viewCounturl%20%24StandardUsercreds%0A%20%20%20%20%24FileviewCount%20%3D%20%24viewCountSource.results%20%7C%20Select-Object%20ViewCount%0A%20%20%20%20Write-Host%20%22%20%20%3D%3D%3D%3D%3D%26gt%3B%26gt%3B%26gt%3B%26gt%3B%20URL%3A%22%2C%20%24viewCounturl%20-ForegroundColor%20Yellow%0A%20%20%20%20Write-Host%20%22%20%20%3D%3D%3D%3D%3D%26gt%3B%26gt%3B%26gt%3B%26gt%3B%20Results%3A%22%2C%20%24viewCountSource.results%20-ForegroundColor%20Yellow%0A%20%20%20%20Write-Host%20%22%20%20%3D%3D%3D%3D%3D%26gt%3B%26gt%3B%26gt%3B%26gt%3B%20FileviewCount%3A%22%2C%20%24FileviewCount.ViewCount%20-ForegroundColor%20Yellow%0A%20%20%20%7D%0A%20%20%20catch%0A%20%20%20%7B%0A%20%20%20%20Write-Host%20%22%20%20%3D%3D%3D%3D%3D%26gt%3B%26gt%3B%26gt%3B%26gt%3B%20Video%20API%20URL%20not%20working%3A%22%2C%20%24viewCounturl%20-ForegroundColor%20Red%0A%20%20%20%20Write-Host%20%22%20%20%20%20%20%20%20%20%20%20%20%20ERROR%20MESSAGE%3A%22%2C%20%24_.Exception.Message%20-ForegroundColor%20Red%0A%20%20%20%20%24FileviewCount%20%3D%20-1%0A%20%20%20%7D%0A%20%20%20Write-Host%20%22%20%20%26gt%3B%26gt%3B%26gt%3B%20FileviewCount%3A%22%2C%20%24FileviewCount%20-foregroundcolor%20Yellow%0A%20%20%20%24datum%20%7C%20Add-Member%20-MemberType%20NoteProperty%20-Name%20ChannelID%20-Value%20%24sposite.id%0A%20%20%20%24datum%20%7C%20Add-Member%20-MemberType%20NoteProperty%20-Name%20ChannelName%20-Value%20%24site.Title%0A%20%20%20%24datum%20%7C%20Add-Member%20-MemberType%20NoteProperty%20-Name%20ChannelURL%20-Value%20%24site.URL%0A%20%20%20%24datum%20%7C%20Add-Member%20-MemberType%20NoteProperty%20-Name%20ChannelStorageinMB%20-Value%20%24site.StorageUsageCurrent%0A%20%20%20%24datum%20%7C%20Add-Member%20-MemberType%20NoteProperty%20-Name%20FileTotal%20-Value%20%24ListItems.Count%0A%20%20%20%24datum%20%7C%20Add-Member%20-MemberType%20NoteProperty%20-Name%20FileID%20-Value%20%24MyListItem%5B%22UniqueId%22%5D%0A%20%20%20%24datum%20%7C%20Add-Member%20-MemberType%20NoteProperty%20-Name%20FileName%20-Value%20%24MyListItem%5B%22Title%22%5D%0A%20%20%20%24datum%20%7C%20Add-Member%20-MemberType%20NoteProperty%20-Name%20FileviewCount%20-Value%20%24FileviewCount.ViewCount%0A%20%20%20%24datum%20%7C%20Add-Member%20-MemberType%20NoteProperty%20-Name%20FileCreator%20-Value%20%24MyListItem%5B%22Created_x0020_By%22%5D%0A%20%20%20%24datum%20%7C%20Add-Member%20-MemberType%20NoteProperty%20-Name%20FileModifier%20-Value%20%24MyListItem%5B%22Modified_x0020_By%22%5D%0A%20%20%20%24datum%20%7C%20Add-Member%20-MemberType%20NoteProperty%20-Name%20CreationDate%20-Value%20%24MyListItem%5B%22Created%22%5D%0A%20%20%20%24datum%20%7C%20Add-Member%20-MemberType%20NoteProperty%20-Name%20ModificationDate%20-Value%20%24MyListItem%5B%22Modified%22%5D%0A%20%20%20%24datum%20%7C%20Add-Member%20-MemberType%20NoteProperty%20-Name%20FileType%20-Value%20%24MyListItem%5B%22File_x0020_Type%22%5D%0A%20%20%20%24datum%20%7C%20Add-Member%20-MemberType%20NoteProperty%20-Name%20FileSizeMB%20-Value%20(%5Bmath%5D%3A%3Around((%24MyListItem%5B%22File_x0020_Size%22%5D%2F(1024*1024))%2C%202))%0A%20%20%20%24datum%20%7C%20Add-Member%20-MemberType%20NoteProperty%20-Name%20FileAbsoluteURL%20-Value%20%20%24(%24MyListItem%5B%22FileDirRef%22%5D%20%2B%22%2F%22%2B%20%24MyListItem%5B%22FileLeafRef%22%5D)%0A%20%20%20%24data%20%2B%3D%20%24datum%0A%20%20%7D%0A%20%20%23Write-Host%20%22StorageQuotainGB%20%20%20%20%20%20%20%20%20%20%20%20%20%3A%22%2C%20(%24site.StorageQuota%2F1024)%20-foregroundcolor%20Green%0A%20%20%23Write-Host%20%22StorageQuotaWarningLevelinGB%20%3A%22%2C%20(%24site.StorageQuotaWarningLevel%2F1024)%20-foregroundcolor%20Green%0A%20%20Write-Host%20%22%22%0A%20%20Write-Host%20%22%20%20---------------------------------------------------------------------------%20%20%22%0A%20%20%20%20%7D%0A%0A%20%24datestring%20%3D%20(get-date).ToString(%22yyyyMMdd-hhmm%22)%0A%20%24fileName%20%3D%20(%22C%3A%5CVideoPortal%5CVideoPortalDetails_%22%20%2B%20%24datestring%20%2B%20%22.csv%22)%0A%20%0A%20Write-host%20%22%20-----------------------------------------%22%20-ForegroundColor%20Green%0A%20Write-Host%20(%22%20%26gt%3B%26gt%3B%26gt%3B%20writing%20to%20file%20%7B0%7D%22%20-f%20%24fileName)%20-ForegroundColor%20Green%0A%20%24data%20%7C%20Export-csv%20%24fileName%20-NoTypeInformation%0A%20Write-host%20%22%20-----------------------------------------%22%20-ForegroundColor%20Green%0A%7D%0A%0A%5Bstring%5D%24username%20%3D%20%22Admin%40yourtenant.onmicrosoft.com%22%0A%5Bstring%5D%24PwdTXTPath%20%3D%20%22C%3A%5CSECUREDPWD%5CExportedPWD-%24(%24username).txt%22%0A%0A%23%20Get%20needed%20information%20from%20end%20user%0A%5Bstring%5D%24MyTenantName%20%3D%20%22yourtenant%22%0A%5Bstring%5D%24SPOAdminPortal%20%3D%20%20%22https%3A%2F%2F%22%2B%20%24MyTenantName%20%2B%22-admin.sharepoint.com%22%0A%5Bstring%5D%24SPOSiteURL%20%3D%20%22https%3A%2F%2F%22%2B%20%24MyTenantName%20%2B%22.sharepoint.com%22%0A%0AInvoke-RestSPO%20-AdminPortalUrl%20%24SPOAdminPortal%20-SPOUrl%20%24SPOSiteURL%20-UserName%20%24username%20-Password%20%24PwdTXTPath%20-TenantName%20%24MyTenantName%0A%3C%2FPRE%3E%0A%3CP%3EYou%20can%20use%20that%20new%20version%20as%20you%20want.%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EFabrice%20Romelard%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CEM%3ESource%20used%3A%3C%2FEM%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CEM%3E%3CA%20href%3D%22http%3A%2F%2Fwww.nubo.eu%2Fen%2Fblog%2F2017%2F03%2FAccessing-The-Office-365-Video-API-Through-PowerShell%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fwww.nubo.eu%2Fen%2Fblog%2F2017%2F03%2FAccessing-The-Office-365-Video-API-Through-PowerShell%2F%3C%2FA%3E%3C%2FEM%3E%3C%2FLI%3E%0A%3CLI%3E%3CEM%3E%3CA%20href%3D%22http%3A%2F%2Fwww.nubo.eu%2Fen%2Fblog%2F2017%2F03%2FAccessing-Channels-With-Office-365-Video-API-Through-PowerShell%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fwww.nubo.eu%2Fen%2Fblog%2F2017%2F03%2FAccessing-Channels-With-Office-365-Video-API-Through-PowerShell%2F%3C%2FA%3E%3C%2FEM%3E%3C%2FLI%3E%0A%3CLI%3E%3CEM%3E%3CA%20href%3D%22http%3A%2F%2Fwww.nubo.eu%2Fen%2Fblog%2F2017%2F03%2FAccessing-Videos-With-Office-365-Video-API-Through-PowerShell%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fwww.nubo.eu%2Fen%2Fblog%2F2017%2F03%2FAccessing-Videos-With-Office-365-Video-API-Through-PowerShell%2F%3C%2FA%3E%3C%2FEM%3E%3C%2FLI%3E%0A%3CLI%3E%3CEM%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fprevious-versions%2Foffice%2Foffice-365-api%2Fapi%2Fvideo-rest-operations%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fprevious-versions%2Foffice%2Foffice-365-api%2Fapi%2Fvideo-rest-operations%3C%2FA%3E%3C%2FEM%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-852887%22%20slang%3D%22en-US%22%3ERe%3A%20PowerShell%20script%20to%20audit%20and%20export%20all%20content%20details%20of%20your%20Office%20Video%20Portal%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-852887%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F41125%22%20target%3D%22_blank%22%3E%40Fabrice%20Romelard%3C%2FA%3E-%20Thank%20you%20so%20much!%26nbsp%3B%20Your%20script%20was%20very%20valuable.%26nbsp%3B%20My%20internal%20customers%20were%20asking%20for%20point-in-time%20view%20counts%20in%20Office%20365%20Video%20before%20I%20migrated%20them%20to%20Stream%20and%20your%20script%20did%20exactly%20what%20we%20needed%20(with%20a%20little%20tweaking%20from%20my%20'automation%20team').%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAfter%20the%20migration%20to%20Stream%20I'll%20be%20reviewing%20your%20other%20suggested%20script%20that%20is%20Stream%20oriented.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-854433%22%20slang%3D%22en-US%22%3ERe%3A%20PowerShell%20script%20to%20audit%20and%20export%20all%20content%20details%20of%20your%20Office%20Video%20Portal%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-854433%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F5086%22%20target%3D%22_blank%22%3E%40George%20Cabe%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20are%20welcome%20and%20can%20use%20that%20script%20as%20you%20want%20to.%3C%2FP%3E%3CP%3EFab%3C%2FP%3E%3C%2FLINGO-BODY%3E
Frequent Contributor

As you probably know now, Office 365 Video Portal is an old product of Office 365, and the new solution to use for any Video need is now Office 365 Stream.

 

The question is clear for any tenant admin, or for any assessment request how to have a clear view of the current Video Portal usage in a tenant.

 

I wrote that PowerShell script to export in only one CSV the following details (you can import and manipulate later with Excel):

  • ChannelName
  • ChannelURL
  • ChannelStorageinMB
  • FileTotal
  • FileName
  • FileType
  • FileSizeMB
  • FileAbsoluteURL

You can easily use it or adapt it as you need to.

 

function Invoke-RestSPO
{
	Param(
	[Parameter(Mandatory=$True)]
	[String]$AdminPortalUrl,

	[Parameter(Mandatory=$True)]
	[String]$SPOUrl,

	[Parameter(Mandatory=$True)]
	[String]$UserName,

	[Parameter(Mandatory=$True)]
	[String]$Password
	)

	[string]$VideoListName = "Videos"
	
	Add-Type -Path ([System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client").location)
	Add-Type -Path ([System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.runtime").location)

	$SecurePassword = ConvertTo-SecureString -string (Get-Content $Password)
	$creds = New-Object System.Management.Automation.PSCredential -ArgumentList $username, $SecurePassword
	#$creds = Get-Credential

	$SPOQueryUrl= $SPOUrl + "/_api/search/query?querytext=%27contentclass:sts_site WebTemplate:POINTPUBLISHINGTOPIC%27&SelectProperties=%27Sitename%27&rowlimit=5000"
	
    Write-Host "Performing the SPO Search Query to get all the Office 365 Video Channels..." -ForegroundColor Green
	$request = [System.Net.WebRequest]::Create($SPOQueryUrl)
	$request.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($creds.UserName,$creds.Password)
	$request.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f")
	$request.Accept = "application/json;odata=verbose"
	#$request.Method=$Method
	$request.Method=[Microsoft.PowerShell.Commands.WebRequestMethod]::Get
	$response = $request.GetResponse()
	$requestStream = $response.GetResponseStream()
	$readStream = New-Object System.IO.StreamReader $requestStream
	$data=$readStream.ReadToEnd()
	
	$results = $data | ConvertFrom-Json
	$N4result=$results.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results.Cells.results
	$Channels = @()
		    foreach($r in $N4result){
			    If($r.Key -eq "SiteName")
			    {
			    $Channels +=$r.Value
			    }           
			}

    Write-Host "Collecting the Office 365 Video Channel Storage Details..." -ForegroundColor Green
	Connect-SPOService -Url $AdminPortalUrl -Credential $creds

	$data=@()
    Write-Host 
    Write-Host "Office 365 Video Channel Storage Details:" -ForegroundColor Green
    Write-Host "-----------------------------------------" -ForegroundColor Green
    Write-Host 
	foreach($chname in $Channels)
	{
		Write-Host "  ---------------------------------------------------------------------------  "
		Write-Host "Channel URL                  :",  $chname
		$site = Get-SPOSite -Identity $chname -Detailed
		
		$ctx=New-Object Microsoft.SharePoint.Client.ClientContext($site.URL)
		#$creds = New-Object System.Management.Automation.PSCredential -ArgumentList ($Username, $AdminPassword)
		$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($creds.UserName,$creds.Password)
		$ctx.RequestTimeout = 1000000 # milliseconds
		$spoweb = $ctx.Web
		$ctx.Load($spoweb)
		$ctx.ExecuteQuery()
		Write-Host
		#write-host "Channel Name                 :", $spoweb.Title
		#Write-Host "Site collection Url          :", $ctx.Url #-BackgroundColor White -ForegroundColor DarkGreen
		
		Write-Host "Channel Name                 :", $site.Title -foregroundcolor Green
		Write-Host "Channel URL                  :", $site.URL -foregroundcolor Yellow
		Write-Host "ChannelStorageinMB           :", $site.StorageUsageCurrent -foregroundcolor Yellow
		write-host "Total Files                  :", $ListItems.Count -foregroundcolor Yellow

		$MyVideoslist = $spoweb.Lists.GetByTitle($VideoListName)
		$ListItems = $MyVideoslist.GetItems([Microsoft.SharePoint.Client.CamlQuery]::CreateAllItemsQuery())
		$ctx.Load($ListItems)
		$ctx.ExecuteQuery()

		foreach($MyListItem in $ListItems)
		{
			$datum = New-Object -TypeName PSObject
			Write-Host "   > file:", $MyListItem["Title"], "- FileType:",  $MyListItem["File_x0020_Type"], "- Size (MB):", ([math]::round(($MyListItem["File_x0020_Size"]/(1024*1024)), 2)), "- FileURL:", $($MyListItem["FileDirRef"] +"/"+ $MyListItem["FileLeafRef"])
			
			$datum | Add-Member -MemberType NoteProperty -Name ChannelName -Value $site.Title
			$datum | Add-Member -MemberType NoteProperty -Name ChannelURL -Value $site.URL
			$datum | Add-Member -MemberType NoteProperty -Name ChannelStorageinMB -Value $site.StorageUsageCurrent
			$datum | Add-Member -MemberType NoteProperty -Name FileTotal -Value $ListItems.Count
			$datum | Add-Member -MemberType NoteProperty -Name FileName -Value $MyListItem["Title"]
			$datum | Add-Member -MemberType NoteProperty -Name FileType -Value $MyListItem["File_x0020_Type"]
			$datum | Add-Member -MemberType NoteProperty -Name FileSizeMB -Value ([math]::round(($MyListItem["File_x0020_Size"]/(1024*1024)), 2))
			$datum | Add-Member -MemberType NoteProperty -Name FileAbsoluteURL -Value  $($MyListItem["FileDirRef"] +"/"+ $MyListItem["FileLeafRef"])
			$data += $datum
		}
		
		#Write-Host "StorageQuotainGB             :", ($site.StorageQuota/1024) -foregroundcolor Green
		#Write-Host "StorageQuotaWarningLevelinGB :", ($site.StorageQuotaWarningLevel/1024) -foregroundcolor Green
		Write-Host ""
		Write-Host "  ---------------------------------------------------------------------------  "
    }

	$datestring = (get-date).ToString("yyyyMMdd-hhmm")
	$fileName = ("C:\VideoPortal\VideoPortalDetails_" + $datestring + ".csv")
	
	Write-host " -----------------------------------------" -ForegroundColor Green
	Write-Host (" >>> writing to file {0}" -f $fileName) -ForegroundColor Green
	$data | Export-csv $fileName -NoTypeInformation
	Write-host " -----------------------------------------" -ForegroundColor Green
		
}


[string]$username = "admin@yourtenant.onmicrosoft.com"
[string]$PwdTXTPath = "C:\SECUREDPWD\ExportedPWD-$($username).txt"

# Get needed information from end user
[string]$SPOAdminPortal = "https://yourtenant-admin.sharepoint.com"
[string]$SPOSiteURL = "https://yourtenant.sharepoint.com"

Invoke-RestSPO -AdminPortalUrl $SPOAdminPortal -SPOUrl $SPOSiteURL -UserName $username -Password $PwdTXTPath

 

The CSV can be used in Excel and a Pivot Table will give you that kind of usage:

 

 

Capture-ListOfFile.JPGFileType for a Channel

 

That will give you an idea about the task force to organize for your migration project or Integration project.

 

Fabrice Romelard

 

French version:

 

Some articles used to build it:

4 Replies
Highlighted

Dear all,

I updated the script adding export option to list the dates (creation and modification) and also get the viewcount.

 

Function Get-RestContents ($url, $cred) {
    $r = [System.Net.WebRequest]::Create($url);
    $r.Credentials = $cred
    $r.Accept = "application/json;odata=verbose"
    $r.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f")

    $res = $r.GetResponse()
    $stream = New-Object System.IO.StreamReader $res.GetResponseStream()
    $results = $stream.ReadToEnd()
    $stream.Dispose()
    return ($results | ConvertFrom-Json).d
}

function Invoke-RestSPO
{
	Param(
	[Parameter(Mandatory=$True)] [String]$AdminPortalUrl, [Parameter(Mandatory=$True)] [String]$SPOUrl, [Parameter(Mandatory=$True)] [String]$UserName,	[Parameter(Mandatory=$True)] [String]$Password,	[Parameter(Mandatory=$True)] [String]$TenantName
	)

	[string]$VideoListName = "Videos"
	[string]$videoPortalUrl = "https://$($TenantName).sharepoint.com/portals/hub/_api/VideoService/"
	
	Add-Type -Path ([System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client").location)
	Add-Type -Path ([System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.runtime").location)

	$SecurePassword = ConvertTo-SecureString -string (Get-Content $Password)
	$creds = New-Object System.Management.Automation.PSCredential -ArgumentList $username, $SecurePassword
	#$creds = Get-Credential
	$StandardUsercreds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($creds.UserName, $creds.Password);

	$SPOQueryUrl= $SPOUrl + "/_api/search/query?querytext=%27contentclass:sts_site WebTemplate:POINTPUBLISHINGTOPIC%27&SelectProperties=%27Sitename%27&rowlimit=5000"
	
    Write-Host "Performing the SPO Search Query to get all the Office 365 Video Channels..." -ForegroundColor Green
	Write-Host "APISearch:",  $SPOQueryUrl -ForegroundColor Green

	$request = [System.Net.WebRequest]::Create($SPOQueryUrl)
	$request.Credentials = $StandardUsercreds
	$request.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f")
	$request.Accept = "application/json;odata=verbose"
	#$request.Method=$Method
	$request.Method=[Microsoft.PowerShell.Commands.WebRequestMethod]::Get
	$response = $request.GetResponse()
	$requestStream = $response.GetResponseStream()
	$readStream = New-Object System.IO.StreamReader $requestStream
	$data=$readStream.ReadToEnd()
	
	$results = $data | ConvertFrom-Json
	$N4result=$results.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results.Cells.results
	$Channels = @()
		    foreach($r in $N4result){
			    If($r.Key -eq "SiteName")
			    {
			    $Channels +=$r.Value
			    }           
			}

    Write-Host "Collecting the Office 365 Video Channel Storage Details..." -ForegroundColor Green
	Connect-SPOService -Url $AdminPortalUrl -Credential $creds

	$data=@()
    Write-Host 
    Write-Host "Office 365 Video Channel Storage Details:" -ForegroundColor Green
    Write-Host "-----------------------------------------" -ForegroundColor Green
    Write-Host 
	foreach($chname in $Channels)
	{
		Write-Host "  ---------------------------------------------------------------------------  "
		Write-Host "Channel URL                  :",  $chname
		$site = Get-SPOSite -Identity $chname -Detailed
		
		$ctx=New-Object Microsoft.SharePoint.Client.ClientContext($site.URL)
		$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($creds.UserName,$creds.Password)
		$ctx.RequestTimeout = 1000000 # milliseconds
		$sposite = $ctx.Site
		$spoweb = $ctx.Web
		$ctx.Load($spoweb)
		$ctx.Load($sposite)
		$ctx.ExecuteQuery()
		Write-Host
		#write-host "Channel Name                 :", $spoweb.Title
		#Write-Host "Site collection Url          :", $ctx.Url #-BackgroundColor White -ForegroundColor DarkGreen
		
		Write-Host "SPOSite & Channel ID         :", $sposite.id -foregroundcolor Green
#		Write-Host "SPOWeb ID                    :", $spoweb.id -foregroundcolor Green
		Write-Host "Channel Name                 :", $site.Title -foregroundcolor Green
		Write-Host "Channel URL                  :", $site.URL -foregroundcolor Yellow
		Write-Host "ChannelStorageinMB           :", $site.StorageUsageCurrent -foregroundcolor Yellow
		write-host "Total Files                  :", $ListItems.Count -foregroundcolor Yellow

		$MyVideoslist = $spoweb.Lists.GetByTitle($VideoListName)
		$ListItems = $MyVideoslist.GetItems([Microsoft.SharePoint.Client.CamlQuery]::CreateAllItemsQuery())
		$ctx.Load($ListItems)
		$ctx.ExecuteQuery()

		foreach($MyListItem in $ListItems)
		{
			[string]$ChannelId = $sposite.id
			[string]$videoId = $MyListItem["UniqueId"]
			$datum = New-Object -TypeName PSObject
			Write-Host "   > file:", $MyListItem["Title"], "- FileType:",  $MyListItem["File_x0020_Type"], "- Size (MB):", ([math]::round(($MyListItem["File_x0020_Size"]/(1024*1024)), 2))
			Write-Host "   > FileURL:", $($MyListItem["FileDirRef"] +"/"+ $MyListItem["FileLeafRef"])
			Write-Host "   > fileID:", $MyListItem["UniqueId"], "- Creation Date:", $MyListItem["Created"] , "- Modification Date:", $MyListItem["Modified"]
			Write-Host "   > FileCreator:", $MyListItem["Created_x0020_By"], "- FileModifier:", $MyListItem["Modified_x0020_By"]

			#Get the ViewCount need to call Video RESTAPI similar to:
			#https://yourtenant.sharepoint.com/portals/hub/_api/VideoService/Channels(guid'63216c90-3f31-4cf0-8abe-c01855a2a794')/search/query(guid'3bc6342d-5e77-42cf-bc25-63117efc5c6d')?$Select=ViewCount
			try
			{
				$viewCounturl = $videoPortalUrl +"Channels(guid'"+ $ChannelId +"')/search/query(guid'"+ $videoId +"')?`$Select=ViewCount"
				$viewCountSource = Get-RestContents $viewCounturl $StandardUsercreds
				$FileviewCount = $viewCountSource.results | Select-Object ViewCount
				Write-Host "  =====>>>> URL:", $viewCounturl -ForegroundColor Yellow
				Write-Host "  =====>>>> Results:", $viewCountSource.results -ForegroundColor Yellow
				Write-Host "  =====>>>> FileviewCount:", $FileviewCount.ViewCount -ForegroundColor Yellow
			}
			catch
			{
				Write-Host "  =====>>>> Video API URL not working:", $viewCounturl -ForegroundColor Red
				Write-Host "            ERROR MESSAGE:", $_.Exception.Message -ForegroundColor Red
				$FileviewCount = -1
			}
			Write-Host "  >>> FileviewCount:", $FileviewCount -foregroundcolor Yellow
			$datum | Add-Member -MemberType NoteProperty -Name ChannelID -Value $sposite.id
			$datum | Add-Member -MemberType NoteProperty -Name ChannelName -Value $site.Title
			$datum | Add-Member -MemberType NoteProperty -Name ChannelURL -Value $site.URL
			$datum | Add-Member -MemberType NoteProperty -Name ChannelStorageinMB -Value $site.StorageUsageCurrent
			$datum | Add-Member -MemberType NoteProperty -Name FileTotal -Value $ListItems.Count
			$datum | Add-Member -MemberType NoteProperty -Name FileID -Value $MyListItem["UniqueId"]
			$datum | Add-Member -MemberType NoteProperty -Name FileName -Value $MyListItem["Title"]
			$datum | Add-Member -MemberType NoteProperty -Name FileviewCount -Value $FileviewCount.ViewCount
			$datum | Add-Member -MemberType NoteProperty -Name FileCreator -Value $MyListItem["Created_x0020_By"]
			$datum | Add-Member -MemberType NoteProperty -Name FileModifier -Value $MyListItem["Modified_x0020_By"]
			$datum | Add-Member -MemberType NoteProperty -Name CreationDate -Value $MyListItem["Created"]
			$datum | Add-Member -MemberType NoteProperty -Name ModificationDate -Value $MyListItem["Modified"]
			$datum | Add-Member -MemberType NoteProperty -Name FileType -Value $MyListItem["File_x0020_Type"]
			$datum | Add-Member -MemberType NoteProperty -Name FileSizeMB -Value ([math]::round(($MyListItem["File_x0020_Size"]/(1024*1024)), 2))
			$datum | Add-Member -MemberType NoteProperty -Name FileAbsoluteURL -Value  $($MyListItem["FileDirRef"] +"/"+ $MyListItem["FileLeafRef"])
			$data += $datum
		}
		#Write-Host "StorageQuotainGB             :", ($site.StorageQuota/1024) -foregroundcolor Green
		#Write-Host "StorageQuotaWarningLevelinGB :", ($site.StorageQuotaWarningLevel/1024) -foregroundcolor Green
		Write-Host ""
		Write-Host "  ---------------------------------------------------------------------------  "
    }

	$datestring = (get-date).ToString("yyyyMMdd-hhmm")
	$fileName = ("C:\VideoPortal\VideoPortalDetails_" + $datestring + ".csv")
	
	Write-host " -----------------------------------------" -ForegroundColor Green
	Write-Host (" >>> writing to file {0}" -f $fileName) -ForegroundColor Green
	$data | Export-csv $fileName -NoTypeInformation
	Write-host " -----------------------------------------" -ForegroundColor Green
}

[string]$username = "Admin@yourtenant.onmicrosoft.com"
[string]$PwdTXTPath = "C:\SECUREDPWD\ExportedPWD-$($username).txt"

# Get needed information from end user
[string]$MyTenantName = "yourtenant"
[string]$SPOAdminPortal =  "https://"+ $MyTenantName +"-admin.sharepoint.com"
[string]$SPOSiteURL = "https://"+ $MyTenantName +".sharepoint.com"

Invoke-RestSPO -AdminPortalUrl $SPOAdminPortal -SPOUrl $SPOSiteURL -UserName $username -Password $PwdTXTPath -TenantName $MyTenantName

You can use that new version as you want.

Fabrice Romelard

 

Source used:

 

 

@Fabrice Romelard- Thank you so much!  Your script was very valuable.  My internal customers were asking for point-in-time view counts in Office 365 Video before I migrated them to Stream and your script did exactly what we needed (with a little tweaking from my 'automation team').

 

After the migration to Stream I'll be reviewing your other suggested script that is Stream oriented.

Thanks @George Cabe 

 

You are welcome and can use that script as you want to.

Fab

Related Conversations