Hi I am hoping someone can help me with the below script?
I want to create a script that exports Teams detials to an excel spreadsheet that will show the following details. Team Name, Team Description, No of Owners, Owners, No of Channels and Channels.
The script I am running produces all this but I would like to try and put it in a csv format with each team details on 1 line. So the owners etc would be ‘Owner1, Owner2, Etc’ in 1 cell and Channels would be 'Channel1, Channel2, etc) .
The script is the below I am struggling how to add the Owner and Teams Channels to appear as 1 entity. (Hope that makes sense). I believe I need to add all the owners to its own array (seperated by a ‘,’) and the same for the Teams channels but struggling on how to do this.
This is the script that brings back the detials.
$allteams = Get-Team
$object = @()
foreach ($t in $allteams) {
$members = Get-TeamUser -GroupId $t.GroupId
$owner = Get-TeamUser -GroupId $t.GroupId -Role Owner
$channels = Get-TeamChannel -GroupId $t.GroupId
$object += New-Object -TypeName PSObject -Property ([ordered]@{
'Team Name'= $t.DisplayName
'Description' = $t.Description
'No Of Owners' = $owner.count
'Owners' = $owner.User
'Members' = $members.count
'No Of Channels' = $channels.count
'Channels' = $channels.displayname -join "`r`n"
})
}
Write-Output $object | Out-File C:\Temp\TeamsDetails.txt
Once I have found how to add the team owners and channels to its own array I should then be able to export the report to a csv rather than a text file.
Thanks for any help in advance.
Thanks
Dom