← script library

Simplifying Cloud Services Management with PowerShell

Software DeploymentDecember 23, 2024

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:

powershell
# 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."

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.