Get-Mailbox <mail address or alias> | select-object WhenCreatedUTC, Name
Tag: PowerShell
Get IPv4 DHCP Reservations in a CSV file
Copy code below and save as Get-DHCPReservations.ps1
Get-DHCPServerV4Scope | ForEach {Get-DHCPServerv4Lease -ScopeID $_.ScopeID | where {$_.AddressState -like ‘*Reservation’} | Select-Object ScopeId,IPAddress,HostName,ClientID,AddressState | Export-Csv “C:\temp\DHCPReservations.csv” -NoTypeInformation
Mailbox Rules
Get rules list
Get-InboxRule -Mailbox <mailbox name or alias>
Get detail on each rule
Get-InboxRule -Mailbox <mailbox name or alias> -Identity “<rule name>” | Select -Property *
Disable Rule
Disable-Inboxrule -identity “<Rule name>” -mailbox <mailbox name or alias>
Remove Rule
Remove-Inboxrule -identity <Rule Name> -mailbox <mailbox name or alias>
Purge Mailbox Deleted Items Folder
Get current Settings
Get-Mailbox service@contoso.de | Format-List SingleItemRecoveryEnabled,RetainDeletedItemsFor
or use
Get-mailbox service@contoso.de | fl *retention*,*retain*
Set New Settings
Set-Mailbox -Identity service@contoso.de -SingleItemRecoveryEnabled $false -RetainDeletedItemsFor 1
#Purges folder deletes after 1 day
Delete Items in Dumpster
Search-mailbox -identity service@contoso.de -SearchDumpsterOnly -DeleteContent
View Recoverable items in Dumpster
Get-MailboxFolderStatistics service@contoso.de -FolderScope RecoverableItems | Format-List Name,FolderAndSubfolderSize
Remove a Name Server from All Reverse Zones
##############################
# The following section contains all input parameters
$DC = “DC1.contoso.internal” # Domain controller to be used
$nameserver = “DNS.contoso.internal” # Nameserver to remove
#
##############################
$list = Get-DnsServer -ComputerName $DC | select -Property serverzone -ExpandProperty serverzone | where {$_.isdsintegrated -eq “true” -and $_.isreverselookupzone -eq “true”} | select -Property zonename
foreach ($zone in $list ) {Remove-DnsServerResourceRecord -ComputerName $DC -ZoneName $zone.zonename -RRType Ns -Name “@” -RecordData $nameserver -Force}
EMS Not working
Sometimes an Exchange server installation goes bad and EMS will not launch from the Start Menu. This post helps to get a local EMS when you start to cleanup or want put things right.
Run these 2 commands in order on the Exchange server
exshell.psc1
exchange.ps1
Get all Remote IP Ranges from All Receive Connectors
$FormatEnumerationLimit =-1
Get-ReceiveConnector | Select-Object -Property ‘Identity’,’RemoteIPRanges’ | FL > c:\temp\relay.txt
Search a user’s mailbox for meetings
Search-Mailbox -identity Jbloggs@contoso.com -SearchQuery ‘Kind:meetings AND From:peter@xyz.com AND Subject:”Managers Monthly Meeting”‘ -TargetMailbox myaddress@contoso.com -TargetFolder ExchangeSearches -LogLevel full
Get all DNS Zones and Records in CSV
$results = Get-DnsServerZone | % {
$zone = $_.zonename
Get-DnsServerResourceRecord $zone | select @{n=’ZoneName’;e={$zone}}, HostName, RecordType, @{n=’RecordData’;e={if ($_.RecordData.IPv4Address.IPAddressToString) {$_.RecordData.IPv4Address.IPAddressToString} else {$_.RecordData.NameServer.ToUpper()}}}
}
$results | Export-Csv -NoTypeInformation c:\temp\DNSRecords.csv -Append