Simplifying Cloud Services Management with PowerShell

Welcome to our helpful guide on PowerShell scripts designed to enhance your IT efficiency. Managing cloud services is essential for businesses adopting modern technology stacks. This script facilitates the management of Microsoft 365 licenses, allowing you to quickly assign or remove licenses for users in your organization, streamlining the operation of your cloud services.
Here is a sample PowerShell script for managing Microsoft 365 licenses:

# Connect to Microsoft 365
Connect-MgGraph -Scopes "User.ReadWrite.All", "Directory.ReadWrite.All"
# Define user and license details
$userId = "[email protected]"
$licenseSku = "yourtenant:ENTERPRISEPACK"
# Assign license to user
Set-MgUserLicense -UserId $userId -AddLicenses @($licenseSku)
Write-Host "License $licenseSku assigned to $userId successfully."
# Remove license if needed
# Set-MgUserLicense -UserId $userId -RemoveLicenses @($licenseSku)
# Write-Host "License $licenseSku removed from $userId successfully."