Step 1: Start Windows PowerShell as an Administrator

 

Topic Last Modified: 2013-12-13

Technically you don’t have to start here: you could kick things off by starting the Windows Azure Active Directory management shell or the SharePoint Online management shell instead. But we’re going to start completely from scratch, which means running “plain old” Windows PowerShell as an administrator.

To run Windows PowerShell as an administrator, complete one of the following two procedures. If you’re running Windows 8, do this:

  1. Access the Charms bar, click Search, and then right-click Windows PowerShell. You can quickly access the Charms bar on any Windows 8 computer (touch screen or non-touch screen) by holding down the Windows key and pressing C.

  2. In the toolbar at the bottom of the screen, click Run as administrator.

  3. If the User Account Control dialog box appears, click Yes to verify that you want to run Windows PowerShell under administrator credentials.

If you’re running Windows 7 (or Windows Servers 2008 or Windows Server 2012) do this:

  1. Click Start, click All Programs, click Accessories, click Windows PowerShell, right-click Windows PowerShell, and then click Run as administrator.

  2. If the User Account Control dialog box appears, click Yes to verify that you want to run Windows PowerShell under administrator credentials.

And yes, you absolutely must run Windows PowerShell as an administrator. If you don’t, you’re going to get an error message similar to this when you try to import one of the Office 365 modules:

The specified module 'Microsoft.Online.SharePoint.Online.PowerShell' was not loaded because no valid module file was found in any directory.

Admittedly, that’s not the clearest error message ever written: the problem really isn’t that the module file couldn’t be found, the problem is that you can’t import a module unless you’re running as an administrator. The whole only way to remedy the situation is to close Windows PowerShell and restart it as an administrator.

After Windows PowerShell is up and running you should then verify that PowerShell is configured to run scripts. To do that, type this command from the PowerShell prompt and then press ENTER:

Get-ExecutionPolicy

Why do you need to do this? Well, if the execution policy is set to anything other than Unrestricted or RemoteSigned you’ll encounter an error similar to this when you try to import a module:

Import-Module : File C:\Program Files\Common Files\Microsoft Lync Server2013\Modules\lynconlineconnector\LyncOnlineConnectorStartup.psm1 cannot be loaded because running scripts is disabled on this system.

If you need to change the execution policy, use the Set-ExecutionPolicy cmdlet this command:

Set-ExecutionPolicy RemoteSigned

Note that you don’t have to exit and restart PowerShell; the change will take effect immediately.


Step 2: Create a Windows PowerShell Credentials Object

 
Show: