Jump to content

Recommended Posts

Posted
Cripes! We've got a lot more class teams than that. Even more if it is pulling out ALL teams...! Wonder if it's possible to modify the scrip to only pull out Teams of a certain type...?
Posted

Some one has generated an updated powershell script on GitHub:

 

The original code uses Get-Team to get the ID and then runs it again to get the name, which is not required.

I have also worked on the code to find the first owner that is a member of the group to populate the Teacher column, and populate the School column from AD.

We use the Office field in AD as the School name for Outlook address book purposes.

I'm using Connect-MicrosoftTeams, Connect-MsolService, and Connect-AzureAD for other powershell commands.

I've also combined the 2 scripts into one, and added an extra check whether the TeamID already exists, that should probably be forced as unique field in the list?

`

$SiteUrl = "https://[domain]/sites/ClassroomDropIn"

$ListName = "Teams"

$CSVPath = "c:\temp\TeamsData.csv"

Connect-MicrosoftTeams

Connect-MsolService

Connect-AzureAD

$AllTeamsInOrg = Get-Team | Select GroupID,DisplayName

#$AllTeamsInOrg

$TeamList = @()

foreach ($Item in $AllTeamsInOrg)

{

$OwnerEmail = (Get-AzureADGroupOwner -ObjectId $Item.GroupId | where {$.UserType -eq 'Member'})[0].UserPrincipalName # UserPrincipalName should be the email address and will avoid errors with duplicate DisplayNames

$School = Get-MsolUser -UserPrincipalName $OwnerEmail | select -ExpandProperty Office # Populate the office field in AD so School can be assigned

$SchoolID = (Get-PnPListItem -List Schools | where {$["Title"] -eq $School}).ID # Get the ID number of the School from the Schools list

$This = "" | select-Object TeamName, TeamObjectID, TeamOwner, TeamSchool # $This will contain the details for each Team found and then add to an array to create the csv

$This.TeamName = $Item.DisplayName

$This.TeamObjectID = $Item.GroupID

$This.TeamOwner = $OwnerEmail

$This.TeamSchool = $SchoolID

$TeamList += $This

}

$TeamList | export-csv $CSVPath -NoTypeInformation

#=================================================

Connect-PnPOnline $SiteUrl

$CSVData = Import-CsV -Path $CSVPath

ForEach ($Row in $CSVData)

{

if ((Get-PnPListItem -List $Listname | where {$_["TeamID"] -eq $($Row.TeamObjectID)}) -eq $null) # check if a Team already exists with this GroupID

{

Add-PnPListItem -List $ListName -Values @{

"Title" = $($Row.TeamName);

"TeamID" = $($Row.TeamObjectID);

"Teacher" = $($Row.TeamOwner);

"School" = $($Row.TeamSchool);

};

}

}

 

https://github.com/OfficeDev/microsoft-teams-apps-classroom-dropin/issues/13

 

I havent tried it, but maybe worth a shot? could be quicker....

Posted
Well one step closer.... how ever seem to be having issues with the app writing back to the sharepoint site. Its read data all good, but when creating a drop-in session, it tells me its completed. However nothing listed in the app. If i add one manually it appears in the list.... Checked the permissions and the accounts for admin are correct.....
Posted
Some one has generated an updated powershell script on GitHub:

 

The original code uses Get-Team to get the ID and then runs it again to get the name, which is not required.

I have also worked on the code to find the first owner that is a member of the group to populate the Teacher column, and populate the School column from AD.

We use the Office field in AD as the School name for Outlook address book purposes.

I'm using Connect-MicrosoftTeams, Connect-MsolService, and Connect-AzureAD for other powershell commands.

I've also combined the 2 scripts into one, and added an extra check whether the TeamID already exists, that should probably be forced as unique field in the list?

`

$SiteUrl = "https://[domain]/sites/ClassroomDropIn"

$ListName = "Teams"

$CSVPath = "c:\temp\TeamsData.csv"

Connect-MicrosoftTeams

Connect-MsolService

Connect-AzureAD

$AllTeamsInOrg = Get-Team | Select GroupID,DisplayName

#$AllTeamsInOrg

$TeamList = @()

foreach ($Item in $AllTeamsInOrg)

{

$OwnerEmail = (Get-AzureADGroupOwner -ObjectId $Item.GroupId | where {$.UserType -eq 'Member'})[0].UserPrincipalName # UserPrincipalName should be the email address and will avoid errors with duplicate DisplayNames

$School = Get-MsolUser -UserPrincipalName $OwnerEmail | select -ExpandProperty Office # Populate the office field in AD so School can be assigned

$SchoolID = (Get-PnPListItem -List Schools | where {$["Title"] -eq $School}).ID # Get the ID number of the School from the Schools list

$This = "" | select-Object TeamName, TeamObjectID, TeamOwner, TeamSchool # $This will contain the details for each Team found and then add to an array to create the csv

$This.TeamName = $Item.DisplayName

$This.TeamObjectID = $Item.GroupID

$This.TeamOwner = $OwnerEmail

$This.TeamSchool = $SchoolID

$TeamList += $This

}

$TeamList | export-csv $CSVPath -NoTypeInformation

#=================================================

Connect-PnPOnline $SiteUrl

$CSVData = Import-CsV -Path $CSVPath

ForEach ($Row in $CSVData)

{

if ((Get-PnPListItem -List $Listname | where {$_["TeamID"] -eq $($Row.TeamObjectID)}) -eq $null) # check if a Team already exists with this GroupID

{

Add-PnPListItem -List $ListName -Values @{

"Title" = $($Row.TeamName);

"TeamID" = $($Row.TeamObjectID);

"Teacher" = $($Row.TeamOwner);

"School" = $($Row.TeamSchool);

};

}

}

 

https://github.com/OfficeDev/microsoft-teams-apps-classroom-dropin/issues/13

 

I havent tried it, but maybe worth a shot? could be quicker....

 

This failed, hard! Not sure if I have the energy at the moment to fix someone else's script!

Posted
Finally got all our Teams out, only 2500 of them! Need to get it reduced out to Class Teams somehow. I know they have an edu_CLASS template but can't see how to use it for Get-Teams...
Posted

I've managed to fix the powershell scripts etc, and all the data is going into Sharepoint lists.

 

For some reason when i run the app, it says my name at the top but then everything else is blank. Has anyone ran into this before?

 

I have given myself an isAdmin on the permissions list.

 

Thanks!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...