Tech Quip: Allowing Office 365 Sharepoint Sharing Outside of Organization

Original source:
http://itgroove.net/brainlitter/2017/06/01/enable-guest-folder-file-sharing-office-365-group-files/

https://www.microsoft.com/en-ca/download/details.aspx?id=35588

$adminUPN="replace_with_username"
$orgName="name_of_sharepoint_prefix"
$usercredential = Get-Credential -username $adminUPN -Message "type password"
Connect-SPOService -Url https://$orgName-admin.sharepoint.com -Credential $userCredential
$siteurl="https://$orgName.sharepoint.com/sites/desired_site_collection"
set-sposite -identity $Siteurl -sharingcapability ExternalUserAndGuestSharing

Code Dump: Change UPN for all members of an AD Group

$ADGROUP="TEST"
$OLDUPN="@OLDDOMAIN.COM"
$NEWUPN="@NEWDOMAIN.COM"

$GRPMEM=Get-ADGroupMember $ADGROUP

Get-ADGroupmember $ADGROUP | ForEach-Object {
$USER=Get-ADUser $_.samaccountname
$UPN = $USER.UserPrincipalName.Replace($OLDUPN,$NEWUPN)
Set-ADUser $USER.samaccountname -UserPrincipalName $UPN
}

Tech Quip: Primary ProxyAddress

In an Azure AD Sync, the ProxyAddress with SMTP is treated as the primary email address. All others should be prefaced with “smtp” in lowercase. If there are more than one in all caps, it takes the first alphabetically.

Get-ADUser -Filter * -Properties SamAccountName, ProxyAddresses | ft samaccountname,proxyaddresses
Set-ADUser -Identity NAME -Clear ProxyAddresses
Set-ADUser -Identity NAME -Add @{Proxyaddresses="SMTP:"}
Set-ADUser -Identity NAME -Add @{Proxyaddresses="smtp:"}