PowerShell

Microsoft 365 PowerShell scripting is a powerful tool for automating and managing various aspects of the Microsoft 365 environment. With PowerShell, IT professionals can streamline administrative tasks, enhance operational efficiency, and ensure consistent configurations across the organization.

8/1/20201 min read

PowerShell

Modify Mailbox Settings Via the Set-Mailbox Cmdlet

Set-Mailbox -Identity "Joseph Ludwig" -Alias "Josephludwig25"

Set-Mailbox -Identity “Joseph Ludwig” -DisplayName “Joe Ludwig”

Set-Mailbox -Identity “Joseph Ludwig” -samAccountName joeludwig

Set-Mailbox -Identity “Joseph Ludwig” -ArchiveDatabase Archive01

Set-Mailbox -Identity “Joseph Ludwig” -Database MBX01Archive01

Set-Mailbox -Identity “Joseph Ludwig” -ArchiveQuota 50GB

Set-Mailbox -Identity “Joseph Ludwig” -ArchiveWarningQuota 45GB

Set-Mailbox -Identity “Joseph Ludwig” -ForwardingAddress “Joseph Ludwig”

Set-Mailbox -Identity “Joseph Ludwig” -ForwardingSmtpAddress “josephludwig@gmail.com

Set-Mailbox -Identity “Joseph Ludwig” -ForwardingAddress “Joseph Ludwig” -DeliverToMailBoxAndForward $True

Get-AdUser -Filter {department eq 'IT'} | ForEach {Set-Mailbox -Identity $_.Name -DeliverToMailboxAndForward $true -ForwardingAddress "Joseph Ludwig"}

Get-ADUser -SearchBase "OU=IT,OU=Department,DC=jl,DC=joe,DC=com" -Properties -Filter | Select samAccountName,GivenName,Surname,DisplayName,UserPrincipalName,EmailAddress,Department,msExchRecipientTypeDetails,Title,Company,Enabled,LastLogonDate,PasswordLastSet,PasswordNeverExpires | Export-Csv C:\Users\joe\Desktop\HR10102024.csv -Encoding UTF8 -NoTypeInformation

Sharepoint Cmdlet

Get-SPOTenant | Select disallowinfectedfiledownload

Set-SPOTenant -DisallowInfectedFileDownload $true

Office 365 Tenant Cmdlet

New-AuthenticationPolicy -Name "Block Basic Authentication"

Set-OrganizationConfig -MailTipsExternalRecipientsTipsEnabled $True

Set-OwaMailboxPolicy OwaMailboxPolicy-Default -LinkedInEnabled $False

Set-OwaMailboxPolicy OwaMailboxPolicy-Default -AdditionalStorageProvidersAvailable $False

Set-AdminAuditLogConfig $true

Get-MsolcompanyInformation | Select Allowemailverifiedusers, Allowadhocsubscriptions

Get-OrganizationConfig | fl auditdisabled*

Outlook Registry Key to Configure Outlook for On Prem user without connecting to office 365 when organization is in hybrid mode.

reg add HKEY_CURRENT_USER\Software\Policies\Microsoft\Office\16.0\Outlook\AutoDiscover /v ExcludeExplicitO365Endpoint /t REG_DWORD /d 1 /f