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}

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

Assign full permissions for a user to another users calendar

Cannot assign folder permissions in mixed hybrid environment i.e. cannot grant a M365 user calendar permissions to an On-Prem 2016 mailbox or vice versa.

john@contoso.com is the calendar being shared
scahill@xyz or dirk@contoso.de is the person who is being granted permission

Get Existing Permissions

Get-MailboxFolderPermission -Identity john@contoso.com:\Calendar

If user is not English speaking get calendar or other folder local name using
Get-MailboxFolderStatistics -Identity dirk@contoso.de -FolderScope Calendar

Get the existing permissions using the local calendar name
Get-MailboxFolderPermission -Identity dirk@contoso.de\Kalendar

Grant Edit Permissions

Set-MailboxFolderPermission -Identity john@contoso.com:\Calendar-User <alias> -AccessRights Editor

Grant Manage Permissions

Add-MailboxFolderPermission -Identity john@contoso.com:\Calendar -User scahill@xyz -AccessRights Editor -SharingPermissionFlags Delegate,CanViewPrivateItems

Note -SharingPermissionFlags is cloud only

Grant Free/Busy Permissions Only

Add-MailboxFolderPermission -Identity john@contoso.com:\Calendar -AccessRights AvailabilityOnly -User scahill@xyz.com

Grant Read-Only Permissions

Add-MailboxFolderPermission -Identity john@contoso.com:\Calendar -AccessRights Reviewer -User scahill@xyz.com

Grant Limited Details Permissions

Set-MailboxFolderPermission -Identity john@contoso.com:\Calendar -User normilg -AccessRights Editor – scahill@xyz.com -SharingPermissionFlags Delegate,CanViewPrivateItems

Remove Permissions

Remove-MailboxFolderPermission -Identity john@contoso.com:\Calendar -User scahill@xyz.com

Calendar Sharing Rights aka Access Rights

Author: CreateItems, DeleteOwnedItems, EditOwnedItems, FolderVisible, ReadItems

Contributor: CreateItems, FolderVisible

Editor: CreateItems, DeleteAllItems, DeleteOwnedItems, EditAllItems, EditOwnedItems, FolderVisible, ReadItems

None: FolderVisible

NonEditingAuthor: CreateItems, FolderVisible, ReadItems

Owner: CreateItems, CreateSubfolders, DeleteAllItems, DeleteOwnedItems, EditAllItems, EditOwnedItems, FolderContact, FolderOwner, FolderVisible, ReadItems

PublishingEditor: CreateItems, CreateSubfolders, DeleteAllItems, DeleteOwnedItems, EditAllItems, EditOwnedItems, FolderVisible, ReadItems

PublishingAuthor: CreateItems, CreateSubfolders, DeleteOwnedItems, EditOwnedItems, FolderVisible, ReadItems

Reviewer: FolderVisible, ReadItems