Mostrando entradas con la etiqueta Office 365. Mostrar todas las entradas
Mostrando entradas con la etiqueta Office 365. Mostrar todas las entradas

miércoles, 2 de marzo de 2016

Remote Powershell to manage Office 365

Yhea, in the previous post I wrote about connecting to Office 365 using powershell in order to do taks related to Office 365.


But if we want to go a bit deep and do some Exchange tasks (For instance Get-Mailbox), we will need to connect into our  Exchange Online, if not we’ll get an error like:



So, in order to connect into our Exchange Online and be able to break everything … sorry, I mean to FIX everything, we should follow the next steps:


1- Update the default PowerShell Execution Policy

Set-ExecutionPolicy Unrestricted


2- Creating a Remote Session to Exchange Online. 
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession

NOTE: After that a window will pop up asking you for your credentials. You should enter your Office 365 admin user.

3- Done, you are connected to your Exchange Online. 
In order to check your connectivity, now you can run the command Get-Mailbox  

lunes, 29 de febrero de 2016

Get Office 365 users using Powershell

Sometimes, at work I need to check the licensed users in Office 365, I can check them from the Office 365 Admin website, but I’m not sure if I’m able to export them to an Excel (Or CSV file).

So, in order to do that I’ll do it using our little friend, the uncle PowerShell.

Before jumping into the commands, you will need to install some modules to connect to your Azure Office 365 platform.

  1. First install the  Microsoft Online Services Sign-In Assistant for IT Professionals RTW
  2. Then Azure Active Directory Module for Windows PowerShell (64-bit version) 
Now, open a powershell terminal and type:
 
PS C:\WINDOWS\system32> Connect-MsolService
A new window will pop up, enter your Office 365 credentials there. And then, if you don't have any error, you will be in. Now type the following command:
PS C:\WINDOWS\system32> Get-MsolUser | Where-Object {$_.isLicensed -eq "TRUE"} | Export-Csv C:\LicensedUsersOffice365.csv


And that is it, you will have an excel file of all your licensed users on Office 365.