Skip to content

Instantly share code, notes, and snippets.

View mobernberger's full-sized avatar

Michael Obernberger mobernberger

  • Austria
  • 12:51 (UTC +02:00)
View GitHub Profile

Disable account linking for your tenant using the following steps:

  1. Download this PowerShell script
  2. Open an instance of the PowerShell script in admin mode
  3. Run the following command first Set-ExecutionPolicy unrestricted
  4. Run the PowerShell script
  5. Follow the instructions the script prompts
  6. The cmdlet will prompt you to sign in with your AAD account
  7. Once signed in, it will disable account linking for your tenant
@mobernberger
mobernberger / disable-myanalytics.ps1
Created February 14, 2022 07:32
Disable MyAnaltics for all users
#Connect to Exchange Online Powershell before running this commands.
Get-Mailbox -ResultSize unlimited | Set-MyAnalyticsFeatureConfig -Feature all -IsEnabled $false -PrivacyMode opt-out
@mobernberger
mobernberger / Test-ProxyLogon-expanded.ps1
Last active March 10, 2021 19:27
Hafnium Check expanded
# Forked from the Original Microsoft script and added some more outputs and checks for aspx files - KBC 10.03.2021 / Michael Obernberger
#
#
# Checks for signs of exploit from CVE-2021-26855, 26858, 26857, and 27065.
#
# Examples
#
# Check the local Exchange server only and save the report:
# .\Test-ProxyLogon.ps1 -OutPath $home\desktop\logs
#
#Install the DCToolbox Module
Install-Module DCToolbox
#Connect to MS Graph Endpoint with the module
Connect-DCMsGraphAsDelegated
#Export the policies to a Excel file
New-DCConditionalAccessPolicyDesignReport
#Start an administrative powershell on your ADFS server
$msolId = "urn:federation:MicrosoftOnline"
$rptName = "Microsoft Office 365 Identity Platform"
$rptRules = (Get-AdfsRelyingPartyTrust -Identifier $msolId).IssuanceTransformRules
$newRule = '@RuleTemplate = "LdapClaims" @RuleName = "UPN Claim Rule" c1:[Type == "http://schemas.microsoft.com/ws/2012/01/passwordexpirationtime"] => issue(store = "_PasswordExpiryStore", types = ("http://schemas.microsoft.com/ws/2012/01/passwordexpirationtime","http://schemas.microsoft.com/ws/2012/01/passwordexpirationdays","http://schemas.microsoft.com/ws/2012/01/passwordchangeurl"), query = "{0};", param = c1.Value);'
$rptRules = $rptRules + $newRule
Set-AdfsRelyingPartyTrust -TargetName $rptName -IssuanceTransformRules $rptRules
#Start an administrative Powershell on your ADFS Server
Enable-AdfsEndpoint "/adfs/portal/updatepassword/"
Set-AdfsEndpoint "/adfs/portal/updatepassword/" -Proxy:$true
#This command restarts the ADFS service to enable the funcitionality (short ADFS interruption)
Restart-Service AdfsSrv -Force
@mobernberger
mobernberger / exo-message-size.ps1
Last active March 29, 2020 17:57
With this series of commands you could change the maximum send and receive size in Exchange Online
#Connect to Exchange Online Powershell before running this commands.
#Get the actual value for all Mailbox Plans
Get-MailboxPlan | fl name,maxsendsize,maxreceivesize,isdefault
#Set the the max send and receive size to 50MB
Get-MailboxPlan | Set-MailboxPlan -MaxSendSize [On-Prem value in MB / e.g. 50MB] -MaxReceiveSize [On-Prem value in MB / e.g. 50MB]
#Set the max send and receive size 50MB for existing mailboxes
Get-Mailbox -ResultSize unlimited -Filter {(RecipientTypeDetails -eq 'UserMailbox')} | Set-Mailbox -MaxSendSize 50MB -MaxReceiveSize 50MB
@mobernberger
mobernberger / block-guest-for-specific-o365group.ps1
Last active March 21, 2020 17:10
With this script/commandlet you could block/allow external guests to specific Office 365 group
#Connect to Azure AD Powershell with the Preview Module: Install-Module AzureADPreview
#Search for specific group
$GroupID = get-unifiedgroup -Identity <Insert SMTP or Identity> | Select-Object -ExpandProperty ExternalDirectoryObjectId
#Check if there is already a specific group settings specified and delete it
$SettingID = Get-AzureADObjectSetting -TargetType Groups -TargetObjectID $GroupID | select-object -expandproperty ID
Remove-azureadobjectsetting -id $settingid -targettype Groups -TargetObjectID $GroupID
#Create a new setting with Guests disabled
#Connect to Exchange Online Powershell before running this commands.
$Mbx = Get-Mailbox -RecipientTypeDetails UserMailbox, SharedMailbox -ResultSize Unlimited | Select DistinguishedName, DisplayName
ForEach ($M in $Mbx) {
Write-Host "Manually enabling mailbox auditing for" $M.DisplayName
Set-Mailbox -Identity $M.DistinguishedName -AuditEnabled $True }