Remote PowerShell login Office 365 all modules

Remote PowerShell login

Requisites login into Office 365 Skype for Business Online are:

·         Running OS must be 64bit

·         Microsoft .NET Framework 4.5.x

·         PowerShell Version 3.0 or higher
(if you need to install Version 3.0+, download and install Windows Management Framework 4.0:
https://www.microsoft.com/en-us/download/details.aspx?id=40855)

Open a Windows PowerShell console.
Run the Install-Module cmdlet as shown here.

    • PS> Install-Module -Name MicrosoftTeams 




NOTE - MULTI-FACTOR AUTHENICATION:

Beside of Msol you must NOT use the $credential variable. Instead let the connect open the Login Frame


MicrosoftOnlineLogin

Set-ExecutionPolicy RemoteSigned

$credential = Get-Credential
Connect-MsolService -Credential $credential


Microsoft Teams

Connect-MicrosoftTeams -Credential $credential

  
SkypeForBusiness

Import-Module SkypeOnlineConnector
$SfBoSession = New-CsOnlineSession -Credential $credential
Import-PSSession $SfBoSession

NOTE:
if you are in an hybrid setup, you need to change the New-CsOnlineSession cmdlet. Else you would receive an error message: The remote server returned an error. (404) Not Found".
$SfBoSession = New-CsOnlineSession –Credential $credential –OverrideAdminDomain "yourdomain.onmicrosoft.com"
  
SharePoint

Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking
$orgName = "<name of your Office 365 organization, e.g. tpoett>"
Connect-SPOService -Url https://$orgName-admin.sharepoint.com -Credential $credential

Note:
orgName is not the DNS Name!



Exchange

$exchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $credential -Authentication "Basic" -AllowRedirection
Import-PSSession $exchangeSession -DisableNameChecking


Security

$ccSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.compliance.protection.outlook.com/powershell-liveid/ -Credential $credential -Authentication Basic -AllowRedirection
Import-PSSession $ccSession -Prefix cc


Logout

Remove-PSSession $sfboSession
Remove-PSSession $exchangeSession
Remove-PSSession $ccSession
Disconnect-SPOService


Azure AD

Requirements:
PowerShell 6.x
.NET Framework 4.7.2

Power Shell:

Install-Module -Name Az -AllowClobber
Connect-AzAccount
Update-Module -Name Az
Enable-AzureRmAlias
Login-AzureRmAccount


Set a user's password to never expire


I strongly urge you, that your admin user have the password set NEVER to never expire!

Run the following cmdlet to set the user password to never expire

1.  Connect to Windows PowerShell by using your company admin credentials. Run the following cmdlet:
Connect-MsolService

2.       In the Enter Credentials page, enter your Office 365 global admin credentials.

3.       After you enter your Office 365 credentials, do the following:

o    To set the password of one user to never expire, run the following cmdlet:
Set-MsolUser -UserPrincipalName <serviceaccount@contoso.com> -PasswordNeverExpires $true

Find out whether a user's password is set to never expire

1.       Connect to Windows PowerShell by using your company admin credentials. Run the following cmdlet:
Connect-MsolService

2.       Do the following:

o    To see whether a single user’s password is set to never expire, run the following cmdlet by using the user principal name (UPN) (for example, april@contoso.onmicrosoft.com) or the user ID of the user you want to check:
Get-MSOLUser -UserPrincipalName <user ID> | Select PasswordNeverExpires

Author:

Comments

Post a Comment

Popular posts from this blog

Cannot join external Lync Meeting: Lync Edge Server Single IP Address (Lync Edge Server Single IP Web Conferenceing Problem)

MFA with Guest Access and different tenants settings

Skype for Business, Lync and Exchange Web Services (EWS) and different DNS Domains- Exchange crawling e.g. for presence