Explore the serene beauty of Lenvik, Norway's lush valleys and charming village from above.

Refreshing Microsoft Graph Modules in PowerShell

Introduction

This demonstrates how to completely remove and reinstall the Microsoft Graph modules. This can be helpful when troubleshooting issues with the modules or ensuring you have the latest versions installed.

Use Case

This script is useful for:

  • Troubleshooting: Resolving issues caused by outdated or corrupted Microsoft Graph modules.
  • Updating Modules: Ensuring you have the latest versions of the Microsoft Graph modules installed.
  • Clean Installation: Starting with a fresh installation of the modules to avoid conflicts.

Script

PowerShell

# Force remove any existing sessions
Get-PSSession | Remove-PSSession

# Remove the modules from the current session
Remove-Module Microsoft.Graph.Intune -Force -ErrorAction SilentlyContinue
Remove-Module Microsoft.Graph -Force -ErrorAction SilentlyContinue

# Now uninstall them completely
Uninstall-Module Microsoft.Graph.Intune -AllVersions -Force
Uninstall-Module Microsoft.Graph -AllVersions -Force

# Install fresh
Install-Module Microsoft.Graph -Force -Verbose 

Explanation

  • Remove Existing Sessions: The script starts by removing any existing PowerShell sessions that might be using the Microsoft Graph modules.
  • Remove Modules: It then removes the Microsoft.Graph.Intune and Microsoft.Graph modules from the current PowerShell session.
  • Uninstall Modules: The script uninstalls all versions of the Microsoft.Graph.Intune and Microsoft.Graph modules.
  • Install Microsoft Graph: Finally, it installs the latest version of the Microsoft.Graph module.

Outro

This script provides a quick and easy way to refresh your Microsoft Graph modules in PowerShell. This can be a helpful first step when encountering issues with Microsoft Graph or when you need to ensure you have the latest functionality.

Tags

PowerShell, Microsoft Graph, Modules, Installation, Uninstallation, Troubleshooting, Refresh, Update

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

WordPress Cookie Plugin by Real Cookie Banner