← script library

Simplify Cloud Services Management in Microsoft 365 with PowerShell

Microsoft 365 & Entra IDDecember 24, 2024

In this post, we will share a PowerShell script designed to simplify the management of cloud services in Microsoft 365. Effectively managing cloud services is essential for ensuring that your organization's resources are utilized efficiently and securely. This script allows administrators to quickly gather information about active services, enable or disable them, and monitor their status, streamlining the management process. Here is the PowerShell script for managing Microsoft 365 cloud services:

powershell
# Connect to Microsoft 365
$credential = Get-Credential
Connect-MsolService -Credential $credential
# Retrieve all users and their assigned cloud service licenses
$users = Get-MsolUser -All | Select-Object DisplayName, UserPrincipalName, Licenses
# Display cloud services information
foreach ($user in $users) {
    Write-Host "User: $($user.DisplayName) - Email: $($user.UserPrincipalName)"
    foreach ($license in $user.Licenses) {
        Write-Host "  License: $($license.AccountSkuId)"
    }
}
# Example: Disable a specific service for a user
$userToDisable = "[email protected]"
$serviceToDisable = "Office 365 Enterprise E3"
Set-MsolUserLicense -UserPrincipalName $userToDisable -RemoveLicenses $serviceToDisable
Write-Host "Service $serviceToDisable has been disabled for user $userToDisable."

Run it across your fleet

This script runs as-is on a single host. Paste it into ServerEngine to schedule it, run it on a whole server group in parallel, and keep the credentials out of the file — see the scripts documentation and the credential store.

Ready when you are.

Try ServerEngine free for 7 days.