This PowerShell script will help you to export the following details from Office 365 video portal to a csv file.

 


- Channel Name
- Channel URL
- User Name with permissions (Owner, Editor and Viewer)

There are many circumstances in which an admin needs the complete list of these details to confirm that the permissions are assigned properly to required users. For example in schools Admin would like to grant channel creation permission only to teachers.
Below is the sample output of the script with the user permissions.
PowerShell
Edit|Remove
$UserName = "admin@XXXXX.onmicrosoft.com" 
$Password = "XXXXXX" 
$SPOUrl = "https://XXXXX.sharepoint.com" 
$AdminPortalUrl="https://XXXXX-admin.sharepoint.com" 
$CSVPath = "C:\temp\out.csv" 
 
Add-Type -Path ([System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client").location) 
Add-Type -Path ([System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.runtime").location) 
 
$SPOQueryUrl= $SPOUrl + "/portals/hub/_api/videoservice/Channels?$top=2000&$skip=0&$select=id,title,tilehtmlcolor&$orderby=title" 
$SecurePassword = $Password | ConvertTo-SecureString -AsPlainText -Force 
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName, $SecurePassword) 
$UserCredential = New-Object System.Management.Automation.PSCredential -argumentlist $UserName, $SecurePassword; 
 
$request = [System.Net.WebRequest]::Create($SPOQueryUrl) 
$request.Credentials = $credentials 
$request.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED""f") 
$request.Accept = "application/json;odata=verbose" 
$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 
 
Connect-SPOService -Url $AdminPortalUrl -Credential $UserCredential 
 
$channels = @{} 
$channelurls = @{} 
$results.d.results | ForEach-Object{ 
$channel = $_ 
$channelusers = @{} 
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SPOUrl + $channel.ServerRelativeUrl)  
$ctx.Credentials = $credentials  
$webSite = $ctx.Web 
$contributors = $webSite.SiteGroups.GetByName("Contributors") 
$viewers = $webSite.SiteGroups.GetByName("Viewers") 
$creators = $webSite.SiteGroups.GetByName("Creators") 
$ctx.Load($contributors) 
$ctx.Load($viewers) 
$ctx.Load($creators) 
$ctx.Load($webSite) 
$ctx.ExecuteQuery() 
ForEach($group in @($contributors,$viewers,$creators)){ 
$ctx.Load($group.Users) 
$ctx.ExecuteQuery() 
$group.Users | ForEach-Object {  
if ( !$channelusers.ContainsKey($_.LoginName)){ 
$object = New-Object –TypeName PSObject 
$object | Add-Member –MemberType NoteProperty –Name "DisplayName" –Value $_.Title 
$channelusers.Add($_.LoginName,$object) 
} 
$channelusers[$_.LoginName] | Add-Member –MemberType NoteProperty –Name $group.Title –Value $true 
} 
} 
$channels.Add($channel.Title,$channelusers) 
$channelurls.Add($channel.Title,$SPOUrl + $channel.ServerRelativeUrl) 
} 
 
$outp = @() 
ForEach($item in $channels.Keys) 
{ 
ForEach($useritem in $channels[$item].Keys) 
{ 
$object = $channels[$item][$useritem]  
$outp += New-Object -TypeName PSObject -Property @{ 
ChannelName=$item 
ChannelUrl=$channelurls[$item] 
DisplayName=$object.DisplayName 
Owner=$object.Creators 
Viewer=$object.Viewers 
Editor=$object.Contributors 
} 
} 
} 
$outp|select ChannelName,ChannelUrl,DisplayName,Owner,Viewer,Editor | Export-Csv -Path $CSVPath