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 = «»
$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 -Credential $Cred -Authentication Basic -AllowRedirection
Import-PSSession $Session
#Import-Module LyncOnlineConnector
#$Session = New-CsOnlinesession -Credential $Cred
#Import-PSSession $Session
#[string]$tenant = get-msoldomain | where {$ -like «*» -and -not($ -like «*»)} | select name
#$tenant3 = $tenant -split(«=»)
#[string]$tenant4 = $tenant3[1]
#$tenant5 = $tenant4 -split(«.on»)
#[string]$tenant6 = $tenant5[0]
#$url = «https://» + $tenant6 + «»
#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 *