Introduction
This help file gives you background and usage information for the "ManageSway" Microsoft® Windows® PowerShell script (ManageSway.ps1).
The script offer functionality to manage Microsoft® Office 365 services.
Its main purpose was to disable or enable (show/hide) the Microsoft® Sway tile on the app launcher of the Microsoft® Office 365 portal, but can also be used to manage any other Microsoft® Office 365 service.
Note:
· You can also inform your users how to add or remove tiles on the
Microsoft® Office 365 app launcher.
Please check the following information: http://go.microsoft.com/fwlink/p/?LinkId=746934
· This file will be shown best with screen resolution 1280 x 1024 (or higher).
Prerequisites
Before you can manage Microsoft® Office 365 with the script, you have to install required software.
Note:
· The script supports the following operating
systems:
Microsoft® Windows® 7, Windows® 8, Windows® 8.1, Windows® 10, Windows® Server
2012, Windows® Server 2012 R2 and Windows® Server 2016.
1. Install the 64-bit version of the Microsoft® Online Services Sign-in Assistant
http://go.microsoft.com/fwlink/p/?LinkId=286152
The "Microsoft® Online Services Sign-In Assistant" (MOS SIA) provides end user sign-in capabilities to Microsoft® Online Services. The MOS SIA installs client components that allow common applications, such as Microsoft® Office 365 for example, to authenticate to Microsoft® Online Services.
Note:
· For users who are installing Microsoft® Office 365 by means of the Microsoft® Office 365 desktop setup application, this download is not necessary, because the MOS SIA is installed as part of the desktop setup process.
2. Install the 64-bit version of the Windows® Azure Active Directory Module for Windows® PowerShell
http://go.microsoft.com/fwlink/p/?linkid=236297
Please also review the information "Install the Azure Active Directory Module" on MSDN for more information like how to update existing installations of the Azure Active Directory Module for Windows® PowerShell:
http://go.microsoft.com/fwlink/p/?LinkId=691475
Note:
· The Windows® Azure Active Directory Module for Windows® PowerShell requires that the Microsoft® .NET Framework 3.5.x feature is enabled on your computer.
3. Ensure that Microsoft® Office 365 is on "First Release"
Logon to Microsoft® Office 365 admin center with your global administrator credentials. Navigate to “SETTINGS” – “ORGANIZATION PROFILE”, click on “Actions” – “Edit” at “Release preferences” and set “Release track” accordingly. To learn more about the Microsoft® Office 365 release options, see http://go.microsoft.com/fwlink/p/?LinkId=746945.
Note:
· It can take up to 24 hours for the changes to take effect in Microsoft® Office 365.
Usage
You have to run the script with administrative permissions in a Microsoft® Windows® PowerShell command window. Therefore, click the START button of Microsoft® Windows® and start typing "power". While you type, you'll see an entry occurring "Windows PowerShell" (Desktop app). Right click this entry and from the upcoming context menu select "Run as administrator".
By default, running PowerShell scripts (*.ps1) is disabled, and you have to bypass this restriction to be able to run the script. This can be done by calling the "Set-ExecutionPolicy"-command with the following parameter:
PS C:\> Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
In the command window, navigate to the location where you have stored the script file (ManageSway.ps1) and run the script. For example:
PS C:\> C:\Scripts\ManageSway.ps1
Note:
· To run the script, you need to have administrative permission on the local machine, and you need to place the script and its help file (ManageSwayHelp.htm) in the same folder.
· Run the script in a Microsoft® Windows® PowerShell command window instead of Microsoft® Windows® PowerShell ISE. This is because the script uses some methods that are not available in Microsoft® Windows® PowerShell ISE. Therefore, you may experience a 10 second sleep time when using Microsoft® Windows® PowerShell ISE after calling some menu entries before the script switch back to the default menu.
User experience
When you start the script, you'll see an important warning message.
After that you'll see the following default menu:
[1] REVIEW account SKU IDs
[2] DISABLE a service
[3] ENABLE all services for all users
[4] REVIEW service plan status for one user
[5] WARNING
[6] INFORMATION
[7] HELP
[8] EXIT
Please select an option and press enter
If you select option [2], a submenu will be expanded, and you can collapse it by selecting option [2] again:
[1] REVIEW account SKU IDs
[2] DISABLE a service
├──[21] DISABLE a service for all users
└──[22] DISABLE a service for one user
[3] ENABLE all services for all users
[4] REVIEW service plan status for one user
[5] WARNING
[6] INFORMATION
[7] HELP
[8] EXIT
Please select an option and press enter
Detailed description
The script offers eight options.
Note:
· You need to know your Microsoft® Office 365 global admin account information to proceed. You'll be asked for the related password.
· For some options, you need to know your account SKU ID ([2], [21], [22], [3], and [4]. Once you have used an account SKU ID, or your Microsoft® Office 365 global admin account, the data will be cached until you exit the script, or if you type "C" and confirm with enter.
[1] REVIEW account SKU IDs
This option evaluates your existing account SKU IDs.
As output, you'll see something similar to this:
AccountSkuId ActiveUnits WarningUnits ConsumedUnits
------------ ----------- ------------ -------------
Sample:ENTERPRISEPREMIUM 365 0 16
Please note the account SKU ID, because you’ll use it later.
Note:
· Be sure to use an account SKU ID that contains
a license for the related service you want to manage.
The following article contains information about the licenses that are
available for Sway: https://support.microsoft.com/kb/3080969
[21] DISABLE a service for all users
This option disables the selected service plan for all users.
For example, if you selected SWAY, the resulting output will look like this:
ServicePlan ProvisioningStatus
----------- ------------------
EQUIVIO_ANALYTICS Success
LOCKBOX_ENTERPRISE Success
EXCHANGE-ANALYTICS Success
SWAY Disabled
ATP_ENTERPRISE PendingActivation
MCOEV Success
MCOMEETADV Success
BI_AZURE_P2 PendingInput
INTUNE_O365 PendingActivation
PROJECTWORKMANAGEMENT Success
RMS_S_ENTERPRISE Success
YAMMER_ENTERPRISE Success
OFFICESUBSCRIPTION Success
MCOSTANDARD Success
EXCHANGE_S_ENTERPRISE Success
SHAREPOINTENTERPRISE Success
SHAREPOINTWAC Success
Additional information about disabling access to services with Microsoft® Office 365 PowerShell can be found here:
http://go.microsoft.com/fwlink/p/?LinkId=691483
Note:
· If you have disabled Sway, you may have to wait a view minutes until the change is reflected in the Microsoft® Office 365 portal, and the related tile disappears from the app launcher.
· Disabling a service like Sway just removes the tile for existing users. You have to repeat the procedure for every new user.
· You'll be asked for the service plan name you want to use, which should be SWAY here. But you can use any other valid service plan name. Check step 6 to find out other service plan names you can use.
[22] DISABLE a service for one user
This option disables the selected service plan for a single user only.
The resulting output looks similar to the previous step.
More information can also be found in the following knowledgebase article:
https://support.microsoft.com/kb/3075256
[3] ENABLE all services for all users
This option enables all service plans for all users.
The resulting output will look like this:
ServicePlan ProvisioningStatus
----------- ------------------
EQUIVIO_ANALYTICS Success
LOCKBOX_ENTERPRISE Success
EXCHANGE-ANALYTICS Success
SWAY Success
ATP_ENTERPRISE PendingActivation
MCOEV Success
MCOMEETADV Success
BI_AZURE_P2 PendingInput
INTUNE_O365 PendingActivation
PROJECTWORKMANAGEMENT Success
RMS_S_ENTERPRISE Success
YAMMER_ENTERPRISE Success
OFFICESUBSCRIPTION Success
MCOSTANDARD Success
EXCHANGE_S_ENTERPRISE Success
SHAREPOINTENTERPRISE Success
SHAREPOINTWAC Success
Note:
· You can’t enable a single service for a single user. All services can only be enabled for all users.
· You can use the script to disable Sway (or any other service) for each user, but the script does not offer a method for disabling a service for a large number of individual users. To do that, you'd have to modify the script code to implement the changes you want. Also, bear in mind that this setting will only affect existing users. For new users, you'd have to repeat the whole process again.
[4] REVIEW service plan status for one user
This option reviews the service plan status for a particular user.
The resulting output look similar to the output in the previous step.
[5] WARNING
This option displays a warning message. Please read it carefully, and act accordingly.
Every time you start the script, this warning is shown.
[6] INFORMATION
This option shows general information, like version information.
[7] HELP
This option opens this help file (ManageSwayHelp.htm).
[8] EXIT
This option asks you if you want to quit the script, and exit it after a confirmation prompt.
When exiting the script, all cached information is removed, and the execution policy is set back to its default value. For Microsoft® Windows®7, Windows® 8, Windows® 8.1 and Windows® 10 this will be "Restricted". For Microsoft® Windows® Server 2012, Windows® Server 2012 R2 and Windows® Server 2016 it will be "RemoteSigned".
Note:
· After exiting the script, you can review the log files.
Log files
The script creates the following two
log files. Please find the related log files in the same folder as the script. Every
time the script starts, the log files will be extended.
The log files give an overview about the commands that were run, and offer a
control mechanism to review the results.
1. ManageSway.log
This log file collects the actions
that has been taken, and lists the results.
The entries are created by the script code, so you can review the related parts
in the script code.
2. Transcript.log
This log file collects a transcript of
the console content.
It gives additional information about environment conditions, and all
interactions within the Microsoft® Windows® PowerShell window.
How does the script work?
Here you can find detailed information about what the script does. You can also review the script code to get a better understanding of how it works. If you're familiar with Microsoft® Windows® PowerShell, you can modify or extend the script to meet your needs.
For some options in the script menu, you need to authenticate with your Microsoft® Office 365 global admin account first.
1. Define your login credentials
These commands feed the variable $MyCredential with your administrator credentials. You can use any name for the variables instead of $MyCredential and $MyOffice365GlobalAdmin here. You have to replace the username (<admin>) and domain name (<domain>) with your related data.
PS C:\> $MyOffice365GlobalAdmin = "<admin>@<domain>.onmicrosoft.com"
PS C:\> $MyCredentials = Get-Credential $MyOffice365GlobalAdmin
As result, a "Windows® PowerShell credential request" dialog will appear, and you have to enter your password.
2. Connect to your Microsoft® Office 365
PS C:\> Connect-MsolService -Credential $MyCredentials
If you see any connection error here, please check this knowledgebase article:
http://go.microsoft.com/fwlink/p/?LinkId=532377
3. Find your account SKU IDs
PS C:\> Get-MsolAccountSku
The resulting output looks like this:
AccountSku Id ActiveUnits WarningUnits ConsumedUnits
------------- ----------- ------------ -------------
Sample:ENTERPRISEPREMIUM 365 0 16
Example:ENTERPRISEPACK 16 0 3
4. Disable Sway
4.1. Disable a service for all users
The following command is not part of
the script code; but demonstrates how to disable a service like Sway for all
users.
Please keep in mind that this code disable the service Sway, but enables all
other services:
PS C:\> Get-MsolUser –All | Set-MsolUserLicense -LicenseOptions (New-MsolLicenseOptions -AccountSkuId "<Sample:ENTERPRISEPREMIUM>" -DisabledPlans "SWAY")
The following script code is implemented in the script, and filter the license before it disables a service, so only the unique service will be disabled. Therefore, running this script code will not enable any other service:
PS
C:\> Get-MsolUser
-All | Where-Object {$_.IsLicensed -Eq $True} | % {
>> $Private:UPN = $_.UserPrincipalName
>> $Private:UserLicenses = $_.Licenses | Where-Object {$_.AccountSkuId -Eq “<Sample:ENTERPRISEPREMIUM>"}
>> $Private:DisabledPlans = @()
>> $Private:DisabledPlans += $Private:UserLicenses.ServiceStatus | Where-Object {$_.ProvisioningStatus -Eq "Disabled"} | % {$_.ServicePlan.ServiceName
>> $Private:DisabledPlans += "SWAY"
>> $Private:LicenseOptions = New-MsolLicenseOptions -AccountSkuId "<Sample:ENTERPRISEPREMIUM>" -DisabledPlans $Private:DisabledPlans
>> Set-MsolUserLicense -UserPrincipalName $Private:UPN -LicenseOptions $Private:LicenseOptions}
Note:
· You have to replace the account SKU ID (<Sample:ENTERPRISEPREMIUM>) with your related data.
· Instead of "SWAY" you can also type any other service plan name. If you'd like to disable more than one service plan, you'd have to type "SWAY", "SHAREPOINTWAC", "SHAREPOINTENTERPRISE" for example.
· Check step 6 to see the service plan names you could use.
4.2. Disable a service for a single user
The following command is not part of the script code; but demonstrates how to disable a service for a single user:
PS C:\> Set-MsolUserLicense -UserPrincipalName "<user-x>@<domain>.onmicrosoft.com" -LicenseOptions (New-MsolLicenseOptions -AccountSkuId "<Sample:ENTERPRISEPREMIUM>" -DisabledPlans "SWAY")
The following script code is implemented in the script, and filter the license before it disables a service like Sway for a single user:
PS
C:\> $Private:User
= Get-MsolUser -UserPrincipalName "<user-x>@<domain>.onmicrosoft.com"
>> $Private:UserLicenses
= $Private:User.Licenses | Where-Object {$_.AccountSkuId -Eq "<Sample:ENTERPRISEPREMIUM>"}
>> $Private:DisabledPlans
= @()
>> $Private:DisabledPlans
+= $Private:UserLicenses.ServiceStatus | Where-Object {$_.ProvisioningStatus -Eq "Disabled"} | % {$_.ServicePlan.ServiceName}
>> $Private:DisabledPlans
+= "SWAY"
>> $Private:LicenseOptions = New-MsolLicenseOptions -AccountSkuId "<Sample:ENTERPRISEPREMIUM>" -DisabledPlans $Private:DisabledPlans
>> Set-MsolUserLicense -UserPrincipalName "<user-x>@<domain>.onmicrosoft.com" -LicenseOptions $Private:LicenseOptions
Note:
· You have to replace the account SKU ID (<Sample:ENTERPRISEPREMIUM>), username (<user-x>), and domain name (<domain>) with your related data.
· Instead of "SWAY" you can type any other service plan name. If you'd like to disable more than one service plan, you'd have to type "SWAY", "SHAREPOINTWAC", "SHAREPOINTENTERPRISE" for example.
· Check step 6 to see the service plan names you could use.
5. Enable Sway
5.1. Enable all services for all users
PS C:\> Get-MsolUser –All | Set-MsolUserLicense -LicenseOptions (New-MsolLicenseOptions -AccountSkuId "<Sample:ENTERPRISEPREMIUM>" -DisabledPlans $Null)
Note:
· You can’t enable a single service for all users. You can only enable all services for all users.
PS C:\> Set-MsolUserLicense -UserPrincipalName "<user-x>@<domain>.onmicrosoft.com" -LicenseOptions (New-MsolLicenseOptions -AccountSkuId "<Sample:ENTERPRISEPREMIUM>" -DisabledPlans $Null)
6. Verify if the script code worked
PS C:\> (Get-MsolUser -UserPrincipalName "<user-x>@<domain>.onmicrosoft.com").Licenses.ServiceStatus
As result, you should see output were the provisioning status for SWAY is shown as "Disabled" (or "Success" if enabled).
ServicePlan ProvisioningStatus
----------- ------------------
EQUIVIO_ANALYTICS Success
LOCKBOX_ENTERPRISE Success
EXCHANGE-ANALYTICS Success
SWAY Disabled
ATP_ENTERPRISE PendingActivation
MCOEV Success
MCOMEETADV Success
BI_AZURE_P2 PendingInput
INTUNE_O365 PendingActivation
PROJECTWORKMANAGEMENT Success
RMS_S_ENTERPRISE Success
YAMMER_ENTERPRISE Success
OFFICESUBSCRIPTION Success
MCOSTANDARD Success
EXCHANGE_S_ENTERPRISE Success
SHAREPOINTENTERPRISE Success
SHAREPOINTWAC Success
Note:
· You can’t enable a single service for a user. You can only enable all services for a user.
Copyright® 2017 by Microsoft®. All rights reserved.