Powershell Command Guide for Exchange Server | GOLINE
Goline Logo

FAQ

News

  • In the supply and logistics sectors, email communication is pivotal. However, organizations face threats like email fraud and phishing. GOLINE SA's clients struggled with configuring email authentication protocols manually. To address this challenge, GOLINE SA became an MSP Partner of PowerDMARC, collaborating to streamline implementation and management. PowerDMARC's cloud-based platform automated DMARC, SPF, and DKIM protocols for GOLINE SA's clients. This streamlined the transition to DMARC enforcement policies, bolstering domain protection without compromising email deliverability. The intuitive platform facilitated easy navigation and provided detailed reporting for proactive issue resolution. GOLINE SA's clients experienced tangible benefits: Enhanced Email Security: Automated protocols...
  • Route RPKI validation April 1st, 2022
    RPKI is a security framework by which network owners can validate and secure the critical route updates or Border Gateway Protocol (BGP) announcements between public Internet networks. BGP is essentially the central nervous system of the Internet and one of its fundamental building blocks. The main function of BGP is to facilitate efficient routing between Autonomous Systems (AS), by building and maintaining the Internet routing table. The Internet routing table is effectively the navigation system of the Internet and without it, traffic would be unable to flow between its constituent networks. Unfortunately, routing equipment alone cannot distinguish between legitimate and malicious routing announcements,...
  • RIPE – Atlas Anchor February 17th, 2022
    We have become an even more integral part of the RIPE Atlas project by hosting an anchor, a device that allows for latency analysis of traffic between autonomous systems.https://atlas.ripe.net/probes/7073/RIPE Atlas anchors play an integral role in the RIPE Atlas network by acting both as enhanced RIPE Atlas probes with more measurement capacity, as well as regional measurement targets within the greater RIPE Atlas network. Anchors are able to perform many more measurements than a regular RIPE Atlas probe, and the large amount of data they collect is made available to everyone. In addition, anchors act as powerful targets that can...

Powershell Command Guide for Exchange Server

# Visualizza i dispositivi mobili registrati con Exchange
Get-MobileDeviceStatistics -Mailbox gami | ft DeviceType, DeviceUserAgent, LastSuccesSync

#Visualizza le impostazioni dei servizi IMAP4 e POP3
Get-PopSettings | format-list
Get-ImapSettings | format-list

#Imposta i parametri da mostrare agli utenti per collegarsi in IMAP4 e POP3
Set-PopSettings -ExternalConnectionSettings {exchange.domain.com:995:SSL}
Set-ImapSettings -ExternalConnectionSettings {exchange.domain.com:993:SSL}

#Abilita i connettori a mostrare le impostazioni agli utenti OWA
Get-ReceiveConnector "*Client Frontend*" | Set-ReceiveConnector -Fqdn exchange.domain.com -AdvertiseClientSettings $true
Get-ReceiveConnector | format-list

 # Debug ActiveSync di una specifica mailbox
Set-CASMailbox gami -ActiveSyncDebugLogging:$true
 
# Versione di Exchange Server
Get-ExchangeServer | Format-List Name,Edition,AdminDisplayVersion
 
#Retry Queue – Forza la coda in stato Retry
Retry-Queue -Filter {Status -eq "Retry"} -Server Exchange -Resubmit $true
 
#Aumenta il livello di debug ad alto (OAL Generator)
set-eventLogLevel "MSExchangeSAOAL Generator" -level high
 
#Crea una nuova Global Address List
New-GlobalAddressList -Name NewGAL
 
#Visualizza i Ruoli
Get-ManagementRoleAssignment Ruoli
 
#Esegue il management
Start-ManagedFolderAssistant -Identity
 
#Elimina GAL
Remove-GlobalAddressList -Identity "Fourth Coffee" -DomainController ad-server.fourthcoffee.com
 
#Visualizza gli utenti in un gruppo
Get-DistributionGroupMember -Identity "Buonvicini Stabio"
 
#Mostra Mailbox Disconnesse
Get-MailboxDatabase | Get-MailboxStatistics | Where { $_.DisconnectReason -eq "Disabled" } | ft DisplayName,Database,DisconnectDate
 
#Rimozione mapping altre mailbox sul proprio Outlook
Add-MailboxPermission -Identity paolo.vass -user superuser -AccessRights FullAccess -InheritanceType All -AutoMapping $false
 
