PowerShell & Teams, want to figure out the Cmdlet can work or not, thanks a lot.

New Contributor

PowerShell rookie need help!

Want to figure out about #Q1 #Q2 #Q3

Appreciate!

 

 

 

try{
    Connect-MicrosoftTeams
    Connect-SPOService
    
    $url = "http://abc.sharepoint.com/sites/"
    $owner = "Terry"
    $displayName = "TerryTeam"

    $group = New-Team -DisplayName $displayName -Description $description -Visibility Private -Owner $owner 
        
    Add-TeamUser -GroupId $group.GroupId -User $user 
    Add-TeamUser -GroupId $group.GroupId -User $user -Role $owner

    $siteUrl = $url + $group.MailNickName

    Set-SPOSite -Identity $siteUrl -Sharingcapability ExistingExternalUserSharingOnly
    Set-SPOSite -Identity $siteUrl -StorageQuota 10240
    
    # ---------------Get result---------------

    $teamName = Get-Team -GroupId $group.GroupId | Select-Object DisplayName # 1
        # or
    $teamName = Get-Team -GroupId $group.GroupId # 2
    $teamName.DisplayName
        # expect = TerryTeam
        # result = wondering this code can really work or not.
        # Q1 = Want to know 1 or 2 which can really work? Or both can't?

    $teamOwner = Get-TeamUser -GroupId $group.GroupId -Role Owner
        # expect = Terry
        # result = Microsoft.Teams.PowerShell.TeamsCmdlets.GetTeamUserResponse
        # Q2 = I think the code is no porblem, but keep error like this.
    $storageResult = Get-SPOSite -Identity $siteUrl | Select StorageQuota
        # expect = 10240
        # result = @{StorageQuota=10240}
        # Q3 = Did I missed some solution?
}
catch{
}
finally{
}

 

2 Replies

@LinTse 

 

What is it you are trying to achieve? Create a script to report on a Team and underlying quota of the SharePoint Site? 

 

A good article for getting the SharePoint Site Quota is here:

 

SharePoint Online: Get Site Collection Storage Size - Quota Usage Report using PowerShell - SharePoi...

 

Think $Site.StorageQuota and $Site.StorageUsageCurrent is what you are looking for Q3. 

 

Also notice at the top, should $url = https:// not http://

 

Let's see if we can get Q3 right then move onto the other 2 :D 

 

Hope that helps

 

Best, Chris

Thank you for replies! And sorry, my description is not clear enough.

The column No.1~17, is the script for create Teams and setting Owner and StorageQuota.
(It's working without error, and value setting also correct so far.)

The No.21~35 is the script which I'm trying to get, DisplayName, Owner, StorageQuota perfectly. (Especially Q2.)
As you say, report the Team's information which just been created, and underlying information of the SharePoint Site

Q1. DisplayName
Wan't to knnow No.21 or No.23~24, which can retrieve the DisplayName correctly, or both?

Q2. Owner
The log showing >>Microsoft.Teams.PowerShell.TeamsCmdlets.GetTeamUserResponse<<
I think GroupId is no problem, but don't know why it can't retrieve the SharePoint Site's owner value "Terry".

Q3. StorageQuota
I think the No.33, pipeline and select to retrieve the StorageQuota value is working right.
But want to know how to make the value "@{StorageQuota=10240}" to "10240" in log file? Sorry, still learning PowerShell.

Sorry, need to wait till 1/5 to test.
We support Ukraine and condemn war. Push Russian government to act against war. Be brave, vocal and show your support to Ukraine. Follow the latest news HERE