Added Files
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
# Bulk change guest accounts from a certain domain so that they show in the Global Address List
|
||||
#
|
||||
# Uses the new PowerShell "module" that support MFA.
|
||||
#
|
||||
|
||||
# What domain are the guests email addresses from?
|
||||
$guestDomain = ''
|
||||
|
||||
# Find and load the new ExO "module"
|
||||
$exoModulePath = (Get-ChildItem -Path $env:userprofile -Filter CreateExoPSSession.ps1 -Recurse -Force -ErrorAction SilentlyContinue).DirectoryName[-1]
|
||||
. "$exoModulePath\CreateExoPSSession.ps1"
|
||||
|
||||
# Establish a session to Exchange Online
|
||||
Connect-EXOPSSession
|
||||
|
||||
# Find all the relevant users and enable them to show in the address list
|
||||
Get-MailUser -ResultSize Unlimited | Where-Object {$_.RecipientTypeDetails -eq 'GuestMailUser' -and $_.EmailAddresses -match $guestDomain} | Set-MailUser -HiddenFromAddressListsEnabled $false
|
||||
|
||||
# End the Exchange Session
|
||||
Get-PSSession | Where-Object {$_.ComputerName -eq 'outlook.office365.com'} | Remove-PSSession
|
||||
@@ -0,0 +1,42 @@
|
||||
# Create a group and add it to all room mailboxes as an editor
|
||||
#
|
||||
# Uses the new PowerShell "module" that support MFA.
|
||||
#
|
||||
|
||||
# What do you want the editors group to be called?
|
||||
$editorsGroup = 'Calendar Editors'
|
||||
|
||||
# Who do you want to be in the group? This can be 1 or more people.
|
||||
$editorsMembers = @('','')
|
||||
|
||||
# Find and load the new ExO "module"
|
||||
$exoModulePath = (Get-ChildItem -Path $env:userprofile -Filter CreateExoPSSession.ps1 -Recurse -Force -ErrorAction SilentlyContinue).DirectoryName[-1]
|
||||
. "$exoModulePath\CreateExoPSSession.ps1"
|
||||
|
||||
# Establish a session to Exchange Online
|
||||
Connect-EXOPSSession
|
||||
|
||||
# Get all room mailboxes in the organisation
|
||||
$roomMailboxes = (Get-Mailbox -RecipientTypeDetails RoomMailbox).Alias
|
||||
|
||||
# If the editors group doesn't exist, create it.
|
||||
if (!(Get-DistributionGroup -Identity $editorsGroup -ErrorAction SilentlyContinue)) {
|
||||
New-DistributionGroup -Name $editorsGroup -Type Security
|
||||
}
|
||||
|
||||
# Add members to the group
|
||||
$existingMembers = Get-DistributionGroupMember -Identity $editorsGroup
|
||||
foreach ($editorsMember in $editorsMembers) {
|
||||
if ($editorsMember -notin $existingMembers.Name) {
|
||||
Add-DistributionGroupMember -Identity $editorsGroup -Member $editorsMember
|
||||
}
|
||||
}
|
||||
|
||||
# Add the permissions to the mailboxes
|
||||
foreach ($roomMailbox in $roomMailboxes) {
|
||||
$calendarFolder = $mailboxAlias + ':\calendar'
|
||||
Add-MailboxFolderPermission -Identity $calendarFolder -User $editorsGroup -AccessRights Editor
|
||||
}
|
||||
|
||||
# End the Exchange Session
|
||||
Get-PSSession | Where-Object {$_.ComputerName -eq 'outlook.office365.com'} | Remove-PSSession
|
||||
@@ -0,0 +1,41 @@
|
||||
# Create a rule to block email forwarding to specific domains.
|
||||
#
|
||||
# Uses the new PowerShell "module" that support MFA.
|
||||
#
|
||||
|
||||
# What domains are we blocking?
|
||||
$domainListFile = 'C:\Temp\DomainList.txt'
|
||||
|
||||
# What do we want to call the rule?
|
||||
$ruleName = 'Block Auto Forwarding to Specific Domains 4'
|
||||
|
||||
# What reason do we want end users to see for the rejection?
|
||||
$rejectionReason = 'Auto forwarding messages to this email provider is not permitted.'
|
||||
|
||||
# Find and load the new ExO "module"
|
||||
$exoModulePath = (Get-ChildItem -Path $env:userprofile -Filter CreateExoPSSession.ps1 -Recurse -Force -ErrorAction SilentlyContinue).DirectoryName[-1]
|
||||
. "$exoModulePath\CreateExoPSSession.ps1"
|
||||
|
||||
# Establish a session to Exchange Online
|
||||
Connect-EXOPSSession
|
||||
|
||||
# Get the domain list from the file
|
||||
$domainList = Get-Content -Path $domainListFile
|
||||
|
||||
# Create a new rule
|
||||
$parameters = @{
|
||||
'Name' = $ruleName;
|
||||
'FromScope' = 'InOrganization';
|
||||
'SenderAddressLocation' = 'Header'
|
||||
'RecipientDomainIs' = $domainList;
|
||||
'MessageTypeMatches' = 'AutoForward';
|
||||
'RejectMessageEnhancedStatusCode' = '5.7.1'
|
||||
'RejectMessageReasonText' = $rejectionReason;
|
||||
'Priority' = 0;
|
||||
'Mode' = 'Enforce'
|
||||
'Enabled' = $true
|
||||
}
|
||||
New-TransportRule @parameters
|
||||
|
||||
# End the Exchange Session
|
||||
Get-PSSession | Where-Object {$_.ComputerName -eq 'outlook.office365.com'} | Remove-PSSession
|
||||
@@ -0,0 +1,91 @@
|
||||
# Script to bulk remove email proxy addresses from Exchange Online users
|
||||
#
|
||||
|
||||
# Which domains are we removing?
|
||||
$domainsToRemove = @('','')
|
||||
|
||||
# Find and load the new ExO "module"
|
||||
$exoModulePath = (Get-ChildItem -Path $env:userprofile -Filter CreateExoPSSession.ps1 -Recurse -Force -ErrorAction SilentlyContinue).DirectoryName[-1]
|
||||
. "$exoModulePath\CreateExoPSSession.ps1"
|
||||
|
||||
# Establish a session to Exchange Online
|
||||
Connect-EXOPSSession
|
||||
|
||||
### Remove the domain from mailboxes ###
|
||||
|
||||
# Get All Mailboxes
|
||||
$allMailboxes = Get-Mailbox -ResultSize Unlimited | Sort-Object -Property alias
|
||||
|
||||
# Remove alias from each mailbox
|
||||
foreach ($mailbox in $allMailboxes) {
|
||||
$redundantAddresses = @()
|
||||
foreach ($domainToRemove in $domainsToRemove) {
|
||||
$redundantAddresses += (($mailbox.EmailAddresses -split ',' | Where-Object {$_ -like ('*' + $domainToRemove + '*')}) -replace 'smtp:','')
|
||||
}
|
||||
if ($redundantAddresses.Count -gt 0) {
|
||||
Write-Output -InputObject ('Removing addresses ' + $redundantAddresses + ' from maibox ' + $mailbox.Name)
|
||||
Set-Mailbox -Identity $mailbox.Identity -EmailAddresses @{remove=$redundantAddresses} -Confirm:$false
|
||||
}
|
||||
}
|
||||
|
||||
###
|
||||
|
||||
### Remove the domain from contacts ###
|
||||
|
||||
# Get all the contacts
|
||||
$allContacts = Get-MailContact -ResultSize Unlimited | Sort-Object -Property alias
|
||||
|
||||
# Remove alias from each contact
|
||||
foreach ($contact in $allContacts) {
|
||||
$redundantAddresses = @()
|
||||
foreach ($domainToRemove in $domainsToRemove) {
|
||||
$redundantAddresses += (($contact.EmailAddresses -split ',' | Where-Object {$_ -like ('*' + $domainToRemove + '*')}) -replace 'smtp:','')
|
||||
}
|
||||
if ($redundantAddresses.Count -gt 0) {
|
||||
Write-Output -InputObject ('Removing addresses ' + $redundantAddresses + ' from contact ' + $contact.Name)
|
||||
Set-MailContact -Identity $contact.Identity -EmailAddresses @{remove=$redundantAddresses} -Confirm:$false -ForceUpgrade:$true
|
||||
}
|
||||
}
|
||||
|
||||
###
|
||||
|
||||
### Remove the domain from groups ###
|
||||
|
||||
# Get all the groups (this includes email enabled security groups)
|
||||
$allGroups = Get-DistributionGroup -ResultSize Unlimited | Sort-Object -Property alias
|
||||
|
||||
# Remove alias from each group
|
||||
foreach ($group in $allGroups) {
|
||||
$redundantAddresses = @()
|
||||
foreach ($domainToRemove in $domainsToRemove) {
|
||||
$redundantAddresses += (($group.EmailAddresses -split ',' | Where-Object {$_ -like ('*' + $domainToRemove + '*')}) -replace 'smtp:','')
|
||||
}
|
||||
if ($redundantAddresses.Count -gt 0) {
|
||||
Write-Output -InputObject ('Removing addresses ' + $redundantAddresses + ' from group ' + $group.Name)
|
||||
Set-DistributionGroup -Identity $group.Identity -EmailAddresses @{remove=$redundantAddresses} -Confirm:$false
|
||||
}
|
||||
}
|
||||
|
||||
###
|
||||
|
||||
### Remove the domain from public folders ###
|
||||
|
||||
# Get all the groups (this includes email enabled security groups)
|
||||
$allPublicFolders = Get-MailPublicFolder -ResultSize Unlimited | Sort-Object -Property alias
|
||||
|
||||
# Remove alias from each public folder
|
||||
foreach ($publicFolder in $allPublicFolders) {
|
||||
$redundantAddresses = @()
|
||||
foreach ($domainToRemove in $domainsToRemove) {
|
||||
$redundantAddresses += (($publicFolder.EmailAddresses -split ',' | Where-Object {$_ -like ('*' + $domainToRemove + '*')}) -replace 'smtp:','')
|
||||
}
|
||||
if ($redundantAddresses.Count -gt 0) {
|
||||
Write-Output -InputObject ('Removing addresses ' + $redundantAddresses + ' from public folder ' + $publicFolder.Name)
|
||||
Set-MailPublicFolder -Identity $publicFolder.Identity -EmailAddresses @{remove=$redundantAddresses} -Confirm:$false
|
||||
}
|
||||
}
|
||||
|
||||
###
|
||||
|
||||
# End the Exchange Session
|
||||
Get-PSSession | Where-Object {$_.ComputerName -eq 'outlook.office365.com'} | Remove-PSSession
|
||||
@@ -0,0 +1,20 @@
|
||||
# Enable Modern Authentication in Exchange Online
|
||||
#
|
||||
# Uses the new PowerShell "module" that support MFA.
|
||||
#
|
||||
|
||||
# Find and load the new ExO "module"
|
||||
$exoModulePath = (Get-ChildItem -Path $env:userprofile -Filter CreateExoPSSession.ps1 -Recurse -Force -ErrorAction SilentlyContinue).DirectoryName[-1]
|
||||
. "$exoModulePath\CreateExoPSSession.ps1"
|
||||
|
||||
# Establish a session to Exchange Online
|
||||
Connect-EXOPSSession
|
||||
|
||||
# Enable modern authentication
|
||||
Set-OrganizationConfig -OAuth2ClientProfileEnabled $true
|
||||
|
||||
# Verify the setting has changed
|
||||
Get-OrganizationConfig | Format-Table -AutoSize Name,OAuth2ClientProfileEnabled
|
||||
|
||||
# End the Exchange Session
|
||||
Get-PSSession | Where-Object {$_.ComputerName -eq 'outlook.office365.com'} | Remove-PSSession
|
||||
@@ -0,0 +1,29 @@
|
||||
# Enable mailbox auditing on mailboxes where auditing is not already enabled
|
||||
#
|
||||
# This is a rewrite of a script from https://github.com/OfficeDev/O365-InvestigationTooling
|
||||
#
|
||||
|
||||
# Find and load the new ExO "module"
|
||||
$exoModulePath = (Get-ChildItem -Path $env:userprofile -Filter CreateExoPSSession.ps1 -Recurse -Force -ErrorAction SilentlyContinue).DirectoryName[-1]
|
||||
. "$exoModulePath\CreateExoPSSession.ps1"
|
||||
|
||||
# Establish a session to Exchange Online
|
||||
Connect-EXOPSSession
|
||||
|
||||
# Set Auditing parameters
|
||||
$params = @{
|
||||
'AuditEnabled' = $true
|
||||
'AuditLogAgeLimit' = '180'
|
||||
'AuditAdmin' = @('Update','MoveToDeletedItems','SoftDelete','HardDelete','SendAs','SendOnBehalf','Create','UpdateFolderPermission')
|
||||
'AuditDelegate' = @('Update','SoftDelete','HardDelete','SendAs','Create','UpdateFolderPermissions','MoveToDeletedItems','SendOnBehalf')
|
||||
'AuditOwner' = @('UpdateFolderPermission','MailboxLogin','Create','SoftDelete','HardDelete','Update','MoveToDeletedItems')
|
||||
}
|
||||
|
||||
# Enable Auditing
|
||||
Get-Mailbox -ResultSize Unlimited | Where-Object {$_.RecipientTypeDetails -match '(User|Shared|Room|Discovery)Mailbox' -and $_.AuditEnabled -eq $false} | Set-Mailbox @params
|
||||
|
||||
# Check Auditing
|
||||
Get-Mailbox -ResultSize Unlimited | Where-Object {$_.RecipientTypeDetails -match '(User|Shared|Room|Discovery)Mailbox'} | Format-Table -AutoSize UserPrincipalName,RecipientTypeDetails,AuditEnabled,AuditLogAgeLimit
|
||||
|
||||
# End the Exchange Session
|
||||
Get-PSSession | Where-Object {$_.ComputerName -eq 'outlook.office365.com'} | Remove-PSSession
|
||||
@@ -0,0 +1,15 @@
|
||||
# Find mailboxes where UPN domain doesn't match email domain
|
||||
#
|
||||
|
||||
# Find and load the new ExO "module"
|
||||
$exoModulePath = (Get-ChildItem -Path $env:userprofile -Filter CreateExoPSSession.ps1 -Recurse -Force -ErrorAction SilentlyContinue).DirectoryName[-1]
|
||||
. "$exoModulePath\CreateExoPSSession.ps1"
|
||||
|
||||
# Establish a session to Exchange Online
|
||||
Connect-EXOPSSession
|
||||
|
||||
# Get list of mailboxes with a different mail domain to UPN domain
|
||||
Get-Mailbox -ResultSize Unlimited | Where-Object {$_.UserPrincipalName.Split('@')[1] -ne $_.PrimarySmtpAddress.Split('@')[1]} | Format-Table Name,UserPrincipalName,PrimarySmtpAddress,RecipientTypeDetails
|
||||
|
||||
# End the Exchange Session
|
||||
Get-PSSession | Where-Object {$_.ComputerName -eq 'outlook.office365.com'} | Remove-PSSession
|
||||
@@ -0,0 +1,40 @@
|
||||
# Find shared mailboxes on the basis of their email domain and lists of who has access to them
|
||||
#
|
||||
# Uses the new PowerShell "module" that support MFA.
|
||||
#
|
||||
|
||||
# Where to save the CSV files to
|
||||
$outputFile = 'C:\Temp\GroupDetails.csv'
|
||||
|
||||
# Wildcard for groups to find
|
||||
$searchWildcard = '*@example.domain'
|
||||
|
||||
# Find and load the new ExO "module"
|
||||
$exoModulePath = (Get-ChildItem -Path $env:userprofile -Filter CreateExoPSSession.ps1 -Recurse -Force -ErrorAction SilentlyContinue).DirectoryName[-1]
|
||||
. "$exoModulePath\CreateExoPSSession.ps1"
|
||||
|
||||
# Establish a session to Exchange Online
|
||||
Connect-EXOPSSession
|
||||
|
||||
# Get all the groups we're looking for
|
||||
$allGroups = Get-DistributionGroup | Where-Object {$_.PrimarySmtpAddress -like $searchWildcard}
|
||||
|
||||
# Initialise the hash table to store results in
|
||||
$groupDetails = @()
|
||||
|
||||
# Run through the groups getting the members and adding
|
||||
foreach ($group in $allGroups) {
|
||||
$groupMembers = (Get-DistributionGroupMember -Identity $group.Name).Alias -join '; '
|
||||
$groupDetails += [PSCustomObject]@{
|
||||
'GroupName' = $group.Name;
|
||||
'GroupEmail' = $group.PrimarySmtpAddress;
|
||||
'GroupType' = $group.GroupType;
|
||||
'GroupMembers' = $groupMembers
|
||||
}
|
||||
}
|
||||
|
||||
# Export results to CSV file
|
||||
$groupDetails | Export-Csv -Path $outputFile -NoTypeInformation
|
||||
|
||||
# End the Exchange Session
|
||||
Get-PSSession | Where-Object {$_.ComputerName -eq 'outlook.office365.com'} | Remove-PSSession
|
||||
@@ -0,0 +1,40 @@
|
||||
# Get the permissions and sendas rights for a list of mailboxes and output them to CSV
|
||||
#
|
||||
# Uses the new PowerShell "module" that support MFA.
|
||||
#
|
||||
|
||||
# Where to save the CSV files to
|
||||
$outputPath = 'C:\Temp\MailboxPermissions\'
|
||||
|
||||
# What mailboxes are we checking?
|
||||
$mailboxes = Get-Content -Path 'C:\Temp\Mailboxes.txt'
|
||||
|
||||
# Find and load the new ExO "module"
|
||||
$exoModulePath = (Get-ChildItem -Path $env:userprofile -Filter CreateExoPSSession.ps1 -Recurse -Force -ErrorAction SilentlyContinue).DirectoryName[-1]
|
||||
. "$exoModulePath\CreateExoPSSession.ps1"
|
||||
|
||||
# Establish a session to Exchange Online
|
||||
Connect-EXOPSSession
|
||||
|
||||
# Get all non-inherited mailbox permissions excluding self and output to a CSV file named for each mailbox
|
||||
foreach ($mailbox in $mailboxes) {
|
||||
Write-Output -InputObject ('Getting permissions for mailbox ' + $mailbox)
|
||||
$mailboxPermissions = Get-MailboxPermission -Identity $mailbox | Where-Object {$_.IsInherited -eq $false -and $_.User -ne 'NT AUTHORITY\SELF'} | Select-Object Identity,User,AccessRights,Deny
|
||||
if ($mailboxPermissions.Count -gt 0) {
|
||||
$outputFile = $outputPath + 'MailboxPermissions_' + ($mailbox -replace '@','_') + '.csv'
|
||||
$mailboxPermissions | Export-CSV -Path $outputFile -NoTypeInformation
|
||||
}
|
||||
}
|
||||
|
||||
# Get all non-inherited recipient permissions (sendas) excluding self and output to a CSV file named for each mailbox
|
||||
foreach ($mailbox in $mailboxes) {
|
||||
Write-Output -InputObject ('Getting permissions for recipient ' + $mailbox)
|
||||
$recipientPermissions = Get-RecipientPermission -Identity $mailbox | Where-Object {$_.IsInherited -eq $false -and $_.Trustee -ne 'NT AUTHORITY\SELF'} | Select-Object Identity,Trustee,AccessRights,AccessControlType
|
||||
if ($recipientPermissions.Count -gt 0) {
|
||||
$outputFile = $outputPath + 'RecipientPermissions_' + ($mailbox -replace '@','_') + '.csv'
|
||||
$recipientPermissions | Export-CSV -Path $outputFile -NoTypeInformation
|
||||
}
|
||||
}
|
||||
|
||||
# End the Exchange Session
|
||||
Get-PSSession | Where-Object {$_.ComputerName -eq 'outlook.office365.com'} | Remove-PSSession
|
||||
@@ -0,0 +1,32 @@
|
||||
# Find shared mailboxes on the basis of their email domain and lists of who has access to them
|
||||
#
|
||||
# Uses the new PowerShell "module" that support MFA.
|
||||
#
|
||||
|
||||
# Where to save the CSV files to
|
||||
$outputPath = 'C:\Temp\'
|
||||
|
||||
# Wildcard for mailboxes to find
|
||||
$searchWildcard = '*'
|
||||
|
||||
# Find and load the new ExO "module"
|
||||
$exoModulePath = (Get-ChildItem -Path $env:userprofile -Filter CreateExoPSSession.ps1 -Recurse -Force -ErrorAction SilentlyContinue).DirectoryName[-1]
|
||||
. "$exoModulePath\CreateExoPSSession.ps1"
|
||||
|
||||
# Establish a session to Exchange Online
|
||||
Connect-EXOPSSession
|
||||
|
||||
# Get all the mailboxes we're looking for
|
||||
$sharedMailboxes = Get-Mailbox -RecipientTypeDetails SharedMailbox -ResultSize Unlimited | Where-Object {$_.PrimarySmtpAddress -like $searchWildcard} | Select-Object Name,Alias,PrimarySmtpAddress,ProhibitSendQuota
|
||||
|
||||
# Export list of mailboxes to CSV File
|
||||
$sharedMailboxes | Export-CSV -Path ($outputPath + 'Shared Mailboxes.csv') -NoTypeInformation
|
||||
|
||||
# Get all non-inherited permissions excluding self and output to a CSV file named for each group
|
||||
foreach ($sharedMailbox in $sharedMailboxes) {
|
||||
$mailboxPermissions = Get-MailboxPermission -Identity $sharedMailbox.alias | Where-Object {$_.IsInherited -eq $false -and $_.User -ne 'NT AUTHORITY\SELF'} | Select-Object Identity,User,AccessRights,Deny
|
||||
$mailboxPermissions | Export-CSV -Path ($outputPath + $sharedMailbox.Name + '.csv') -NoTypeInformation
|
||||
}
|
||||
|
||||
# End the Exchange Session
|
||||
Get-PSSession | Where-Object {$_.ComputerName -eq 'outlook.office365.com'} | Remove-PSSession
|
||||
@@ -0,0 +1,27 @@
|
||||
# Exchange Online with MFA Support
|
||||
|
||||
## What is this?
|
||||
|
||||
Connecting to Exchange Online through a remote PowerShell session doesn't work when using multi factor authentication. You can (apparrently) get round that by creating an application password, but I've never got it to work and in my mind creating a password to bypass MFA somewhat defeates the point of enabling MFA in the first place.
|
||||
|
||||
There now is a new "module" available which does support MFA, so this folder is where I'll be putting new scripts that support MFA or old scripts as I update them.
|
||||
|
||||
## Pre-requisites
|
||||
|
||||
To connect using MFA you have to locally install a new module from Microsoft. Which for whatever reason isn't available from PSGallery, nor can it be simply downloaded. Instead it has to be installed from within the Exchange Online admin centre using one of those annoying ClickOnce installers that only work in MS's own web browsers.
|
||||
|
||||
Microsoft have a document explaining the unnecessarily convulted install process here:
|
||||
|
||||
[Connect to Exchange Online PowerShell using multi-factor authentication](https://docs.microsoft.com/en-us/powershell/exchange/exchange-online/connect-to-exchange-online-powershell/mfa-connect-to-exchange-online-powershell?view=exchange-ps)
|
||||
|
||||
In addition, because this will be using a remote session it will require the script execution policy within PowerShell to be changed to RemoteSigned. This is done either globally with:
|
||||
|
||||
`Set-ExecutionPolicy -ExecutionPolicy RemoteSigned`
|
||||
|
||||
Or for the current user with:
|
||||
|
||||
`Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser`
|
||||
|
||||
## Disclaimer
|
||||
|
||||
All scripts are provided as is without warranty of any kind, use them at your own risk.
|
||||
@@ -0,0 +1,32 @@
|
||||
# Reset default calendar permissions to availability for a list of users.
|
||||
#
|
||||
# Uses the new PowerShell "module" that support MFA.
|
||||
#
|
||||
|
||||
# File with list of users
|
||||
$userlistPath = 'C:\Temp\Userlist.txt'
|
||||
|
||||
# Find and load the new ExO "module"
|
||||
$exoModulePath = (Get-ChildItem -Path $env:userprofile -Filter CreateExoPSSession.ps1 -Recurse -Force -ErrorAction SilentlyContinue).DirectoryName[-1]
|
||||
. "$exoModulePath\CreateExoPSSession.ps1"
|
||||
|
||||
# Establish a session to Exchange Online
|
||||
Connect-EXOPSSession
|
||||
|
||||
# Get list of users
|
||||
$userlist = Get-Content -Path $userlistPath
|
||||
|
||||
# Get mailboxes for users in list
|
||||
$mailboxes = Get-Mailbox -ResultSize Unlimited | Where-Object {$_.Name -in $userlist} | Sort-Object -Property Name
|
||||
|
||||
# Check the mailboxes and reset any which have default permissions of None to AvailabilityOnly
|
||||
foreach ($mailbox in $mailboxes) {
|
||||
$calendarPath = $mailbox.UserPrincipalName + ':\Calendar'
|
||||
$defaultPermissions = Get-MailboxFolderPermission -Identity $calendarPath -User 'Default'
|
||||
if ($defaultPermissions.AccessRights -eq 'None') {
|
||||
Set-MailboxFolderPermission -Identity $calendarPath -User 'Default' -AccessRights AvailabilityOnly
|
||||
}
|
||||
}
|
||||
|
||||
# End the Exchange Session
|
||||
Get-PSSession | Where-Object {$_.ComputerName -eq 'outlook.office365.com'} | Remove-PSSession
|
||||
@@ -0,0 +1,28 @@
|
||||
# A simple script to enable forwarding for a list of users from a CSV file
|
||||
#
|
||||
# The script is expecting the CSV file to have two columns called SourceAddress and DestinationAddress
|
||||
#
|
||||
|
||||
# Get the list of users from a CSV file
|
||||
$userList = Import-Csv -Path 'C:\Temp\UserList.csv'
|
||||
|
||||
# Find and load the new ExO "module"
|
||||
$exoModulePath = (Get-ChildItem -Path $env:userprofile -Filter CreateExoPSSession.ps1 -Recurse -Force -ErrorAction SilentlyContinue).DirectoryName[-1]
|
||||
. "$exoModulePath\CreateExoPSSession.ps1"
|
||||
|
||||
# Establish a session to Exchange Online
|
||||
Connect-EXOPSSession
|
||||
|
||||
# Get all non-inherited permissions excluding self and output to a CSV file named for each group
|
||||
foreach ($user in $userList) {
|
||||
Write-Output -InputObject ('Forwarding ' + $user.SourceAddress + ' to ' + $user.DestinationAddress)
|
||||
Set-Mailbox -Identity $user.SourceAddress -ForwardingSmtpAddress $user.DestinationAddress
|
||||
}
|
||||
|
||||
# Pull back a list to check everything has worked correctly
|
||||
foreach ($user in $userList) {
|
||||
Get-Mailbox -Identity $user.SourceAddress | Select-Object UserPrincipalName,ForwardingSmtpAddress,DeliverToMailboxAndForward
|
||||
}
|
||||
|
||||
# End the Exchange Session
|
||||
Get-PSSession | Where-Object {$_.ComputerName -eq 'outlook.office365.com'} | Remove-PSSession
|
||||
@@ -0,0 +1,52 @@
|
||||
# Create and set up a room mailbox.
|
||||
#
|
||||
# Uses the new PowerShell "module" that support MFA.
|
||||
#
|
||||
|
||||
# New room name and alias
|
||||
$displayName = ''
|
||||
$mailboxAlias = ''
|
||||
|
||||
# How many people can the room take?
|
||||
$roomCapacity = ''
|
||||
|
||||
# Do you want meeting requests to be auto accepted?
|
||||
$requestAutoAccept = $true
|
||||
|
||||
# Do we want to add the room to a room list?
|
||||
$addToRoomList = $true
|
||||
|
||||
# What is the room list called? (Will be created if it doesn't exist)
|
||||
$roomList = ''
|
||||
|
||||
# Find and load the new ExO "module"
|
||||
$exoModulePath = (Get-ChildItem -Path $env:userprofile -Filter CreateExoPSSession.ps1 -Recurse -Force -ErrorAction SilentlyContinue).DirectoryName[-1]
|
||||
. "$exoModulePath\CreateExoPSSession.ps1"
|
||||
|
||||
# Establish a session to Exchange Online
|
||||
Connect-EXOPSSession
|
||||
|
||||
# Create the new room mailbox
|
||||
New-Mailbox -Room -Alias $mailboxAlias -Name $displayName -DisplayName $displayName -ResourceCapacity $roomCapacity
|
||||
|
||||
# Wait for the meeting room mailbox to process
|
||||
Start-Sleep -Seconds 30
|
||||
|
||||
# Set the mailbox calendar to auto accept meeting requests (assuming policies are met)
|
||||
if ($requestAutoAccept) {
|
||||
Set-CalendarProcessing $mailboxAlias -AutomateProcessing AutoAccept
|
||||
}
|
||||
|
||||
# If we're adding the room to a room list, then do that.
|
||||
if ($addToRoomList) {
|
||||
# If the room list doesn't exist, create it.
|
||||
if (!(Get-DistributionGroup -Identity $roomList -ErrorAction SilentlyContinue)) {
|
||||
New-DistributionGroup -Name $roomList -RoomList
|
||||
}
|
||||
|
||||
# Add the room to the list
|
||||
Add-DistributionGroupMember -Identity $roomList -Member $mailboxAlias
|
||||
}
|
||||
|
||||
# End the Exchange Session
|
||||
Get-PSSession | Where-Object {$_.ComputerName -eq 'outlook.office365.com'} | Remove-PSSession
|
||||
Reference in New Issue
Block a user