Tech Quip: Allowing Office 365 Sharepoint Sharing Outside of Organization

Original source:

$usercredential = Get-Credential -username $adminUPN -Message "type password"
Connect-SPOService -Url https://$ -Credential $userCredential
set-sposite -identity $Siteurl -sharingcapability ExternalUserAndGuestSharing

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



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:"}