#This script will assign a specified license to every user that is a part of a specified group.
#Connecting to Office 365
$usercredential = get-credential -credential "ENTER LOGIN HERE"
Connect-MsolService -Credential $usercredential
#This is the license, Specify license from Get-MsolAccountSku
$myAccountSKUID = "ENTER HERE"
#This sets the license to a variable
$licenseOptions = New-MsolLicenseOptions -AccountSkuId $myAccountSKUID
#This grabs the users in the specified group, Specify group ID from Get-MsolGroup
$users = Get-MsolGroupMember -GroupObjectId "ENTER GROUP ID HERE"
#Each listed user in the group
foreach($user in $users)
{
#Since the username is essentially the user's email address in our O365, this sets a users license based on the user's
#email address that is listed from the specified group to their principal name (which also happens to be their email) in O365
Set-MsolUserLicense -UserPrincipalName $user.EmailAddress -AddLicenses $myAccountSKUID
}