#Visualizza i Mailbox id delle caselle disconnesse
Get-MailboxDatabase | Get-MailboxStatistics | where { $_.DisplayName -eq "<display name>" } | Format-List DisplayName,MailboxGuid,Database,DisconnectReason
Get-MailboxStatistics -Database "Archiving" | Where-Object {$_.DisconnectDate -Notlike $NULL} | FL DisplayName, DisconnectDate, MailboxGuid
Get-MailboxStatistics -Database "xxxxxxxxx" | Where { $_.DisconnectReason -eq "SoftDeleted" } | ft DisplayName,Database,DisconnectDate
 
# Aggiorna lo stato delle mailbox (Molto importante se l'account viene disabilitato, altrimenti non si visualizza)
Get-MailboxStatistics -Database "Mailbox Database 1825817324" | ForEach { Update-StoreMailboxState -Database $_.Database -Identity $_.MailboxGuid -Confirm:$false }
 
# Visualizza mailbox disabilitate/disconnesse
Get-MailboxStatistics -Database "Mailbox Database 1825817324" | Where-Object {$_.DisconnectDate -Notlike $NULL} | FL DisplayName, DisconnectDate, MailboxGuid
NOTA IMPORTANTE: eseguire prima Get-MailboxStatistics (comando sopra)
 
NOTA Info:
Se disabilito l'archiviazione a un utente, la mailbox archive del DB Archiving non scompare per 30 giorni e può essere semplicemente riabilitata.
 
#Per vedere lo stato dell'archiviazione
Get-Mailbox -Identity "SAAL" | Format-List *Archive* DisabledArchiveDatabase : Archiving
 
NOTA: È però possibile cancellarla manualmente.
 
#Visualizzare Identity
Get-MailboxStatistics -Database "Archiving" |  FL Identity, DisplayName
 
#Rimozione delle caselle disconnesse
Remove-Mailbox -Identity <Identity> -Permanent $true
Remove-Mailbox -Database "Archiving" -StoreMailboxIdentity 1a67e308-888e-4fa2-9842-f38e1842598a
 
NOTA: Attenzione: Se si sposta una mail box da un database all'altro la casella risulta in modalità SoftDeleted
 
#Rimuove le caselle che sono state spostate da una database all'altro (quandi nello stato SoftDeleted)
Remove-StoreMailbox -Database "Archiving" -Identity "6292eb0b-360f-4a64-ade3-18d70a72b181" -MailboxState SoftDeleted
 
NOTA: Attenzione, se una casella di posta o un archivio viene disattivato é necessario riavviare il mailserver o attendere il giorno
dopo per vederla nelle Disconneccted mailbox.
 
# Mostra tutti gli account con il numero di messaggi, il limite storage (warning) e Last logon Time (in ordine di oggetti)
Get-MailboxStatistics -Server EXCHANGE | Sort-Object TotalItemSize –Descending
 
#Mostra le informazioni per l'utente richiesto
Get-MailboxStatistics ellezeta
 
#Mostra le dimensioni delle caselle di email ed il numero degli oggetti ordinati in maniera decrescente
Get-MailboxDatabase "Mailbox Database 1825817324" | Get-MailboxStatistics | Sort totalitemsize -desc | ft displayname, totalitemsize, TotalDeletedItemSize, itemcount
 
#Mostra info dettagliate per il singolo user
Get-MailboxStatistics -identity ellezeta | fl
 
#Esporta le informazioni in un csv
Get-MailboxDatabase "Mailbox Database 1825817324" | Get-MailboxStatistics | Sort totalitemsize -desc | Export-CSV C:downloadsmailboxes.csv
 
#Testare i web services di Exchange
Test-OutlookWebServices -Identity:mami
 
#Cambiare permission alle public folder
Add-PublicFolderClientPermission -Identity "Trasporti" -AccessRights Owner -User "MAMI"
 
#Inviare un email con allegati
Send-MailMessage -From miro@domain.com -To miro@domain.com -Subject "Ciao" -Body "Messaggio" -SMTPServer EXCHANGE -Attachments C:mailboxSize.txt
 
#Eseguire un comando Exchange shell via cmd. Esempio
C:WindowsSystem32WindowsPowerShellv1.0powershell.exe -command ". 'F:ExchangebinRemoteExchange.ps1'; Connect-ExchangeServer -auto ; C:.StartReportToEmail.ps1 ;exit "
 
#Mostrare l'identità di una mailbox. E' possibile vedere se é disconnessa o meno guardando l'identità.
Get-MailboxStatistics MAMI |fl
Get-MailboxStatistics MAMI -Archive |fl
Get-Mailbox |FL *Archive*
get-mailbox BUPA | fl *archive*
 
#Connettere un archivio
Connect-Mailbox -Identity "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx" -Archive -User "Doe John" -Database "Archiviazione"
[PS] get-mailbox BUPA | fl *archive*
[PS] get-mailbox mami | fl *archive*
 
