Connect Online Services Powershell

I can not remember from time to time how to start remote powershell towards different services. I just made a script to make things easier for myself. There is always room for improvement, to reuse credentials, but sometimes I need to use different accounts.

function Show-Menu
{
param (
[string]$Title = ‘Powershell Services’
)
cls
Write-Host “================ $Title ================”

Write-Host “1: Press ‘1’ Azure Active Directory.” -ForegroundColor Green
Write-Host “2: Press ‘2’ Exchange Online.” -ForegroundColor Green
Write-Host “3: Press ‘3’ Skype for Business.” -ForegroundColor Green
Write-Host “4: Press ‘4’ SharePoint Online.” -ForegroundColor Green
Write-Host “5: Press ‘5’ Security and Compliance Center.” -ForegroundColor Green
Write-Host “Q: Press ‘Q’ to quit.” -ForegroundColor Green
}

Show-Menu –Title ‘Powershell Services’
$selection = Read-Host “Please choose Service”
switch ($selection)
{
‘1’ {
‘You chose option #1 – AzureAD’
# Azure Active Directory
$Credential = Get-Credential
Connect-MsolService -Credential $Credential
} ‘2’ {
‘You chose option #2 – Exchange Online’
# Exchange Online
$credential = Get-Credential
$exosession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid -Credential $credential -Authentication Basic –AllowRedirection
Import-PSSession $exosession
} ‘3’ {
‘You chose option #3 – Skype FB’
# Skype for Business
$credential = Get-Credential
$skypesession = New-CsOnlineSession -Credential $credential
Import-PSSession $skypesession
} ‘4’ {
‘You chose option #4 – SharePoint Online’
# SharePoint Online
$Credential = Get-Credential
Connect-SPOService -url https://<enter sitename here>-admin.sharepoint.com -Credential $credential
} ‘5’ {
‘You chose option #5 – Security and Compliance’
# Security and Compliance Center
$credential = Get-Credential
$ccsession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.compliance.protection.outlook.com/powershell-liveid/ -Credential $Credential -Authentication Basic -AllowRedirection
Import-PSSession $ccsession
} ‘q’ {
return
}
}

Skype for Business CsRGSHolidaySet

Created RGSHolidaySet for Norway 2018.

$poolname = Read-Host -Prompt “Legg inn Skype-pool navn, full FQDN”
$NyttAar = New-CsRgsHoliday -Name “Nyttårsdag” -StartDate “1/1/2018” -EndDate “2/1/2018”
$SkTo = New-CsRgsHoliday -Name “Skjærtorsdag” -StartDate “29/3/2018” -EndDate “30/3/2018”
$LaFr = New-CsRgsHoliday -Name “Langfredag” -StartDate “30/3/2018” -EndDate “31/3/2018”
$PMan = New-CsRgsHoliday -Name “2. Påskedag” -StartDate “2/4/2018” -EndDate “3/4/2018”
$Arb = New-CsRgsHoliday -Name “Arbeidernes dag” -StartDate “1/5/2018” -EndDate “2/5/2018”
$Himmel = New-CsRgsHoliday -Name “Kristi Himmelfartsdag” -StartDate “10/5/2018” -EndDate “11/5/2018”
$17Mai = New-CsRgsHoliday -Name “Grunnlovsdagen” -StartDate “17/5/2018” -EndDate “18/5/2018”
$2Pinse = New-CsRgsHoliday -Name “2. Pinsedag” -StartDate “21/5/2018” -EndDate “22/5/2018”
$Jul = New-CsRgsHoliday -Name “Julen 2018” -StartDate “25/12/2018” -EndDate “27/12/2018”

New-CsRgsHolidaySet -Parent “ApplicationServer:$poolname” -Name “Holiday 2018” -HolidayList ($NyttAar, $SkTo, $LaFr, $PMan, $Arb, $Himmel, $17Mai, $2Pinse, $Jul)

Network connectivity issues or an incorrectly configured certificate on the destination server

Issued new certificate for internal Front End. The new certificate had SHA256, vs old one had SHA1. There were two FE servers but only one gave this error:

Sending HTTP request failed. Server functionality will be affected if messages are failing consistently.

Sending the message to https://FQDN:444/LiveServer/Replication failed. IP Address is 10.10.0.12. Error code is 0x2EFE. Content-Type is application/replication+xml. Http Error Code is 0x0.
Cause: Network connectivity issues or an incorrectly configured certificate on the destination server. Check the eventlog description for more information.
Resolution:
Check the destination server to see that it is listening on the same URI and it has certificate configured for MTLS. Other reasons might be network connectivity issues between the two servers.

 

Solution: Run local setup on server. Was not necessary on the other for some reason.