Install New-UnifiedGroup

Welcome Forums General PowerShell Q&A Install New-UnifiedGroup

This topic contains 3 replies, has 3 voices, and was last updated by

 
Participant
2 weeks, 1 day ago.

  • Author
    Posts
  • #113302

    Participant
    Points: 0
    Rank: Member

    Hi,

    So I'm currently trying to make a Microsoft Team generator within my Azure function app and I'm trying to use the cmdlets "New-UnifiedGroup" in PowerShell to create an O365 group, unfortunately, I can't find any way to install it.

    Here's my code.

    
    New-UnifiedGroup -DisplayName $DisplayName -Alias $DisplayName -EmailAddresses $EmailAddresses -Owner $EmailAddresses -RequireSenderAuthentificationEnabled $False -Verbose
    
    $encpassword = ConvertTo-SecureString -String $password_string -AsPlainText -Force
    $credentials = new-object -typename System.Management.Automation.PSCredential -argumentlist ($username, $encpassword)
    connect-PnPOnline -credentials $credentials -Url $url
    Import-PSSession $session
    New-Team -Group (Get-UnifiedGroup $DisplayName).ExternalDirectoryObjectId -Verbose
    

    favor

     

  • #113315

    Participant
    Points: 20
    Rank: Member

    Where it the $Session variable set in the above code ?

  • #113320

    Participant
    Points: 0
    Rank: Member

    Here's my entire code :

    
    $requestBody = Get-Content $triggerInput -Raw | ConvertFrom-Json
    $GroupName = $requestBody.GroupName
    Write-Output $GroupName
    $url = "https://tenant.sharepoint.com"
    $upn = $requestBody.upn
    $alias = $requestBody.Alias
    $DisplayName = $requestBody.DisplayName
    $EmailAddresses = $requestBody.EmailAddresses
    $username = ""
    $password_string = ""
    New-UnifiedGroup -DisplayName $DisplayName -Alias $DisplayName -EmailAddresses $EmailAddresses -Owner $EmailAddresses -RequireSenderAuthentificationEnabled $False -Verbose
    $encpassword = ConvertTo-SecureString -String $password_string -AsPlainText -Force
    $credentials = new-object -typename System.Management.Automation.PSCredential -argumentlist ($username, $encpassword)
    connect-PnPOnline -credentials $credentials -Url $url
    New-Team -Group (Get-UnifiedGroup $DisplayName).ExternalDirectoryObjectId -Verbose
    
    

    Do i need to do something with $Session ?

  • #113338

    Participant
    Points: 0
    Rank: Member

    you need to define $session before you import it

You must be logged in to reply to this topic.