Join David Elfassy for an in-depth discussion in this video Connecting to Office 365 with remote PowerShell, part of Administration for Cloud-Based Office 365.
- [Voiceover] So we've managed plenty of things in Office 365 admin center and the various admin centers for Exchange, SharePoint, and Lync. As soon as you get a little bit more proficient with managing objects from these portals, you'll start to realize that there'll be times when you want to configure something but that option just simply won't be there. Well, that's when remote PowerShell walks in. PowerShell is a command line functionality of Exchange, SharePoint, and Lync on premises that has now been available in Exchange, SharePoint, and Lync online.
We can use PowerShell to establish a remote session to Office 365, specifically to our tenant, authenticate that session, and then run commands within that PowerShell session. So let's see how that looks. I'm going to pop up my PowerShell window. Now, note that I'm running this PowerShell window with elevated privileges. So the first thing that I need to do from PowerShell now is actually allow PowerShell to run scripts, in order to run my remote PowerShell commands. So to do that, I have to modify the execution policy.
Now, note that you only need to do this once per computer that you'll be using to connect to remote PowerShell. You won't need to do that again. So I'm running my set command, execution policy to modify my execution policy. And the parameter that I'm going to apply is remotesigned. I'm being asked to confirm this change, which I have. So let me clear my screen. My execution policy has been changed. I can actually verify that by using my get command.
And you'll see that my execution policy has now been set to remotesigned. Now, I'm ready to establish my remote PowerShell session. Now, the first thing that I need to do is actually establish my credentials, and those are my actual Office 365 administrative credentials. So I'm going to use the dollar sign, user credential, get credential command, which is going to prompt me for my credentials. So you see I have the pop up box now that's asking me to put in my user name and password and, again, that is the user name and password that you would be using within your portal of Office 365 when you login with login.Microsoftonline.com.
All right, so now I've entered my credentials the remaining commands that I'll be running through this PowerShell session will be authenticated with the credentials that I've just provided. So now let's begin the command to establish the session. So I'm going to define a new PowerShell session, PS session, PowerShell session and that session is going to have a name. I'm going to give it a name of Microsoft.exchange.
I need to specify my connection so I'm going to actually connect to a URI, not a URL, this is a URI, so slight difference. That URI is actually my Office 365 tenant. It's Outlook.office365.com/powershell-liveid/. Now I'm going to specify that it's going to use the credential that I provided before and the credential, again, is the credential that I provided in the pop up box that appeared just earlier.
Now I need to specify my authentication mechanism, which my authentication is basic because I provide my user name and password and allow redirection because this is a remote PowerShell connection. And hopefully I haven't mistyped anything in my session. Perfect, now when in PowerShell you actually get no reply and the command runs without any big red marks that means that it's worked and it's processed and everything that you've inputted into your session was actually successful.
Now, what I need to do is import the session. So I've defined the session, it's logged into my PowerShell, but now I need to import it. And the process of importing is actually running it. So I'm going to run the import-pssession and my session that I just defined. Now this is actually now established my remote connectivity to Office 365 loading the available PowerShell commandlet and I am now connected to Exchange online portion of Office 365.
Note that what I've been running is the connectivity to the Exchange online commandlet, they are the same processes available for Office 365, SharePoint online, and Lync online. But right now I'm connected to the PowerShell of Exchange online.
- Managing global subscription settings, domain names, and user settings
- Managing Exchange mailboxes
- Implementing Exchange distribution and security groups
- Using Message Trace
- Implementing Exchange rules
- Managing SharePoint compliance settings
- Managing Lync settings
- Using remote PowerShell to manage Office 365