Conexión remota a Powershell de Office 365
Hola a todos!
Veremos cómo conectarnos remotamente a la consola de Office 365.
| function Connect-O365(){ | |
| Import-Module msonline | |
| #USUARIO | |
| $userL="USUARIO DE ADMINISTRADOR GLOBAL" | |
| #CONTRASEÃ | |
| $passL='CONTRASEÃ DE ADMINISTRADOR GLOBAL' | |
| #ENCRIPTA LA CONTRASEÃ | |
| $encrypted = ConvertTo-SecureString $passL .asplaintext .force | |
| $cred= New-Object System.Management.Automation.PsCredential($userL, $encrypted) | |
| #CONEXIÃ AL OFFICE365 | |
| $Credentials = $cred | |
| Import-Module msonline | |
| Connect-MsolService -Credential $Credentials | |
| $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell/ -Credential $Credentials -Authentication Basic -AllowRedirection | |
| Import-PSSession $Session | |
| } | |
| Connect-O365 | |
| #VERIFICAR SESIÃ | |
| Get-PSSession |
Una vez ejecutado, tendremos acceso a todos los cmdlets de Office 365.