Simplify Cloud Services Management in Microsoft 365 with PowerShell
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:
# 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.
More in Microsoft 365 & Entra ID
Automate M365 User License Assignment with PowerShell
2025-01-09Manage M365 Users with PowerShell
2025-01-09Automate Microsoft 365 User License Management with PowerShell
2025-01-09Streamlining M365 User Management with PowerShell
2025-01-09PowerShell Script to Retrieve M365 User License Info
2025-01-09Automate Microsoft 365 User Report Generation with PowerShell
2025-01-09Ready when you are.
Try ServerEngine free for 7 days.