-
Notifications
You must be signed in to change notification settings - Fork 243
Update all Microsoft Cloud PowerShell modules
directorcia edited this page Jan 8, 2025
·
2 revisions
# PowerShell Script Overview
This PowerShell script ensures the system's necessary modules are up-to-date. Here's a breakdown of its functionality:
## Initialize Counter
- `$counter = 0`: Initializes a counter to keep track of the number of operations performed.
## Check for Administrator Privileges
```powershell
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
- The script checks if it is running with administrator privileges using the current Windows user principal.
If ($currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))
- Executes the script only if it's running as an administrator.
if ($ps.Major -lt 7)
- Checks if the PowerShell version is less than 7.
- If true:
- Increments the counter.
- Updates the NuGet provider by calling
test-package -packagename NuGet
.
- Increments the counter.
- Updates the Azure AD module by calling
test-install -modulename AzureAD
.
- Increments the counter.
- Checks if the older Azure AD Rights Management module (
aadrm
) is installed.- If the module exists:
- Displays a warning message.
- Uninstalls the outdated
aadrm
module.
- If the module exists:
- Installs the Azure Information Protection service module by calling
test-install -modulename AIPService
.
- Increments the counter.
- Updates the Teams module by calling
test-install -modulename MicrosoftTeams
.
- Increments the counter.
- Updates the SharePoint Online module by calling
test-install -modulename Microsoft.Online.SharePoint.PowerShell
.
This script updates essential PowerShell modules (NuGet
, AzureAD
, AIPService
, MicrosoftTeams
, and Microsoft.Online.SharePoint.PowerShell
) if executed with administrator privileges. It also ensures that outdated modules (e.g., aadrm
) are removed.