01 November 2020

Add an emailaddress to the safe senders list in Outlook for all Office365 mailboxes

 Adding an email address to be trusted for whatever reason to your environment depends on what email anti spam/phish/malware/virus solution you have.

But here's one that's always in the way. Outlook.

Here's how to add an email address to the safe senders list in Outlook for all your mailboxes in Exchange Online:

#Add trusted sender and domain per user:            
Set-MailboxJunkEmailConfiguration firstname.lastname@domain.com  -TrustedSendersAndDomains @{Add="@something.com","info@something.com"}             
            
#Add Blocked sender and domain per user:            
Set-MailboxJunkEmailConfiguration firstname.lastname@domain.com  -BlockedSendersAndDomains @{Add="@something.com","info@something.com"}            
            
#Add emailaddress to the trusted list in all mailboxes:            
Get-Mailbox -resultsize unlimited | Set-MailboxJunkEmailConfiguration -TrustedSendersAndDomains @{Add="quarantine@messaging.microsoft.com"}            
            
#Add a domain and an email address to the trusted list in all mailboxes:            
Get-Mailbox -resultsize unlimited | Set-MailboxJunkEmailConfiguration -BlockedSendersAndDomains @{Add="domain1.com", "user@domain2.com"}            

Install Office365 requirements with PowerShell - SkypeOnline - ExchangeOnline - AzureAD - SharepointOnline - Teams PowerShell modules

Updated - 01-11-2020

  • Replaced the SharePoint Online installer with the PowerShell Gallery module
  • Added Exchange Online V2 module
  • Updated SharePoint Online PowerShell module URL
  • Added Teams PowerShell module
  • Added AZ PowerShell module
  • Added Intune PowerShell module
  • Added Staff Hub PowerShell module

I came across a script by Chris Goosen to connect to all of the Office 365 services via PowerShell.
When I tried to run it errors were flying everywhere.
All of the requirements were missing on my system.

So that's what I came up with, a one stop way to get all of those requirements in one single go.
<#
.SYNOPSIS 
Install Office365 PowerShell Prerequisites
 
.DESCRIPTION  
Downloads and installs the AzureAD, Sharepoint Online, Skype Online for Windows PowerShell etc.

.Made by 
Edwin van Brenk

.Date
01-11-2020

.Source
https://vanbrenk.blogspot.com/2018/03/install-office365-requirements-with.html
#>            
                       