# Individua le mailbox disconnesse
Get-MailboxDatabase | Get-MailboxStatistics | Where { $_.DisconnectReason -ne $null } | fl DisplayName,MailboxGuid,Database,DisconnectReason
 
#Cancella in maniera permanente la mailbox disconessa (DB: Archiviazione)
Remove-StoreMailbox -Database Archiviazione -Identity "vedi ID da comando precedente"  -MailboxState Disabled
 
#Default policy di retention della posta cancellata
Get-Mailbox MAMI | FL RetainDeletedItemsFor
Set-Mailbox -Identity MAMI -RetainDeletedItemsFor 30
 
#Dimensione dei database mailbox
Get-MailboxDatabase -Status | select ServerName,Name,DatabaseSize
 
#Exchange: aumentare la quota delle regole della mailbox
set-mailbox -RulesQuota: 256KB MAMI
 
NOTA: Richiede il parametro identità della casella: GUID o email o alias
Valori da 32BK a 256KB
 
 
#Visualizzare la quota attuale
Get-Mailbox | ft DisplayName,RulesQuota
 
#Enable logging imap4 e pop3
Set-imapsettings -server EXCHANGE  –ProtocolLogEnabled $true
Set-popsettings -server EXCHANGE  –ProtocolLogEnabled $true
Get-ImapSettings -Server EXCHANGE | select *log*
Get-PopSettings -Server EXCHANGE  | select *log*
Set-ImapSettings -server EXCHANGE -ProtocolLogEnabled $true -LogFileLocation "F:TEMPimap4log"
 
#Avviare uno script Powershell per Exchange
C:WindowsSystem32WindowsPowerShellv1.0powershell.exe -command ". 'F:ExchangebinRemoteExchange.ps1'; Connect-ExchangeServer -auto ; C:Script.xxxxnomedelloscriptx.ps1"
 
#Script per cancellare email @contoso da contatti + Invio email e scrittura in file
Get-MailContact -ResultSize Unlimited | Select-Object Name, PrimarySMTPAddress, @{Name="EmailAddresses";Expression={$_.EmailAddresses -cmatch "smtp"}} | Where-Object {($_.PrimarySMTPAddress -like "*contoso.com*") -or ($_.EmailAddresses -like "*contoso.com*")} > C:GOLINEAddressFound.txt
Get-MailContact -ResultSize Unlimited -IgnoreDefaultScope | Select-Object Identity, Name, PrimarySMTPAddress, @{Name="EmailAddresses";Expression={$_.EmailAddresses -cmatch "smtp"}} | Where-Object {($_.PrimarySMTPAddress -like "*contoso.com*") -or ($_.EmailAddresses -like "*contoso.com*")} | foreach {$contact = $_;
$email = $contact.emailaddresses;
$email | foreach {if ($_.smtpaddress -like "*contoso.com") {$address = $_.smtpaddress;}
Set-Mailcontact $contact.identity -EmailAddressPolicyEnable $false
Set-Mailcontact $contact.identity -EmailAddresses @{Remove=$address};
}}
Send-MailMessage -From postmaster@domain.com -To nc@domain.com -SmtpServer exchange.domain.com -Attachments "C:GOLINEAddressFound.txt" -Subject "Rimozione default policy dai contatti esterni" -BodyAsHtml -Body "Nell'allegato i contatti trovati"
 
#Message log in Exchange
Get-MessageTrackingLog -ResultSize Unlimited -Start "10/20/2015 15:00PM" -End "10/20/2015 16:00PM" -Sender "john.doe@puntofresco.ch" -Recipient "pippo@ciccio.com"| Format-List Send*,Recipient*,MessageSubject*,EventId*,Reference*,TimeStamp > "C:Send Search.txt"
Tutti i parametri sono facoltativi
Get-MessageTrackingLog -ResultSize Unlimited -Sender "superellezeta@domain.com" -Recipient "it@domain.com"| Format-List Send*,Recipient*,MessageSubject*,EventId*,Reference*
Get-MessageTrackingLog -ResultSize Unlimited -Start "12/31/2017 09:30AM" -End "12/31/2017 09:31AM" -Object "Netwrix Auditor: Password Expiration Report – domain.local" -Sender "noc@domain.com" -Recipient "john.doe@domain.com"| Format-List Send*,Recipient*,MessageSubject*,EventId*,Reference*,TimeStamp,ClientIp,ClientHostname,OriginalClientIp
 
