[EXO][PS] Audit Log Search for Sign Mailbox
Audit Log Search
Audit Log Search
Quickly check if a user or subset of users are part of a ad group that has more than 5000 members.
1 2 3 4 5 |
$adgroup = “[group]” $groupdn = (get-adgroup $adgroup).distinguishedname $members = dsget group $grouppn -members $total = foreach ($i in $members){$u = $i.trim('"'); get-aduser $u | select userprincipalname} $total -like "*[unique string]*" |
Quickly find out all the Distribution Groups a user is a member of with a few lines of simple PS code.
1 2 3 |
$Username = "johnsmith@hiepic.com" $DistributionGroups = Get-DistributionGroup -ResultSize unlimited | where { (Get-DistributionGroupMember -ResultSize unlimited $_.Name | foreach {$_.PrimarySmtpAddress}) -contains "$Username"} $DistributionGroups |
Summary: This article documents the what’s, why’s and the how’s of setting up Room Finder and Workspaces in a hybrid Office 365 Exchange Environment. The on-premise environment uses ADC with no write-back enabled. Buildings, Cities, Types, and Filters (Capacity, Floors, Features) A room list is a distribution group. A room list is a collection of room mailboxes. →
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
$Mailbox = @{ ResultSize = “Unlimited” } $Filter = @{ FilterScript = {$_.PrefixString -ceq “smtp”} } $Select = @{ Property = @{Name=”First Name”;Expression={$_.DisplayName.Split(“,”)[1].Trim()}}, @{Name=”Last Name”;Expression={$_.DisplayName.Split(“,”)[0].Trim()}}, “DisplayName”, “ServerName”, “PrimarySmtpAddress”, @{Name=”EmailAddresses”;Expression={$_.EmailAddresses | Where-Object @Filter}} } Get-Mailbox @Mailbox | Select-Object @Select #Split all SMTP using comma (Get-Mailbox -ResultSize Unlimited |Select-Object DisplayName,ServerName,PrimarySmtpAddress, @{Name=“EmailAddresses”;Expression={$_.EmailAddresses |Where-Object {$_.PrefixString -ceq “smtp”} | ForEach-Object {$_.SmtpAddress}}}) |Select-Object DisplayName,ServerName,PrimarySmtpAddress, @{Name=“EmailAddresses”;Expression={$_.EmailAddresses.Split() -join(“,”)}} |Export-Csv C:\scripts\temp\addresses2.csv -NoTypeInformation Get-Mailbox -ResultSize Unlimited |Select Name, PrimarySMTPAddress, @{Name=’EmailAddresses’;Expression={[string]::join(“;”, ($_.EmailAddresses -cmatch ‘smtp’))}} Get-Mailbox -ResultSize Unlimited | Select-Object DisplayName,PrimarySmtpAddress, @{Name="EmailAddresses";Expression={$_.EmailAddresses | Where-Object {$_.PrefixString -ceq "smtp"} | ForEach-Object {$_.SmtpAddress}}} | Sort-Object DisplayName | Export-CSV "\\sf3\user1\shared\share\e\all_SMTP_Addresses.csv" -NoTypeInformation |
$errors = (Get-MsolContact –ObjectID <Object_ID>).Errors $errors | foreach-object {“nService: ” + $_.ErrorDetail.Name.split(“/”)[0]; “Error Message: “+ $_.ErrorDetail.ObjectErrors.ErrorRecord.ErrorDescription} $errors = (Get-MsolGroup –ObjectID <Object_ID>).Errors $errors | foreach-object {“nService: ” + $_.ErrorDetail.Name.split(“/”)[0]; “Error Message: “+ $_.ErrorDetail.ObjectErrors.ErrorRecord.ErrorDescription} $errors = (Get-MsolUser -UserPrincipalName “<User_ID>”).Errors $errors | foreach-object {“`nService: ” + $_.ErrorDetail.Name.split(“/”)[0]; “Error Message: ” + $_.ErrorDetail.ObjectErrors.ErrorRecord.ErrorDescription} Get-MsolUser -HasErrorsOnly -All | ft DisplayName,UserPrincipalName,@{Name=”Error”;Expression={($_.errors[0].ErrorDetail.objecterrors.errorrecord.ErrorDescription)}} →
Ensure you have a user mailbox backup prior to starting the following process as there is potential risk of data loss. Options are to have a third party solution to perform a mailbox backup or export to PST (see new-mailboxexport cmdlet). Capture relevant information from on-premise exchange and exchange online. Grab the mailbox information (primary →
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
#Load Exchange 2010 Module Add-PSSnapin Microsoft.Exchange.Management.Powershell.E2010 -ErrorAction SilentlyContinue #Setup Variables $Filename = "C:\temp\tasks\fowarding_address\export.csv" $header = "UPN,ForwardingSmtpAddress,DeliverToMailboxAndForward" $header | Out-File $Filename #Grab Data $Users = Get-Mailbox -ResultSize Unlimited -Filter { (ForwardingAddress -ne $null) -or (ForwardingSmtpAddress -ne $null) } ForEach ($User in $Users) { if ($user.ForwardingSmtpAddress -ne $null) { $forwardingSmtpAddress = $user.ForwardingSmtpAddress $DeliverToMailboxAndForward = $User.DeliverToMailboxAndForward.ToString() $logstring = "$($user.PrimarySmtpAddress),$($forwardingSmtpAddress),$($DeliverToMailboxAndForward)" $logstring | Out-File $Filename -Append } else { if ($user.ForwardingAddress -ne $null) { $forwardingContact = $user.ForwardingAddress $forwardingContactAddress = (Get-Recipient $forwardingContact).PrimarySmtpAddress $DeliverToMailboxAndForward = $User.DeliverToMailboxAndForward.ToString() $logString = "$($user.PrimarySmtpAddress),$($forwardingContactAddress),$($DeliverToMailboxAndForward)" $logString | Out-File $Filename -Append } } } #Remove Exchange 2010 Module Remove-PSSnapin Microsoft.Exchange.Management.Powershell.E2010 #Connect to Exchange Online $username = "<user name>" $targetdir = (dir $env:LOCALAPPDATA”\Apps\2.0\” -Include CreateExoPSSession.ps1,Microsoft.Exchange.Management.ExoPowershellModule.dll -Recurse | Group Directory | ? {$_.Count -eq 2}).Values | sort LastWriteTime -Descending | select -First 1 | select -ExpandProperty FullName import-Module $targetdir\CreateExoPSSession.ps1 $PasswordFile = "Password.txt" $KeyFile = "AES.key" $key = Get-Content $KeyFile $MyCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $username, (Get-Content $PasswordFile | ConvertTo-SecureString -Key $key) connect-exopssession -credential $MyCredential #Reapply forwarding to migrated EXO mailboxes $Users = Import-Csv $Filename ForEach ($user in $users) { $DeliverToMailboxAndForward = [System.Convert]::ToBoolean($User.DeliverToMailboxAndForward) Set-Mailbox -Identity $($user.UPN) -DeliverToMailboxAndForward $DeliverTomailboxAndForward -ForwardingSmtpAddress $($user.ForwardingSmtpAddress) -whatif } #Kill Session and Remove Module Get-PSSession | Remove-PSSession Get-Module | Remove-Module |
Add member of a role group which has the Mailbox Import Export role
1 |
New-ManagementRoleAssignment -Role "Mailbox Import Export" -User "<user name or alias>" |
Export primary mailbox:
1 |
New-MailboxExportRequest -Mailbox <user> -FilePath \\<server FQDN>\<shared folder name>\<PST name>.pst |
Export archive mailbox:
1 |
New-MailboxExportRequest -Mailbox <user> -FilePath \\<server FQDN>\<shared folder name>\<PST name>.pst -isarchive |
More details https://docs.microsoft.com/en-us/powershell/module/exchange/mailboxes/New-MailboxExportRequest?redirectedfrom=MSDN&view=exchange-ps
.Synopsis E-mail Counting Script v1 by ELAU 10/10/19 – Script counts emails received for each day of the current month .DESCRIPTION – Script pulls days of the month and counts number of emails received for each day of the current month or days specified into a HTML report. – Script allows option to e-mail report →
Recent Comments