<#
Function InstallSharepointOnlinePowerShellModule() {

$SharepointOnlinePowerShellModuleSourceURL = "https://download.microsoft.com/download/0/2/E/02E7E5BA-2190-44A8-B407-BC73CA0D6B87/SharePointOnlineManagementShell_8525-1200_x64_en-us.msi"

$DestinationFolder = "C:\Temp"

     If (!(Test-Path $DestinationFolder))
     {
         New-Item $DestinationFolder -ItemType Directory -Force
     }

Write-Host "Downloading Sharepoint Online PowerShell Module from $SharepointOnlinePowerShellModuleSourceURL"

     try
     {
         Invoke-WebRequest -Uri $SharepointOnlinePowerShellModuleSourceURL -OutFile "$DestinationFolder\SharePointOnlineManagementShell_7414-1200_x64_en-us.msi" -ErrorAction STOP

$msifile = "$DestinationFolder\SharePointOnlineManagementShell_7414-1200_x64_en-us.msi"
$arguments = @(
          "/i"
          "`"$msiFile`""
          "/passive"
)

Write-Host "Attempting to install $msifile"

         $process = Start-Process -FilePath msiexec.exe -Wait -PassThru -ArgumentList $arguments
         if ($process.ExitCode -eq 0)
         {
             Write-Host "$msiFile has been successfully installed"
         }
         else
         {
             Write-Host "installer exit code  $($process.ExitCode) for file  $($msifile)"
         }

     }
     catch
     {
         Write-Host $_.Exception.Message
     }
 }

InstallSharepointOnlinePowerShellModule
#>            
            
# Download and Install Visual Studio C++ 2017                        
$VisualStudio2017x64URL = "https://download.visualstudio.microsoft.com/download/pr/11687625/2cd2dba5748dc95950a5c42c2d2d78e4/VC_redist.x64.exe"            
Write-Host "Downloading VisualStudio 2017 C++ from $VisualStudio2017x64"                         
            
$DestinationFolder = "C:\Temp"            
            
Invoke-WebRequest -Uri $VisualStudio2017x64URL -OutFile "$DestinationFolder\VC_redist.x64.exe" -ErrorAction STOP            
            
Write-Host "Attempting to install VisualStudio 2017 C++, a reboot is required!"            
            
Start-Process "$DestinationFolder\VC_redist.x64.exe" -ArgumentList "/passive /norestart" -Wait            
            
Write-Host "Attempting to install VisualStudio 2017 C++"            
            
# Download and Install Skype Online PowerShell module            
$SkypeOnlinePowerShellModuleSourceURL = "https://download.microsoft.com/download/2/0/5/2050B39B-4DA5-48E0-B768-583533B42C3B/SkypeOnlinePowerShell.Exe"            
            
$DestinationFolder = "C:\Temp"            
            
     If (!(Test-Path $DestinationFolder))            
     {            
         New-Item $DestinationFolder -ItemType Directory -Force            
     }            
            
Write-Host "Downloading Skype Online PowerShell Module from $SkypeOnlinePowerShellModuleSourceURL"            
            
Invoke-WebRequest -Uri $SkypeOnlinePowerShellModuleSourceURL -OutFile "$DestinationFolder\SkypeOnlinePowerShell.Exe" -ErrorAction STOP            
            
Start-Process "$DestinationFolder\SkypeOnlinePowerShell.Exe" -ArgumentList "/quiet" -Wait            
            
# Register PSGallery PSprovider and set as Trusted source            
Register-PSRepository -Name PSGallery -SourceLocation https://www.powershellgallery.com/api/v2/ -PublishLocation https://www.powershellgallery.com/api/v2/package/             
-ScriptSourceLocation https://www.powershellgallery.com/api/v2/items/psscript/ -ScriptPublishLocation https://www.powershellgallery.com/api/v2/package/ -InstallationPolicy             
Trusted -PackageManagementProvider NuGet -ErrorAction SilentlyContinue                        
Register-PSRepository -Default -ErrorAction SilentlyContinue            
Set-PSRepository -Name psgallery -InstallationPolicy trusted            
            
# Install modules from PSGallery            
Install-Module -Name AADRM -Force            
Install-Module -Name AzureADPreview -Force            
Install-Module -Name AzureAD -Force            
Install-Module -Name MSOnline -Force            
Install-Module -Name AZ -Force            
Install-Module -Name MicrosoftTeams -Force            
Install-Module -Name Microsoft.Graph.Intune -Force            
Install-Module -Name Microsoft.Online.SharePoint.PowerShell -Force            
            
# Manually install Exchange Online with MFA authentication support from the Exchange Online ECP            
Write-Host "Login, go to Hybrid and download the Exchange Online Powershell module"            
Start-Process https://outlook.office365.com/ecp/

Add Color coded PowerShell code to your Blogger page

I wanted a nicer way to show PowerShell code on my page here.
So after a little bit of searching a came across the PowerShell ISE.
Now thats nothing new, but what i didn't know is that you can add "add ons" to the ISE and with that it becomes even more fun.

To be able to add color coded PowerShell code to your blog install the module "IsePackV2"

If you haven't set Chocolatey and PSGallery as Packagesource and trusted them then run:
Get-PackageProvider -Name PSGallery -Force
Set-PackageSource -Name PSGallery -Trusted
Get-PackageProvider -Name Chocolatey -Force
Set-PackageSource -Name Chocolatey -Trusted
This Add on needs some additional modules so we'll install all in one go.
You can run this in PowerShell Ise or regular PowerShell but both must be run with elevated permissions:
Install-Module IsePackV2 -AllowClobber -Force           
Install-Module ShowUI -AllowClobber -Force            
Install-Module RoughDraft -AllowClobber -Force            
Install-Module Pipeworks -AllowClobber -Force            
Install-Module EZOut -AllowClobber -Force            
Install-Module ScriptCop -AllowClobber -Force            
Import-Module IsePackV2
When running the PowerShell ISE as Administrator and running Import-Module IsePackV2 there will be some error. I don't know where it comes from, i'll have to look in to that later.
But for now the thing your looking for is the add on we just added.





















The way this is as follows.
Your type some stuff in the script pane in the ISE.

















Select and copy it, go to Add-ons -> IsePack -> Edit -> Copy-ColoredAsHtml.
As soon as you click "Copy-ColoredAsHtml" it on your clipboard.
Now go to your blog editor and paste the text in the Html editor page:













And then it will look like this on your blog: