Wednesday, November 20, 2013

how I configure a script to get into a Powershell CLI for editing Office365 properties

I was setting up a laptop to use a script to get into a Powershell CLI and wanted to document what I used to get in.

You'll need to download two items to enable PowerShell:

1) Microsoft Online Services Sign-in Assistant
2) Azure AD Module for Windows PowerShell

from here:

https://technet.microsoft.com/library/dn975125.aspx


You may need to install .net 3.5 from turn windows features on/off.

Then I created a folder on the root C called scripts.  In there, I created a file called office365.ps1 with these contents:
---
Import-Module MSOnline
$O365Cred = Get-Credential
$O365Session = New-PSSession –ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $O365Cred -Authentication Basic -AllowRedirection
Import-PSSession $O365Session
Connect-MsolService –Credential $O365Cred
---

Then I make edits by opening powershell.  Navigate to c:\scripts and run office365.ps1.  Of note, you might also need to enable remote execution (Set-ExecutionPolicy RemoteSigned) like this:









From there, I use the commands I described in this post:
http://t-solve.blogspot.com/2013/01/office365-shell-commands-for-reference.html



When I need to run a Powershell script, I open powershell, navigate to c:\scripts, and I run office365.ps1 like this:


No comments: