Public/Invoke-AddGroupMember.ps1

function Invoke-AddGroupMember {
    <#
    .SYNOPSIS
        Adds user to a certain group
    .PARAMETER UserName
        Target user
    .PARAMETER GroupType
        Options are basic, standard, and mfa
    .EXAMPLE
        !add dk.test.hz basic|standard|mfa
    #>

    [PoshBot.BotCommand(
        CommandName = 'add',
        Aliases = ('group', 'addgroup', 'member')
    )]
    [cmdletbinding()]
    param(
        [parameter(Mandatory)]
        [string]$username,
        [parameter(Mandatory)]
        [string]$grouptype
    )
    Import-Module ActiveDirectory
    $searchname = '*' + $username + '*'
    $GCADUser = Get-ADUser -Filter { (((SamAccountName -like $searchname) -or (Name -like $searchname)) -and ((Enabled -eq $true) -and (mail -like "*"))) } -Server sundc1:3268

    switch ($grouptype) {
        "basic" {
            $group = Get-ADGroup -Identity "sunssc.M365-business-basic.usg"
            Add-ADGroupMember -identity "sunssc.M365-business-basic.usg" -Members $GCADUser
        }
        "standard" {
            $group = Get-ADGroup -Identity "sunssc.M365-business-standard.usg"
            Add-ADGroupMember -identity "sunssc.M365-business-standard.usg" -Members $GCADUser
        }
        "mfa" {
            $group = Get-ADGroup -Identity "sunssc.Azure-MFA-users.usg"
            Add-ADGroupMember -identity "sunssc.Azure-MFA-users.usg" -Members $GCADUser
        }
    }
    New-PoshBotCardResponse -Text ("$GCADUser.DistinguishedName has been added to $group.distinguishedname!")
    Start-Sleep -seconds 60
    $result = Invoke-Command -ComputerName "sun-aad.sunssc.local" -ScriptBlock {
        Start-ADSyncSyncCycle -PolicyType Delta
    }
    New-PoshBotCardResponse -Type Normal -Text ($result | format-list -property * | out-string) -Title "Sync Azure AD"
}