Get-MessageTrackingLog -ResultSize Unlimited -Start "12/31/2017 03:01AM" -End "12/31/2017 03:02AM"   -Sender "noc@domain.com" -Recipient "john.doe@domain.com" | where-object {$_.MessageSubject -like  "*Expiration*"} | Format-List Send*,Recipient*,MessageSubject*,EventId*,Reference*,TimeStamp,ClientIp,ClientHostname,OriginalClientIp
where-object {$_.MessageSubject -like  "*Expiration*"}
"Password Expiration Report"
 
#Room autoconfirmation
Set-CalendarProcessing "Sala riunioni grande – Oberdorfstrasse, 8 – Zürich" -AutomateProcessing AutoAccept
 
#Permetti di spedire esternamente se non autenticato (connettore hub partner per spedire esternamente)
NOTA: Selezionare hub, poi partner e anonimi, inserire lista indirizzi IP.
 
Get-ReceiveConnector "cPanel Relay Hub" | Add-ADPermission -User 'NT AUTHORITYAnonymous Logon' -ExtendedRights MS-Exch-SMTP-Accept-Any-Recipient
Get-DistributionGroup MigrazioneNavision   |  Format-List
Get-DistributionGroup MigrazioneNavision | fl AcceptMessagesOnlyFrom,AcceptMessagesOnlyFromDLMembers,RejectMessagesFrom,RejectMessagesFromDLMembers,RequireSenderAuthenticationEnabled
Get-ReceiveConnector "Default Frontend EXCHANGE" | Add-ADPermission -User "MYWIN_DOMAINmailservice" -ExtendedRights ms-Exch-SMTP-Submit
Get-ReceiveConnector "Client Proxy EXCHANGE" | Add-ADPermission -User "MYWIN_DOMAINmailservice" -ExtendedRights ms-Exch-SMTP-Submit
Remove-ADPermission "Default Frontend EXCHANGE" -User "MYWIN_DOMAINmailservice" -ExtendedRights ms-Exch-SMTP-Submit
Remove-ADPermission "Client Proxy EXCHANGEE" -User "MYWIN_DOMAINmailservice" -ExtendedRights ms-Exch-SMTP-Submit
 
#Visualizza le dimensioni dei DB di Exchange
Get-MailboxDatabase -Status | select ServerName,Name,DatabaseSize
 
[PS] C:Windowssystem32>Get-MailboxDatabase -Status | select ServerName,Name,DatabaseSize
 
#Visualizza il message-rate limit di Exchange prima di bloccare le sessioni
Get-receiveconnector | ft Name, messageratelimit
 
Get-receiveconnector -Identity "Client Proxy EXCHANGE" | Set-receiveconnector -messageratelimit unlimited
Get-receiveconnector -Identity "Client Frontend EXCHANGE" | Set-receiveconnector -messageratelimit unlimited
Get-receiveconnector -Identity "Client Proxy EXCHANGE" | Set-receiveconnector -messageratelimit 5
Get-receiveconnector -Identity "Client Frontend EXCHANGE" | Set-receiveconnector -messageratelimit 5
 
Get-receiveconnector -Identity "Client Proxy EXCHANGE" | Set-receiveconnector -messageratelimit 100
Get-receiveconnector -Identity "Client Frontend EXCHANGE" | Set-receiveconnector -messageratelimit 100
 
#Visualizza il tracking dei messaggi
Get-MessageTrackingLog -ResultSize Unlimited -Start "12/31/2017 09:30AM" -End "12/31/2017 09:30AM" -Sender "john.doe@puntofresco.ch" -Recipient "pippo@ciccio.com"| Format-List Send*,Recipient*,MessageSubject*,EventId*,Reference*,TimeStamp
Get-MessageTrackingLog -ResultSize Unlimited -Start "12/31/2017 03:00AM" -End "12/31/2017 03:01AM" -Sender "noc@domain.com" -Recipient "john.doe@domain.com"| Format-List Send*,Recipient*,MessageSubject*,EventId*,Reference*,TimeStamp,ClientIp,ClientHostname,OriginalClientIp
Get-MessageTrackingLog Completo >
Get-MessageTrackingLog -ResultSize Unlimited -Start "10/24/2018 05:00PM" -End "10/24/2018 07:00PM" -Sender "paolo.cappa@domain.com" -Recipient "norbert.nico@docuware.com"| Format-List RunspaceId,Timestamp,ClientIp,ClientHostname,ServerIp,ServerHostname,SourceContext,ConnectorId,Source,EventId,InternalMessageId,MessageId,Recipients,RecipientStatus,TotalBytes,RecipientCount,RelatedRecipientAddress,Reference,MessageSubject,Sender,ReturnPath,Directionality,TenantId,OriginalClientIp,MessageInfo,MessageLatency,MessageLatencyType,EventData
 
# Elimina Public Folder con sottocartelle
Remove-PublicFolder -Identity "GOLINE – IT Ordini " -Recurse:$True
 
# Aggiungi la possibilità di creare elementi in un public folder (anonymous missing)
Add-PublicFolderClientPermission "Coop – Ordini FAX" -AccessRights CreateItems -User Anonymous
 
# Visualizzare tutti gli ID delle cartelle e buttarle in un file. Poi cercare manualmente con un CTRL+F.
C:Windowssystem32>Get-MailboxStatistics -Database "Mailbox Database 1825817324" |  FL Identity, DisplayName > c:aaa.txt
 
# Cancellare la  mailbox
Remove-Mailbox -Database "Mailbox Database 1825817324" -StoreMailboxIdentity 9ddfbd8b-6903-46e3-a520-0f7ae4081ab4
 
#Update GAL
Update-GlobalAddressList -Identity "Default Global Address List"
 
#Send AS
Get-DistributionGroup "Boat Company Info" | Add-ADPermission -User "Solaris Reception" -ExtendedRights "Send As"
Set-DistributionGroup -Identity "Boat Company – Info" -GrantSendOnBehalfTo "Solaris Reception"
Remove-Mailbox -Identity <Identity> -Permanent $true
Remove-Mailbox -Database "Archiving" -StoreMailboxIdentity 1a67e308-888e-4fa2-9842-f38e1842598a
 
NOTA: Attenzione: Se si sposta una mail box da un database all'altro la casella risulta in modalità SoftDeleted
 
#Rimuove le caselle che sono state spostate da una database all'altro (quandi nello stato SoftDeleted)
Remove-StoreMailbox -Database "Archiving" -Identity "6292eb0b-360f-4a64-ade3-18d70a72b181" -MailboxState SoftDeleted
 
NOTA: Attenzione, se una casella di posta o un archivio viene disattivato é necessario riavviare il mailserver o attendere il giorno
dopo per vederla nelle Disconneccted mailbox.
 
# Mostra tutti gli account con il numero di messaggi, il limite storage (warning) e Last logon Time (in ordine di oggetti)
Get-MailboxStatistics -Server EXCHANGE | Sort-Object TotalItemSize –Descending
 
#Mostra le informazioni per l'utente richiesto
Get-MailboxStatistics ellezeta
 
#Mostra le dimensioni delle caselle di email ed il numero degli oggetti ordinati in maniera decrescente
Get-MailboxDatabase "Mailbox Database 1825817324" | Get-MailboxStatistics | Sort totalitemsize -desc | ft displayname, totalitemsize, TotalDeletedItemSize, itemcount
 
#Mostra info dettagliate per il singolo user
Get-MailboxStatistics -identity ellezeta | fl
 
#Esporta le informazioni in un csv
Get-MailboxDatabase "Mailbox Database 1825817324" | Get-MailboxStatistics | Sort totalitemsize -desc | Export-CSV C:downloadsmailboxes.csv
 
#Testare i web services di Exchange
Test-OutlookWebServices -Identity:mami
 
#Cambiare permission alle public folder
Add-PublicFolderClientPermission -Identity "Trasporti" -AccessRights Owner -User "MAMI"
 
#Inviare un email con allegati
Send-MailMessage -From miro@domain.com -To miro@domain.com -Subject "Ciao" -Body "Messaggio" -SMTPServer EXCHANGE -Attachments C:mailboxSize.txt
 
#Eseguire un comando Exchange shell via cmd. Esempio
C:WindowsSystem32WindowsPowerShellv1.0powershell.exe -command ". 'F:ExchangebinRemoteExchange.ps1'; Connect-ExchangeServer -auto ; C:.StartReportToEmail.ps1 ;exit "
 
#Mostrare l'identità di una mailbox. E' possibile vedere se é disconnessa o meno guardando l'identità.
Get-MailboxStatistics MAMI |fl
Get-MailboxStatistics MAMI -Archive |fl
Get-Mailbox |FL *Archive*
get-mailbox BUPA | fl *archive*
 
#Connettere un archivio
Connect-Mailbox -Identity "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx" -Archive -User "Buones Hover" -Database "Archiviazione"
[PS] get-mailbox BUPA | fl *archive*
 
[PS] get-mailbox mami | fl *archive*
 
 
# Individua le mailbox disconnesse 
Get-MailboxDatabase | Get-MailboxStatistics | Where { $_.DisconnectReason -ne $null } | fl DisplayName,MailboxGuid,Database,DisconnectReason
 
