Run the following commands to verify the NuGet provider is installed:

Find-PackageProvider -Name NuGet -Force -ForceBootstrap

Run the following commands to define the name of the PowerShell module or collection and the names of any dependent modules in the collection:

$PowerShellModuleName = 'Microsoft.Graph'
$DependentModuleNames = 'Microsoft.Graph.Authentication'

Run the following commands to define the Graph PowerShell modules respecting the dependency on the Microsoft.Graph.Authentication module:

$Modules, $DependentModules = (Get-Module -Name "$PowerShellModuleName.*").Where({$_.Name -notin $DependentModuleNames},[System.Management.Automation.WhereOperatorSelectionMode]::Split)

Run the following commands to unload the Graph PowerShell modules respecting the dependency on the Microsoft.Graph.Authentication module:

$Modules | ForEach-Object { Remove-Module -Name $_.Name -Force }; $DependentModules | ForEach-Object { Remove-Module -Name $_.Name -Force }

Run the code blocks in one of the following sections to update or install the latest version of the Graph PowerShell modules from the PSGallery: