Created
May 1, 2021 13:58
-
-
Save abelmferreira/13d23fc9b45d9a24097d38e8a2adf95b to your computer and use it in GitHub Desktop.
Revisions
-
abelmferreira created this gist
May 1, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,52 @@ # Procura por pastas no Exchange Online e retorna o caminho completo (full path) e seu tamanho # # Uso: # exchange-GetMailboxFolder-FullPath.ps1 -Find Texto # # Instala automaticamente se não encontrado o módulo ExchangeOnlineManagement # Solicita credenciais para conectar ao Exchange Online se não conectado # Param ( [Parameter(Mandatory = $true)][string]$Find ) #Verifica se módulo exchangeonline esta instalado $modules = Get-Module | Select-Object -Property Name $hasmodule = (@($modules) -like '@{Name=ExchangeOnlineManagement*').Count -gt 0 If ($hasmodule -ne "True") { Write-Host "Módulo Exchange Online Management não localizado" -ForegroundColor Red Install-Module ExchangeOnlineManagement } else { Write-Host "Módulo Exchange Online Management localizado" -ForegroundColor Green } #Verifica se conectado e faz login no ExchangeOnline com suporte a MFA $getsessions = Get-PSSession | Select-Object -Property State, Name $isconnected = (@($getsessions) -like '@{State=Opened; Name=ExchangeOnlineInternalSession*').Count -gt 0 If ($isconnected -ne "True") { Write-Host "Não conectado ao Exchange Online" -ForegroundColor Red Connect-ExchangeOnline } else { Write-Host "Conectado ao Exchange Online" -ForegroundColor Green } #Lista de todas as pasta em variavel $allfolders = Get-MailboxFolder -Identity ":\" -Recurse $allfolders ` | Where FolderPath -Match $Find ` | Sort-Object -Descending FolderSize ` | Select Name, Identity, HasSubFolders, @{Name = "Size MB"; Expression = { [Math]::Ceiling($_.FolderSize / 1MB) } }, FolderPath ` | FT