#Cancella in maniera permanente la mailbox disconessa (DB: Archiviazione)
Remove-StoreMailbox -Database Archiviazione -Identity "vedi ID da comando precedente"  -MailboxState Disabled
 
#Default policy di retention della posta cancellata
Get-Mailbox MAMI | FL RetainDeletedItemsFor
Set-Mailbox -Identity MAMI -RetainDeletedItemsFor 30
 
#Dimensione dei database mailbox
Get-MailboxDatabase -Status | select ServerName,Name,DatabaseSize
 
#Exchange: aumentare la quota delle regole della mailbox
set-mailbox -RulesQuota: 256KB MAMI
 
NOTA: Richiede il parametro identità della casella: GUID o email o alias
Valori da 32BK a 256KB
 
 
#Visualizzare la quota attuale
Get-Mailbox | ft DisplayName,RulesQuota
 
#Enable logging imap4 e pop3
 
Set-imapsettings -server EXCHANGE  –ProtocolLogEnabled $true
Set-popsettings -server EXCHANGE  –ProtocolLogEnabled $true
Get-ImapSettings -Server EXCHANGE | select *log*
Get-PopSettings -Server EXCHANGE  | select *log*
Set-ImapSettings -server EXCHANGE -ProtocolLogEnabled $true -LogFileLocation "F:TEMPimap4log"
 
#Avviare uno script Powershell per Exchange
C:WindowsSystem32WindowsPowerShellv1.0powershell.exe -command ". 'F:ExchangebinRemoteExchange.ps1'; Connect-ExchangeServer -auto ; C:Script.xxxxnomedelloscriptx.ps1"
 
#Script per cancellare email @contoso da contatti + Invio email e scrittura in file
Get-MailContact -ResultSize Unlimited | Select-Object Name, PrimarySMTPAddress, @{Name="EmailAddresses";Expression={$_.EmailAddresses -cmatch "smtp"}} | Where-Object {($_.PrimarySMTPAddress -like "*contoso.com*") -or ($_.EmailAddresses -like "*contoso.com*")} > C:GOLINEAddressFound.txt
Get-MailContact -ResultSize Unlimited -IgnoreDefaultScope | Select-Object Identity, Name, PrimarySMTPAddress, @{Name="EmailAddresses";Expression={$_.EmailAddresses -cmatch "smtp"}} | Where-Object {($_.PrimarySMTPAddress -like "*contoso.com*") -or ($_.EmailAddresses -like "*contoso.com*")} | foreach {$contact = $_;
$email = $contact.emailaddresses;
$email | foreach {if ($_.smtpaddress -like "*contoso.com") {$address = $_.smtpaddress;}
Set-Mailcontact $contact.identity -EmailAddressPolicyEnable $false
Set-Mailcontact $contact.identity -EmailAddresses @{Remove=$address};
}}
Send-MailMessage -From postmaster@domain.com -To nc@domain.com -SmtpServer exchange.domain.com -Attachments "C:GOLINEAddressFound.txt" -Subject "Rimozione default policy dai contatti esterni" -BodyAsHtml -Body "Nell'allegato i contatti trovati"
 
#Message log in Exchange
Get-MessageTrackingLog -ResultSize Unlimited -Start "10/20/2015 15:00PM" -End "10/20/2015 16:00PM" -Sender "john.doe@puntofresco.ch" -Recipient "pippo@ciccio.com"| Format-List Send*,Recipient*,MessageSubject*,EventId*,Reference*,TimeStamp > "C:Send Search.txt"
 
Tutti i parametri sono facoltativi
 
Get-MessageTrackingLog -ResultSize Unlimited -Sender "superellezeta@domain.com" -Recipient "it@domain.com"| Format-List Send*,Recipient*,MessageSubject*,EventId*,Reference*
Get-MessageTrackingLog -ResultSize Unlimited -Start "12/31/2017 09:30AM" -End "12/31/2017 09:31AM" -Object "Netwrix Auditor: Password Expiration Report – domain.local" -Sender "noc@domain.com" -Recipient "john.doe@domain.com"| Format-List Send*,Recipient*,MessageSubject*,EventId*,Reference*,TimeStamp,ClientIp,ClientHostname,OriginalClientIp
 
Get-MessageTrackingLog -ResultSize Unlimited -Start "12/31/2017 03:01AM" -End "12/31/2017 03:02AM"   -Sender "noc@domain.com" -Recipient "john.doe@domain.com" | where-object {$_.MessageSubject -like  "*Expiration*"} | Format-List Send*,Recipient*,MessageSubject*,EventId*,Reference*,TimeStamp,ClientIp,ClientHostname,OriginalClientIp
where-object {$_.MessageSubject -like  "*Expiration*"}
"Password Expiration Report"
 
#Room autoconfirmation
Set-CalendarProcessing "Sala riunioni grande – Oberdorfstrasse, 8 – Zürich" -AutomateProcessing AutoAccept
 
#Permetti di spedire esternamente se non autenticato (connettore hub partner per spedire esternamente)
NOTA: Selezionare hub, poi partner e anonimi, inserire lista indirizzi IP.
 
Get-ReceiveConnector "cPanel Relay Hub" | Add-ADPermission -User 'NT AUTHORITYAnonymous Logon' -ExtendedRights MS-Exch-SMTP-Accept-Any-Recipient
Get-DistributionGroup MigrazioneNavision   |  Format-List
Get-DistributionGroup MigrazioneNavision | fl AcceptMessagesOnlyFrom,AcceptMessagesOnlyFromDLMembers,RejectMessagesFrom,RejectMessagesFromDLMembers,RequireSenderAuthenticationEnabled
Get-ReceiveConnector "Default Frontend EXCHANGE" | Add-ADPermission -User "MYWIN_DOMAINmailservice" -ExtendedRights ms-Exch-SMTP-Submit
Get-ReceiveConnector "Client Proxy EXCHANGE" | Add-ADPermission -User "MYWIN_DOMAINmailservice" -ExtendedRights ms-Exch-SMTP-Submit
Remove-ADPermission "Default Frontend EXCHANGE" -User "MYWIN_DOMAINmailservice" -ExtendedRights ms-Exch-SMTP-Submit
Remove-ADPermission "Client Proxy EXCHANGEE" -User "MYWIN_DOMAINmailservice" -ExtendedRights ms-Exch-SMTP-Submit
 
#Visualizza le dimensioni dei DB di Exchange
Get-MailboxDatabase -Status | select ServerName,Name,DatabaseSize
[PS] C:Windowssystem32>Get-MailboxDatabase -Status | select ServerName,Name,DatabaseSize
 
 #Visualizza il message-rate limit di Exchange prima di bloccare le sessioni
Get-receiveconnector | ft Name, messageratelimit
 Get-receiveconnector -Identity "Client Proxy EXCHANGE" | Set-receiveconnector -messageratelimit unlimited
Get-receiveconnector -Identity "Client Frontend EXCHANGE" | Set-receiveconnector -messageratelimit unlimited
Get-receiveconnector -Identity "Client Proxy EXCHANGE" | Set-receiveconnector -messageratelimit 5
Get-receiveconnector -Identity "Client Frontend EXCHANGE" | Set-receiveconnector -messageratelimit 5
 Get-receiveconnector -Identity "Client Proxy EXCHANGE" | Set-receiveconnector -messageratelimit 100
Get-receiveconnector -Identity "Client Frontend EXCHANGE" | Set-receiveconnector -messageratelimit 100
 
#Visualizza il tracking dei messaggi
 Get-MessageTrackingLog -ResultSize Unlimited -Start "12/31/2017 09:30AM" -End "12/31/2017 09:30AM" -Sender "john.doe@puntofresco.ch" -Recipient "pippo@ciccio.com"| Format-List Send*,Recipient*,MessageSubject*,EventId*,Reference*,TimeStamp
Get-MessageTrackingLog -ResultSize Unlimited -Start "12/31/2017 03:00AM" -End "12/31/2017 03:01AM" -Sender "noc@domain.com" -Recipient "john.doe@domain.com"| Format-List Send*,Recipient*,MessageSubject*,EventId*,Reference*,TimeStamp,ClientIp,ClientHostname,OriginalClientIp
Get-MessageTrackingLog Completo >
Get-MessageTrackingLog -ResultSize Unlimited -Start "10/24/2018 05:00PM" -End "10/24/2018 07:00PM" -Sender "john.doe@domain.com" -Recipient "norbert.nicolin@docuware.com"| Format-List RunspaceId,Timestamp,ClientIp,ClientHostname,ServerIp,ServerHostname,SourceContext,ConnectorId,Source,EventId,InternalMessageId,MessageId,Recipients,RecipientStatus,TotalBytes,RecipientCount,RelatedRecipientAddress,Reference,MessageSubject,Sender,ReturnPath,Directionality,TenantId,OriginalClientIp,MessageInfo,MessageLatency,MessageLatencyType,EventData
 
# Elimina Public Folder con sottocartelle
Remove-PublicFolder -Identity "GOLINE – IT Ordini " -Recurse:$True
 
# Aggiungi la possibilità di creare elementi in un public folder (anonymous missing)
Add-PublicFolderClientPermission "Coop – Ordini FAX" -AccessRights CreateItems -User Anonymous
 
