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
Anuncios

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s