127 lines
3.3 KiB
Markdown
127 lines
3.3 KiB
Markdown
# [Nível 3] Referência de Operações via PowerShell
|
|
|
|
**Contexto:** Este guia foca na administração do Exchange **sem interface gráfica**, essencial para o ambiente Windows Server Core (`172.16.150.150`).
|
|
**Pré-requisito:** Carregar o snap-in no CMD/PowerShell: `Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn`
|
|
|
|
---
|
|
|
|
## 1. Gestão de Destinatários
|
|
|
|
### Criar Nova Caixa de Correio (Usuário já existe no AD)
|
|
|
|
```powershell
|
|
Enable-Mailbox -Identity "dominio\usuario" -Database "NOME_DO_BANCO"
|
|
```
|
|
|
|
### Criar Usuário + Caixa (Tudo de uma vez)
|
|
|
|
```powershell
|
|
New-Mailbox -UserPrincipalName "fulano@itguys.com.br" -Alias "fulano" -Name "Fulano da Silva" -OrganizationalUnit "ITGUYS/Users" -Database "iT Guys" -Password (ConvertTo-SecureString -String 'Senha123' -AsPlainText -Force)
|
|
```
|
|
|
|
### Ajustar Cotas (Exceção)
|
|
|
|
```powershell
|
|
Set-Mailbox -Identity "fulano" -IssueWarningQuota 4.5GB -ProhibitSendQuota 4.75GB -ProhibitSendReceiveQuota 5GB -UseDatabaseQuotaDefaults $false
|
|
```
|
|
|
|
### Ver Tamanho da Caixa
|
|
|
|
```powershell
|
|
Get-MailboxStatistics -Identity "fulano" | Select DisplayName, TotalItemSize, ItemCount
|
|
```
|
|
|
|
---
|
|
|
|
## 2. Permissões e Delegação
|
|
|
|
### Dar Acesso Total (Full Access)
|
|
|
|
```powershell
|
|
Add-MailboxPermission -Identity "CaixaAlvo" -User "UsuarioQueAcessa" -AccessRights FullAccess -InheritanceType All
|
|
```
|
|
|
|
### Dar Permissão de Enviar Como (Send As)
|
|
|
|
_Nota: Este comando é de AD, não de Mailbox._
|
|
|
|
```powershell
|
|
Add-ADPermission -Identity "CaixaAlvo" -User "UsuarioQueAcessa" -ExtendedRights "Send-As"
|
|
```
|
|
|
|
---
|
|
|
|
## 3. Rastreamento e Troubleshooting (Message Trace)
|
|
|
|
O `Get-MessageTrackingLog` é mais poderoso que a busca do ECP.
|
|
|
|
### Rastrear e-mail específico (Remetente -> Destinatário)
|
|
|
|
Visualizar status, data e EventID (Deliver, Fail, Defer).
|
|
|
|
```powershell
|
|
Get-MessageTrackingLog -Start "12/20/2025 08:00" -Sender "remetente@externo.com" -Recipients "usuario@itguys.com.br" | Select Timestamp,EventId,Source,MessageSubject
|
|
```
|
|
|
|
### Ver por que falhou (Detalhe do erro)
|
|
|
|
Se o EventID for `FAIL`, adicione `RecipientsStatus` e `RecipientStatus` para ver o erro.
|
|
|
|
```powershell
|
|
... | Select Timestamp,EventId,Recipients,RecipientStatus
|
|
```
|
|
|
|
### Ver e-mails enviados por um usuário hoje
|
|
|
|
```powershell
|
|
Get-MessageTrackingLog -ResultSize Unlimited -Start (Get-Date).AddHours(-24) -Sender "usuario@itguys.com.br" -EventId SEND
|
|
```
|
|
|
|
---
|
|
|
|
## 4. Diagnóstico de Filas e Fluxo
|
|
|
|
### Ver Filas de Envio (Queues)
|
|
|
|
Se `MessageCount` estiver alto, há congestionamento.
|
|
|
|
```powershell
|
|
Get-Queue | Select Identity, DeliveryType, Status, MessageCount, LastError
|
|
```
|
|
|
|
### Ver mensagens presas em uma fila específica
|
|
|
|
```powershell
|
|
Get-Message -Queue "SRVCGDVIEXCH001\365" | Select Subject,FromAddress,Status
|
|
```
|
|
|
|
### Forçar nova tentativa de envio (Retry)
|
|
|
|
```powershell
|
|
Retry-Queue -Identity "SRVCGDVIEXCH001\365" -Resubmit $true
|
|
```
|
|
|
|
---
|
|
|
|
## 5. Manutenção e Saúde do Servidor
|
|
|
|
### Checar status dos Bancos de Dados
|
|
|
|
Verifica se estão Montados e Saudáveis.
|
|
|
|
```powershell
|
|
Get-MailboxDatabaseCopyStatus *
|
|
```
|
|
|
|
### Checar Serviços do Exchange
|
|
|
|
```powershell
|
|
Test-ServiceHealth
|
|
```
|
|
|
|
### Espaço em Disco (Via WMI/CIM - já que não tem Explorer)
|
|
|
|
```powershell
|
|
Get-CimInstance Win32_LogicalDisk | Select DeviceID, @{N='FreeGB';E={"{0:N2}" -f ($_.FreeSpace/1GB)}}, @{N='TotalGB';E={"{0:N2}" -f ($_.Size/1GB)}}
|
|
```
|