Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function Connect-Office365 {
- <#
- .SYNOPSIS
- -Taylor Lee
- Modified 05172019
- .DESCRIPTION
- Connect to all Office 365 Modules or just those chosen using the provided parameters
- .Example
- Connect-Office365 -acctName name@bigcompany.com -domainHost bigcompany -all
- Connects to all included office 365 modules for this Function
- .Example
- Connect-Office365 -acctName name@bigcompany.com -skype
- Connects to skype and includes it mandatory parameters
- .Example
- Connect-Office365 -domainhost bigcompany -SharepointOnline
- Connects to skype and includes it mandatory parameters
- .Example
- Connect-Office365 -AzureAD
- Connects to a specific module using the available AzureAD parameter
- .Example
- Connect-Office365 -AzureAD -Teams
- Connects to multiple specified modules
- .Notes
- #Sharepoint Online Module
- The SharePoint Online Management Shell is a Windows PowerShell module that you can use to manage SharePoint Online users, sites,
- and site collections.
- Sharepoint Online Module https://www.microsoft.com/en-us/download/details.aspx?id=35588
- #Azure AD Module
- Windows Azure AD tenant-based administrative tasks such as user management, domain management and for configuring single sign-on
- Install-Module AzureAD
- #Exchange Online Module
- Exchange Online PowerShell allows you to manage your Exchange Online settings from the command line.
- Download the Exchange Online Module from the Hybrid section of Office 365 Exchange Admin Center
- #Security and Compliance Module
- Office 365 Security & Compliance Center PowerShell allows you to manage your Office 365 Security & Compliance Center settings from the command line.
- Download the Exchange Online Module from the Hybrid section of Office 365 Exchange Admin Center
- #Skype For Business Module
- Skype For Business Module allows managing Skype for Business settings from the Command Line.
- Download and install Skype for Business Module https://www.microsoft.com/en-us/download/details.aspx?id=39366
- If bug still exists, Visual C++ 2017 x64 14.10.25008 is needed to work with this module.
- #Microsoft Teams Module
- Microsoft Teams Module Module allows managing Microsoft Teams settings from the Command Line.
- Install-module MicrosoftTeams
- #Azure AZ Module
- Azure Az Module Module allows managing Azure settings, subscriptions, VM, Resource groups, and more from the Command Line.
- Replaces Azure RM
- Install-Module -Name Az
- #>
- [CmdletBinding(SupportsShouldProcess)]
- Param (
- [Parameter(Mandatory = $true, ParameterSetName = "All")][Parameter(Mandatory = $true, ParameterSetName = "Skype")]$AcctName,
- [Parameter(Mandatory = $true, ParameterSetName = "All")][Parameter(Mandatory = $true, ParameterSetName = "Sharepoint")]$DomainHost,
- [Parameter(Mandatory = $true, ParameterSetName = "All")][Switch] $All,
- [Parameter(Mandatory = $true, ParameterSetName = "AzureAD")][Switch] $AzureAD,
- [Parameter(Mandatory = $true, ParameterSetName = "Sharepoint")][Switch] $SharepointOnline,
- [Parameter(Mandatory = $true, ParameterSetName = "ExchangeOnline")][Switch] $ExchangeOnline,
- [Parameter(Mandatory = $true, ParameterSetName = "SecurityandCompliance")][Switch] $SecurityandCompliance,
- [Parameter(Mandatory = $true, ParameterSetName = "Skype")][Switch] $Skype,
- [Parameter(Mandatory = $true, ParameterSetName = "Teams")][Switch] $Teams,
- [Parameter(Mandatory = $true, ParameterSetName = "Az")][Switch] $Az
- )
- if ($SharepointOnline) {
- #Sharepoint Online Module
- Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking
- Write-Host "Connecting to SharePoint Online" -backgroundcolor black -foregroundcolor green
- Connect-SPOService -Url https://$DomainHost-admin.sharepoint.com
- }
- if ($AzureAD) {
- #Azure AD Module
- Write-Host "Connecting to other Azure AD Services" -backgroundcolor black -foregroundcolor green
- Connect-AzureAD
- }
- if ($ExchangeOnline) {
- #Exchange Online Module
- Write-Host "Connecting to Exchange Online Services" -backgroundcolor black -foregroundcolor green
- $CreateEXOPSSession = (Get-ChildItem -Path $env:userprofile -Filter CreateExoPSSession.ps1 -Recurse -ErrorAction SilentlyContinue -Force | Select -Last 1).DirectoryName
- . "$CreateEXOPSSession\CreateExoPSSession.ps1"
- Connect-EXOPSSession
- }
- if ($SecurityandCompliance) {
- #Security and Compliance Module
- Write-Host "Connecting to Exchange Online Protection and Security (aka Security and Compliance)" -backgroundcolor black -foregroundcolor green
- Connect-ippssession
- }
- if ($Skype) {
- #Skype For Business Module
- Import-Module SkypeOnlineConnector
- Write-Host "Connecting to Skype for Business Online" -backgroundcolor black -foregroundcolor green
- $sfboSession = New-CsOnlineSession -UserName $AcctName
- Import-PSSession $sfboSession
- }
- if ($Teams) {
- #Microsoft Teams Module
- Write-Host "Connecting to Microsoft Teams" -backgroundcolor black -foregroundcolor green
- Connect-MicrosoftTeams
- $SkypeRequired = Read-Host "Did you import the additionaly required skype module? Yes or No"
- if ($SkypeRequired -eq 'No') {
- #Skype For Business Module
- Import-Module SkypeOnlineConnector
- Write-Host "Connecting to Skype for Business Online" -backgroundcolor black -foregroundcolor green
- $sfboSession = New-CsOnlineSession -UserName $AcctName
- Import-PSSession $sfboSession
- }
- }
- if ($Az) {
- #Azure Az Module
- Write-Host "Connecting to Azure Az Module" -backgroundcolor black -foregroundcolor green
- Connect-AzAccount
- }
- if ($All) {
- #Sharepoint Online Module
- Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking
- Write-Host "Connecting to SharePoint Online" -backgroundcolor black -foregroundcolor green
- Connect-SPOService -Url https://$DomainHost-admin.sharepoint.com
- #Azure AD Module
- Write-Host "Connecting to other Azure AD Services" -backgroundcolor black -foregroundcolor green
- Connect-AzureAD
- #Exchange Online Module
- Write-Host "Connecting to Exchange Online Services" -backgroundcolor black -foregroundcolor green
- connect-exopssession
- #Security and Compliance Module
- Write-Host "Connecting to Exchange Online Protection and Security (aka Security and Compliance)" -backgroundcolor black -foregroundcolor green
- Connect-ippssession
- #Skype For Business Module
- Import-Module SkypeOnlineConnector
- Write-Host "Connecting to Skype for Business Online" -backgroundcolor black -foregroundcolor green
- $sfboSession = New-CsOnlineSession -UserName $AcctName
- Import-PSSession $sfboSession
- #Microsoft Teams Module
- Write-Host "Connecting to Microsoft Teams" -backgroundcolor black -foregroundcolor green
- Connect-MicrosoftTeams
- #Azure Az Module
- Write-Host "Connecting to Azure Az Module" -backgroundcolor black -foregroundcolor green
- Connect-AzAccount
- }
- Write-Host "Going to import modules with verbose switch so all commands are available" -backgroundcolor black -foregroundcolor green
- pause
- get-module | import-module -verbose
- Clear-Host
- Get-Command | Out-GridView
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement