Skip to content

Instantly share code, notes, and snippets.

View chrisbrownie's full-sized avatar
🛩️
computering

Chris Brown chrisbrownie

🛩️
computering
View GitHub Profile
@chrisbrownie
chrisbrownie / Update-UPNs.ps1
Created September 1, 2015 22:15
Updates the UPN of all users in a specified location to match their primary SMTP address
$SearchBase = "DC=MargiesTravel,DC=com"
# Get all the users who have proxyAddresses under the margiestravel.com domain
foreach ($user in (Get-ADUser -SearchBase $SearchBase -LdapFilter '(proxyAddresses=*)')) {
# Grab the primary SMTP address
$address = Get-ADUser $user -Properties proxyAddresses | Select -Expand proxyAddresses | Where {$_ -clike "SMTP:*"}
# Remove the protocol specification from the start of the address
$newUPN = $address.SubString(5)
# Update the user with their new UPN
Set-ADUser $user -UserPrincipalName $newUPN
# Import MSOL Module
Import-Module MSOnline
# Connect to the service
Connect-MsolService
# What's the AAD Sku? We'll assign this to admins
$aadSku = (Get-MsolAccountSku | Where {$_.AccountSkuId -ilike "*:AAD_PREMIUM"})[0].AccountSkuId
# Define StrongAuthentication (MFA) requirements
# Get all users with MFA enabled
# Import MSOL Module
Import-Module MSOnline
# Connect to the service
Connect-MsolService
#Find all MFA enabled users
$MfaUsers = Get-MsolUser -All | Where-Object {$_.StrongAuthenticationRequirements -like "*"}
@chrisbrownie
chrisbrownie / PowerShellTTS.ps1
Last active December 29, 2016 21:41
PowerShell Text To Speech
Add-Type -AssemblyName System.speech
$ss = New-Object System.Speech.Synthesis.SpeechSynthesizer
$ss.Rate = -3
$ss.Speak("Hello I am a computer")
@chrisbrownie
chrisbrownie / Convert-ADGroupsToGlobal.ps1
Last active August 23, 2016 10:46
Bulk Convert AD Groups to Global
# Get all the groups in the OU we're targeting
$groups = Get-ADGroup –Filter * -SearchBase “OU=File Shares,OU=Groups,DC=Contoso,DC=com”
# Recurse through each group
Foreach ($group in $groups) {
# Make it universal
$group | Set-ADGroup –GroupScope 2
# Make it global
$group | Set-ADGroup –GroupScope 1
}