From 144f7c883bce0ae7871786fb8f462961e1671b61 Mon Sep 17 00:00:00 2001 From: moebit Date: Fri, 26 May 2023 01:30:05 +0200 Subject: [PATCH] =?UTF-8?q?[Misc]=20Hinzuf=C3=BCgen=20neuer=20Skripte=20f?= =?UTF-8?q?=C3=BCr=20das=20Offboarding=20von=20JEs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Misc/JE-Offboarding/Remove-JE-Contatcs.ps1 | 12 ++++++++++++ Misc/JE-Offboarding/Remove-JE-Guest-Users copy.ps1 | 11 +++++++++++ Misc/README.md | 5 ++++- 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 Misc/JE-Offboarding/Remove-JE-Contatcs.ps1 create mode 100644 Misc/JE-Offboarding/Remove-JE-Guest-Users copy.ps1 diff --git a/Misc/JE-Offboarding/Remove-JE-Contatcs.ps1 b/Misc/JE-Offboarding/Remove-JE-Contatcs.ps1 new file mode 100644 index 0000000..6df7172 --- /dev/null +++ b/Misc/JE-Offboarding/Remove-JE-Contatcs.ps1 @@ -0,0 +1,12 @@ +# The script is used to remove the je contacts that are used in the configuration of the various BDSU distribution groups like BDS MIT Line. +Connect-ExchangeOnline + +$Contacts = Get-MailContact -Resultsize unlimited +$FilteredJeContacts = $Contacts | Where-Object {$_.PrimarySmtpAddress -like '*@je-domain.org'} +$FilteredJeContacts | Sort-Object Identity +$FilteredJeContacts | ForEach-Object { + Users | ForEach-Object { + # Before you remove the guest user pls check if everything is correct and than remove the comment + # Remove-MailContact -Identity $_.PrimarySmtpAddress -Confirm:$false + Write-Host "Removed contact" $_.Identity +} \ No newline at end of file diff --git a/Misc/JE-Offboarding/Remove-JE-Guest-Users copy.ps1 b/Misc/JE-Offboarding/Remove-JE-Guest-Users copy.ps1 new file mode 100644 index 0000000..bb20caf --- /dev/null +++ b/Misc/JE-Offboarding/Remove-JE-Guest-Users copy.ps1 @@ -0,0 +1,11 @@ +# The script is used to remove JE guest accounts that allow access to the BDSU intranet. +Connect-AzureAd + +$GuestUsers = Get-AzureADUser -Filter "UserType eq 'Guest'" -All $true +$JeUsers = $GuestUsers | Where-Object {$_.mail -like '*@je-domain.org'} +$JeUsers | Sort-Object DisplayName +$JeUsers | ForEach-Object { + # Before you remove the guest user pls check if everything is correct and than remove the comment + # Remove-AzureADUser -ObjectId $_.ObjectId + Write-Host "Removed guest user" $_.DisplayName +} \ No newline at end of file diff --git a/Misc/README.md b/Misc/README.md index 4a22c62..678b149 100644 --- a/Misc/README.md +++ b/Misc/README.md @@ -1,2 +1,5 @@ ### [Delete-Mail-Globally.ps1](Delete-Mail-Globally.ps1) -Skript, um eingenangene und nicht gefilterte Phishing-Emails aus allen vorhandenen Postfächern im MS365 Tenant zu entfernen. \ No newline at end of file +Skript, um eingenangene und nicht gefilterte Phishing-Emails aus allen vorhandenen Postfächern im MS365 Tenant zu entfernen. + +### [JE-Offboarding](/admin-scripts/Misc/JE-Offboarding/) +Skripte, um eine JE, die nicht mehr Teil des BDSU ist offzuboarden \ No newline at end of file