Saturday, May 20, 2017

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 -RequiredVersion <version>







MicrosoftOnlineLogin

Set-ExecutionPolicy RemoteSigned

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

  
SkypeForBusiness

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

  
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



Set a user's password to never expire


I strongly urge you, that your admin user have the password set 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:

No comments:

Post a Comment