# Visualizzare tutti gli ID delle cartelle e buttarle in un file. Poi cercare manualmente con un CTRL+F.
C:Windowssystem32>Get-MailboxStatistics -Database "Mailbox Database 1825817324" |  FL Identity, DisplayName > c:aaa.txt
 
# Cancellare la  mailbox
Remove-Mailbox -Database "Mailbox Database 1825817324" -StoreMailboxIdentity 9ddfbd8b-6903-46e3-a520-0f7ae4081ab4
 
#Update GAL
Update-GlobalAddressList -Identity "Default Global Address List"
 
#Send AS
Get-DistributionGroup "Boat Company Info" | Add-ADPermission -User "Solaris Reception" -ExtendedRights "Send As"
Set-DistributionGroup -Identity "Boat Company – Info" -GrantSendOnBehalfTo "Solaris Reception"
 
Comandi utili per migrazione Exchange

#Creare un nuovo Database
New-MailboxDatabase -Name "Mailbox Database" -Server EXCHANGE19 -EdbFilePath "E:Mailbox DatabaseMailbox Database.edb" -LogFolderPath "E:Mailbox DatabaseLog"

#Cambiare nome al database Mailbox
Set-MailboxDatabase "Mailbox Database XXXXXX" -Name "Mailbox DB EXCHANGE 2019"

#Spostare un database:
Move-DatabasePath "Mailbox DB EXCHANGE 2019" -EdbFilePath "E:Mailbox DBMailbox DB EXCHANGE 2019.edb" -LogFolderPath "E:Mailbox DB"
Move-DatabasePath "Public Folders DB EXCHANGE 2019" -EdbFilePath "E:Public Folders DBPublic Folders DB EXCHANGE 2019.edb" -LogFolderPath "E:Public Folder DB"

#Spostamento Mailbox utente
New-MoveRequest -Identity "SAGI" -TargetDatabase "Mailbox Database 2019" -BatchName "Migration" -Priority Highest

#Spostamento Public Folder
Visualizzare il nome: Get-Mailbox -Server EXCHANGE -PublicFolder
New-MoveRequest PublicFolderMailbox1 -TargetDatabase "Public Folders Database 2019"

#Mostra lo stato dello spostamento
Get-MoveRequest | Get-MoveRequestStatistics

#Rimuove tutte le MoveRequest
Get-MoveRequest -movestatus completed | remove-moverequest

#Cancella singole move request
Remove-MoveRequest -Identity "ellezeta"

#Mostra cartelle disconnesse
Get-MailboxDatabase | Get-MailboxStatistics | Where { $_.DisconnectReason -ne $null } | fl DisplayName,MailboxGuid,Database,DisconnectReason

#Cancella le cartelle disconnesse
Get-MailboxStatistics -Database "Mailbox Database 1825817324" | where {$_.DisconnectReason -eq "SoftDeleted"} | ForEach {Remove-StoreMailbox -Database $_.Database -Identity $_.DisplayName -MailboxState SoftDeleted}
#Singolarmente
Remove-StoreMailbox -Database "Public Folders" -Identity "Public Folder Mailbox 1" -MailboxState SoftDeleted

#Impostare Autodiscovery
Get-ClientAccessService |fl identity,autodiscoverserviceinternaluri
Set-ClientAccessService -Identity EXCHANGE2019 -AutodiscoverServiceInternalUri https://exchange.domain.com/Autodiscover/Autodiscover.xml

#Verificare accessi cartelle e dare autorizzazioni con il seguente comando
Get-Mailbox -ResultSize unlimited -Filter {(RecipientTypeDetails -eq 'UserMailbox') -and (Alias -ne 'Admin')} | Add-MailboxPermission -User Super.Service@domain.com -AccessRights fullaccess -InheritanceType all

#Aggiungere permesso di spedizione e mapping cartella altro utente
NOTA: Non usare la GUI di ECP Exchange

Da PowerShell di Exchange eseguire i due comandi PS:

Add-ADPermission -Identity "Restaurant Da Mario" -User "john.doe@gasometer.local" -AccessRights ExtendedRight -ExtendedRights "Send As"
Add-MailboxPermission -Identity "Restaurant Da Mario" -User "john.doe@gasometer.local" -AccessRights FullAccess -InheritanceType All

BUG: Si verifica un errore di spedizione quando si è in modalità cache e viene scaricata la OAB.
Per risolvere questo problema togliere la modalità cache se non è un computer portatile oppure nella spedizione cancellare l'indirizzo DA e ricercarlo nella rubrica.

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x