Change/Add Office 365 Group Email using Office 365 PowerShell


$Creds = Get-Credential -Message “Please enter Office 365 Global Admin Credentials”
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $Creds -Authentication Basic -AllowRedirection
Import-PSSession $Session

$AllGroups = Get-UnifiedGroup -Filter *

#Getting first group just for checking. 
$FirstGroup = Get-UnifiedGroup -Identity $AllGroups[0].Id

#Syntax

#{Add=”<Type>:<emailaddress1>”,”<Type>:<emailaddress2>”,…; Remove=”<Type>:<emailaddress2>”,”<Type>:<emailaddress2>”}.

$EmailAdded = @{Add=”smtp:bigwigstest@sharepointmvp.onmicrosoft.com”}
Set-UnifiedGroup -Identity $FirstGroup.Id -EmailAddresses $EmailAdded -Verbose

Get all Sites and Subsites from SharePoint Online Sites


$User = “admin@M365x086769.onmicrosoft.com”
$Creds = Get-Credentials

$AllSites = @()
function Get-SPOSubWebs{
    Param(
        [Microsoft.SharePoint.Client.ClientContext]$Context,
        [Microsoft.SharePoint.Client.Web]$RootWeb
    )
 
 
    $Webs = $RootWeb.Webs
    $Context.Load($Webs)
    $Context.ExecuteQuery()
 
    ForEach ($sWeb in $Webs)
    {
        Write-Output $sWeb
        $SiteObject = [PSCustomObject]@{Site = $sWeb.Url }
        $AllSites +=$SiteObject
        Get-SPOSubWebs -RootWeb $sWeb -Context $Context
    }
}

Connect-SPOService -Url “https://M365x086769-admin.sharepoint.com” -Credential $Creds
$Sites = Get-SPOSite -Limit All | Select Url
foreach($Site in $Sites)
{
   
    Set-SPOUser -Site $Site.Url -LoginName $Creds.UserName -IsSiteCollectionAdmin $true -Verbose
    $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Creds.UserName, $Creds.Password)
    $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($Site.Url)
    $ctx.Credentials = $credentials
    $Web = $ctx.Web
    $ctx.Load($Web)
    $ctx.ExecuteQuery()
    $SiteObject = [PSCustomObject]@{SiteUrl = $Web.Url }
    $AllSites +=$SiteObject
    Get-SPOSubWebs -RootWeb $Web -Context $ctx   
}

$AllSites

$AllSites | Export-Csv -Path C:\temp\AllSites.csv -NoTypeInformation –Force

Link on Technet

https://gallery.technet.microsoft.com/Get-all-Sites-and-Subsites-a0972bdb