Productivv

IT | CLOUD | RELIABLE

Powershell: Export users from AD to Excel

Export all users from AD from a specific OU (recursive) to Excel

$OU = 'OU=USERS,DC=PRODUCTIVV,DC=LOCAL'
Get-ADUser -Filter * -SearchBase $OU -SearchScope Subtree | Select-object DistinguishedName,Name,UserPrincipalName | export-csv -path c:\temp\userexport.csv

Only enabled users

$OU = 'OU=USERS,DC=PRODUCTIVV,DC=LOCAL'
Get-ADUser -Filter * -SearchBase $OU -SearchScope Subtree | Select-object DistinguishedName,Name,UserPrincipalName,Enabled | Where {$_.Enabled -like "False"} | export-csv -path c:\temp\userexport.csv 

Exchange Online: Upgrade DKIM keys to 2048-bit

Manuallly upgrade existing DKIM keys from 1024-bit to 2048-bit

Connect to Exchange online using powershell

Import-Module ExchangeOnlineManagement
Connect-ExchangeOnline

Upgrade key to 2048-bit

Rotate-DkimSigningConfig -KeySize 2048 -Identity {domain name}

Example

Rotate-DkimSigningConfig -KeySize 2048 -Identity productivv.be

Result

Get-DkimSigningConfig -identity productivv.be | Select Selector1KeySize

This new 2048-bit key takes effect on the RotateOnDate, and will send emails with the 1024-bit key in the interim. After four days, you can test again with the 2048-bit key (that is, once the rotation takes effect to the second selector).

Get-DkimSigningConfig -identity productivv.be | Select RotateOnDate

Sources:

Connect to Exchange Online PowerShell | Microsoft Learn