Connect Office 365

Once you have you PC/PowerShell prepared, you can connect to Office 365, using a simple script as this, where you define your username, and thereafter you can simply click it. don’t forget, you use the dollar sign $ to generate PSvariables.

$User = «sysadmin@MyDomain.info»
$Pass = ConvertTo-SecureString «TheWarMachineIsTheBest.» -AsPlainText -Force
$Cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $Pass
Import-Module MSOnline
Connect-msolservice -Credential $Cred
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $Cred -Authentication Basic -AllowRedirection
Import-PSSession $Session
#Import-Module LyncOnlineConnector
#import-module microsoft.online.sharepoint.powershell
#$Session = New-CsOnlinesession -Credential $Cred
#Import-PSSession $Session
#[string]$tenant = get-msoldomain | where {$_.name -like «*.onmicrosoft.com» -and -not($_.name -like «*mail.onmicrosoft.com»)} | select name
#$tenant
#$tenant3 = $tenant -split(«=»)
#[string]$tenant4 = $tenant3[1]
#$tenant4
#$tenant5 = $tenant4 -split(«.on»)
#[string]$tenant6 = $tenant5[0]
#$url = «https://» + $tenant6 + «-admin.sharepoint.com»
#Connect-SPOService -Url $url -credential $Cred

Dejar un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *