Join David Elfassy for an in-depth discussion in this video Configure PowerShell for Office 365, part of Office 365: Deployment.
- [Instructor] Administrators agree that using Windows PowerShell is a great way of performing efficient management of objects for enterprise products. When we move to Office 365, we still have access to PowerShell, to be able to manage all of our objects that are stored in exchange, in share point, Skype for business, active directory. All of our configuration, all of our objects, and all of our settings can still be managed by using PowerShell. A lot of the commands are similar. A lot of the scripts that you've created at your enterprise level can be leveraged in order to be used in Office 365 as well.
So let's take a look at how PowerShell works for Office 365 because depending on the product that we're connected to, the technology that we're connecting to, we're going to use different methods of connecting, so in order to perform this demo, what I had to do is actually download some PowerShell modules and on the Microsoft website, I can download several PowerShell modules, specifically the most important one is the Azure Active Directory module for Windows PowerShell, so once I downloaded that, I went ahead and I run it as an administrator so that I have the ability to run all commands within this PowerShell.
So the first command that I'm going to run is set execution policy remote signed, which is the command that will allow me to run the various scripts that are going to be included in my tasks. I'm going to say yes to all, yes, and go onto my PowerShell tasks, so the first module that we need in order to manage Office 365. Well, it's already loaded, is the Azure active directory module, so that one I've downloaded and this is the one I've launched so that's the one I'm going to be working from.
The next module that I'm going to be working with and the next one that I'd like to load is one that I downloaded which is the one for SharePoint, so I'm going to import the module for SharePoint, so to import it, I'm going to run the import-module cmdlet. That's the command that allows you to import various modules that you've downloaded from Microsoft or that you've created yourself. Import microsoft.online.sharepoint.powershell is the command that I'm going to run to import this module and it gives me a little warning about the verbs included in this one and I'm good, so now I've imported a module.
I haven't actually established a session yet, a session to my subscription of Office 365, so let me clear the screen here and the first thing that I'm going to do is establish my credential into the local cash of PowerShell so to do that, I'm going to do a dollar sign credential and I'm going to use this variable so that my credential gets stored in this variable and I'm going to do a get credential. Now the get credential that I'm look for is my Office 365 global admin credential so that's the username and password that I'm going to enter over here and now my credential is stored in a variable of $credential so let's do two things.
First let's connect to our Office 365 subscription and to do that, I'm going to do a connect-ms, Microsoft, ol online service, Microsoft online service and I'm going to ask it to pull the credential from the variable that I just provided. And that's it. I'm now logged onto Office 365. It successfully passed through my authentication that I had provided and already stored.
Now if we want to verify that that actually works, what I'm going to do is I'm going to do a get-msoldomain. Now, these are actually my domains that are in Office 365. If you remember from previous videos in this course, when we logged onto the Office 365 admin portal, we saw these SMPT suffix domains that were available. Well, I also imported by SharePoint online, PowerShell module. Now let's see if that works. Now in order to connect to my SharePoint online administrative site, I need to connect to the service, so connect SPO, share point online, service and what I'm going to do is I'm going to connect to the URL.
Now, the URL is my administrative URL. What's interesting about the administrative URL is that it's always made up of the same parameter or the same syntax. It has the syntax formula. The first aspect of the formula is the name of the initial domain that you specified for SharePoint online during the initial setup of SharePoint online. Mine is called net logon cloud. That's the name that I provided. Then there's a /admin and it's always .sharepoint.com.
Now, I need to authenticate, so again, I'm going to pass my credential. Now, it seems a little redundant, but for every connection that I make to a separate service, a separate online service, I need to provide my credential again, so now I've run this command, created my connection, and let's test it. Let's see if it actually works, so I'm going to run a get spo site. Should pull up my sites to see if my sites are there and there they are. I have multiple sites that exist and they're all available.
I'm able to retrieve them. So I've established my connection for SharePoint online for Azure active directory for Office 365. Let's see what's left. How about SharePoint or Skype for business? So let's do Skype for business. In order to do Skype for business, I have to download also the module for Skype for business and now what I need to do is import-module and though we all call it Skype for business, in the technology, it's still lync online and it's the lync online connector so it's telling me that if you need to do this, it's going to start the WinRM service on this machine.
Now because I'm starting a service, I'm logged on as a local administrator, I'm able to start the service, but it prompts me to verify that I truly want to start this WinRM service so the service has now been started and the module has been imported so now the next task is to create a session so what we need to do is we're going to create a dollar sign, create another variable and I'm going to call it lync session, could be SharePoint Skype for business session.
You can call it whatever you want. It really doesn't matter and I'm going to run the command new cs. Now, before it was called lync, it was called communication server. That's where the cs comes from, so new-cs online session and you guessed it. Once again, I've got to provide my credentials because I'm connecting to my Skype for business online subscription and $credential so that I don't have to enter in the username and password again.
It's passing those credentials over, making my connection and now the last step is I need to import this as the PowerShell session so to do that, I run the import-pssession and I'm going to give it the name of the variable that I just created, which was lync session, so to recap, I import the module that I downloaded earlier. There's a download called the Skype for business online module for PowerShell.
Then I create my session and then I import my session into PowerShell. Enter. And success. And now I've cleared my screen so that my screen is nice and clean and after I've successfully imported my modules and set my session for Skype for business, I can actually test that to make sure that it's working, so I'm just going to do a get-cs and using tab complete, I'll see that all my CS cmdlets are available.
I'll see a style plan, conferencing policy, external access policy. I can also do my get-cs user and then I have the additional user settings that are available so I can run any of those commands and remember the commands are only available if they are truly available, so if they are able to run, so the next session that I'd like to import here and I'd like to use is exchange, so for exchange again, I'm going to use a variable, so I'm going to pass create variable. I'm going to call it $exchange and you can name it whatever you like.
I'm going to create a new PowerShell session and I'm going to have it connect to a configuration partition, configuration named Microsoft.exchange and I'm going to connect it to a specific URI. Now, the URI is actually stored in Office 365 and I'm forcing my connection to Office 365 to a specific administrative URI. A URI is kind of like a URL, so outlook.office365.com/powershell-liveid.
Now, you might remember Live ID as being a formal name of passport and now what we call Microsoft account. That's the URL that I'm going to be connecting to. I'm going to specify my credential again and I'm passing through my credential that I've already put into a variable in PowerShell, so using my $credential and then I'm going to specify the type of authentication that I will use. Now, because I'm using a remote PowerShell connection for this URL, I need to specify my authentication and I need to specify that the authentication be of type basic and I'm going to allow redirection of my authentication as well and run my command and hopefully I haven't had a typo, which I didn't.
That's great and so I've created my variable and now I'm ready to import this variable into my PowerShell session. So import-ps session, PowerShell session and I'm going to equate that to my variable, which is $exchange, so I'm importing the variable that I just created. I probably made a typo here. Oh, yes. Very important to type correctly and I'm missing an S in my ps-session.
Let's try that again. Perfect, so now it's importing my Powershell session and I'd like to see if this is working correctly and to do that, I'll run a simple get-mailbox cmdlet to see if I can see my Exchange mailboxes and they're there. All the mailboxes that I've created before, I can actually create nice lists here and I have a great course on Exchange on the library where I discuss in advance or I discuss advanced PowerShell techniques of managing objects in Exchange, so I encourage you to look at those.
So now I'm able to run my command for my active directory users, so all of my users that are in... And that's not the correct command. Get-msol-accounts, not account. Let's see what we have here. I have lots of... Oh, there's a good one. Get it. Msol-administrative unit, no. Oh, I have to connect to my server, so I had connected earlier, but I closed my window, so let me reconnect to my service and...
Dash credential, $credential. See, this is very useful to see sometimes error messages. We get to troubleshoot our own connection, so if I do a get-msol AD administrative unit. I actually have no administrative units in my active directory, Azure active directory, so let's see what else I can have here. Account sku. Account sku might be an interesting one.
Yeah, so these are all my licenses that I have for my Office 365 subscription, so all of my Azure AD subscription and my RMS enterprise pack which is actually my true Office 365, so I've got that. I've got my SharePoint online objects. I can also get SPO, SharePoint online, and I see that I have lots of information here, deleted sites, external users, and all of my settings here are going to be available, running get-SPO site or get-SPO, get-CS which are my Skype for business.
I keep on calling it lync but it's Skype for business and I get to have all of my settings for Skype for business that are available through here. Here, for example, all of my audio conferencing providers and of course, I've got all of my exchange, so all of my exchange configuration settings. Here, if I... Mailbox, mailbox activity report. All of my mailbox settings and all of my exchange configurations are going to be available through that.
Let's see if I can do a get-calendar. Yeah, get calendar objects, no. We can do another one here. Get-transport. Yeah, get-transportconfig, which is all of the configuration of how all of my email messages are being delivered throughout my organization and throughout my Office365 subscription and out to the internet, so all of my cmdlets are here. It doesn't matter if they're exchange cmdlets, if they're lync cmdlets, if they're Azure cmdlets, if they're Office 365 basic cmdlets.
All of those are available through PowerShell. I just have to download the modules, import them all, and they're available in my PowerShell command. Now one thing that you may want to do is then save this PowerShell context so that you don't have to reenter all this information every time or if you use multiple machines, include all of these commands in a single script, keep that script handy so you can run it on multiple machines and that's using PowerShell for Office 365.
This course details the process of moving your network to Office 365 by deploying a new Office 365 subscription. David Elfassy covers creating user accounts, adding domains, and configuring email, directories, conferencing, file sharing, and valuable business services such as PowerShell and SharePoint. Watch these tutorials to deploy your own implementation of Office 365 or to see if this technology fits your enterprise needs.
- Using FastTrack to prepare for Office 365
- Creating Office 365 user accounts
- Adding domains
- Configuring Outlook and Skype
- Configuring sharing and shared mailboxes
- Troubleshooting an Office 365 deployment
- Configuring PowerShell
- Creating SharePoint services