Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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

Code Block
languagepowershell
Find-PackageProvider -Name NuGet -Force -ForceBootstrap

Run the following commands to define the name of the PowerShell module and any prerequisite modules:

Code Block
languagepowershell
$Name = 'Microsoft.Graph'
$PrerequisiteModuleNames = 'Microsoft.Graph.Authentication'

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

Code Block
languagepowershell
$Modules, $PrerequisiteModules = (Get-Module -Name "$Name.*").Where({$_.Name -notin $PrerequisiteModuleNames},[System.Management.Automation.WhereOperatorSelectionMode]::Split)

Run the following commands to unload the Azure PowerShell modules respecting the dependency on the Az.Accounts module:

Code Block
languagepowershell
$Modules | ForEach-Object { Remove-Module -Name $_.Name -Force }; $PrerequisiteModules | 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 Azure PowerShell modules from the PSGallery: 

  • To update the modules:

    Code Block
    languagepowershell
    Get-Module -ListAvailable -Name "$Name.*" | ForEach-Object { Update-Module -Name $_.Name } 
  • To install or reinstall the modules:

    Code Block
    Save-Module -Path "$env:ProgramFiles\WindowsPowerShell\Modules" -Name $Name -Force