This file contains 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 characters
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory = $false)] | |
[int]$MaxRetries = 20, | |
[Parameter(Mandatory = $false)] | |
[string]$LogFilePath = "$PSScriptRoot\GetAllPFStatistics.log" | |
) | |
function WriteHostAndLog($message) { |
This file contains 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 characters
# Public folder hierarchy and statistics retrieval options | |
## Test scenario | |
# | |
# PF mailboxes in Exchange Online. | |
# | |
# ❯ Get-PublicFolder -Mailbox MB1 -ResidentFolders -Recurse -ResultSize Unlimited | Measure | Select Count | |
# | |
# Count | |
# ----- |
This file contains 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 characters
# Example: | |
# .\Get-MailboxPermissionsDetailed.ps1 -Alias bilong | ft SecurityIdentifier,AceQualifier,AccessMask,Rights | |
[CmdletBinding()] | |
param ( | |
[Parameter()] | |
[string] | |
$Alias | |
) |
This file contains 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 characters
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = "High")] | |
param ( | |
[Parameter(Mandatory)] | |
[string] | |
$Server, | |
[Parameter(Mandatory)] | |
[string] | |
$Mailbox, |
This file contains 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 characters
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory)] | |
[string] | |
$Server, | |
[Parameter(Mandatory)] | |
[string] | |
$To, |
This file contains 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 characters
function Get-ExchangeServices { | |
$services = @(Get-Service MSExchange* | Where-Object { $_.StartType -eq "Automatic" }) | |
$services += Get-Service HostControllerService | |
$services += Get-Service W3SVC | |
return $services | |
} | |
function Stop-ExchangeServices { | |
$servicesToStop = Get-ExchangeServices | |
foreach ($service in $servicesToStop) { |
This file contains 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 characters
# Useful for doing MCDB stuff in a lab | |
$action = New-ScheduledTaskAction -Execute "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -Argument '-Command "Get-PhysicalDisk | Set-PhysicalDisk -MediaType SSD"' | |
$trigger = New-ScheduledTaskTrigger -AtStartup | |
$principal = New-ScheduledTaskPrincipal -UserID "NT AUTHORITY\SYSTEM" -LogonType ServiceAccount -RunLevel Highest | |
Register-ScheduledTask -TaskName "Set Media Type" -Action $action -Trigger $trigger -Principal $principal |
This file contains 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 characters
[CmdletBinding()] | |
param ( | |
[Parameter()] | |
[string] | |
$Mailbox | |
) | |
$mb = Get-Mailbox $Mailbox | |
. $exscripts\ManagedStoreDiagnosticFunctions.ps1 | |
$mbTableResult = Get-StoreQuery -Database "$($mb.Database.ToString())" -Query "SELECT MailboxNumber FROM Mailbox WHERE MailboxGuid = '$($mb.ExchangeGuid.ToString())'" |
This file contains 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 characters
param( | |
[Parameter()] | |
[ValidateSet("NameUnknown", "NameFullyQualifiedDN", "NameSamCompatible", "NameDisplay", "NameUniqueId", "NameCanonical", "NameUserPrincipal", "NameCanonicalEx", "NameServicePrincipal", "NameDnsDomain")] | |
[string] | |
$ExtendedNameFormat = "NameSamCompatible") | |
$extendedNameFormats = @{ | |
"NameUnknown" = 0 | |
"NameFullyQualifiedDN" = 1 | |
"NameSamCompatible" = 2 |
This file contains 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 characters
#Requires -Modules Microsoft.Graph, Microsoft.Graph.Users.Actions | |
Connect-MgGraph -Scopes "User.Read.All", "Mail.ReadBasic", "Mail.Read", "Mail.ReadWrite" -DeviceAuth -ContextScope Process | |
$userId = (Invoke-MgGraphRequest -Uri "v1.0/me")["id"] | |
# Only returns 10 items by default | |
Get-MgUserMessage -UserId $userId | ft ReceivedDateTime,Subject | |
# You can filter for stuff older than a certain date | |
Get-MgUserMessage -UserId $userId -Filter "ReceivedDateTime lt 2023-01-25" | ft ReceivedDateTime,Subject |
NewerOlder