次の方法で共有


Disable or Enable PowerApps, Flows, and Dynamics 365 Tiles from the App Launcher in Office 365

Here is a sample script that should allow you to enable/disable PowerApps, Flow and the Dynamics 365 Tiles for all users in a tenant by enabling/disabling certain service plans within your enterprise pack.

Before

clip_image002

After

clip_image004

First you need to find the appropriate AccountSKUIds

Connect-MsolService
Get-MsolAccountSku post1

Second, find the available service plans

Get-MsolAccountSku | select -ExpandProperty ServiceStatus post2

Third, Copy/Paste the following PowerShell script. Please supply your values for the Global Admin $user, $Password, $ServicePlans and $AccountSkuId.

#Please install the SharePoint client components SDK - https://www.microsoft.com/en-us/download/details.aspx?id=35585 prior to running this script.
<#Disclaimer:
This Sample Code, scripts or any related information are provided for the purpose of illustration only and is not intended to be used in a production environment.
THIS SAMPLE CODE AND ANY RELATED INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND/OR FITNESS FOR A PARTICULAR PURPOSE. We grant You a nonexclusive, royalty-free right to use and modify the Sample Code and to reproduce and distribute the object code form of the Sample Code,
provided that You agree: (i) to not use Our name, logo, or trademarks to market Your software product in which the Sample Code is embedded; (ii) to include a valid copyright notice on Your software
product in which the Sample Code is embedded; and (iii) to indemnify, hold harmless, and defend Us and Our suppliers from and against any claims or lawsuits, including attorneys’ fees,
that arise or result from the use or distribution of the Sample Code.#>
#Author:Sammy Kailini, Sammyk@microsoft.com | SammyKailini@live.com

Import-Module MsOnline
#Configure Site URL and User
$User = "admin@Tenant.onmicrosoft.com"
$Password = "Password" | ConvertTo-SecureString -AsPlainText -Force #its not recommended to save passwords inside scripts, please save passwords encrypted in a separate file instead.
#Service Plans to Disable
$ServicePlans = "FLOW_O365_P3","POWERAPPS_O365_P3"
$AccountSkuId = "Tenant:ENTERPRISEPREMIUM"
#Configure Report Path
$ReportPath = "c:\Error_Report.csv"
#---------------------Nothing needs editing below this line-------------------------------------------------
If (Test-Path $ReportPath){
Remove-Item $ReportPath
}
#Write Output Report CSV File Headers
"User, Error Message" | out-file $ReportPath -Encoding ascii -Append
#Add references to SharePoint client assemblies and authenticate to Office 365 site - required for CSOM
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.UserProfiles")
#Connect to SPO
$PSCreds = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User,$password
Connect-MsolService -Credential $PSCreds
$LO = New-MsolLicenseOptions -AccountSkuId $AccountSkuId -DisabledPlans $ServicePlans
Write-Host
Write-Host "FYI: This could take a while :)" -ForegroundColor Cyan
[String]$licenses = $null
$users = get-msoluser -All | where {$_.islicensed -eq $true} | select userprincipalname,licenses
$progressCount = 0
foreach($usr in $Users)
{
$progressCount++
Write-Host processing $progressCount out of $users.Count -ForegroundColor Cyan -NoNewline
$output += $usr.UserPrincipalName+","
Try
{
Set-MsolUserLicense -UserPrincipalName $usr.UserPrincipalName -LicenseOptions $LO -Verbose
Write-Host " Success, updated user" $usr.UserPrincipalName -ForegroundColor Green
}
Catch
{
$ErrorMessage = $_.Exception.Message
$output += $ErrorMessage
$ErrorMessage
}
}
$output | Out-File $ReportPath -Encoding ascii -Force -Append
Write-Host "Done!!" -ForegroundColor White -BackgroundColor DarkCyan

Happy SharePointing :)

SammyK