test-msGraphVersions.ps1
|
function test-msGraphVersions { out-logfile -string "Enterring test-msGraphVersions" $msGraphModuleName = "Microsoft.Graph.Authentication" $telmetryHelpderModuleName = "TelemetryHelper" $userInstallPath = "User" out-logfile -string "Proactively updating all installed graph powershell moddules." try { $module = get-installedModule -name $msGraphModuleName -erroraction stop } catch { out-logfile -string "Failed to get installed module information for $msGraphModuleName." out-logfile -string $_ -isError:$TRUE } if ($null -ne $module) { if ($module.InstalledLocation.contains($userInstallPath)) { out-logfile -string "The Microsoft.Graph.Authentication module is installed in the user scope." update-powershellModule -powershellModuleName $msGraphModuleName } else { out-logfile -string "The Microsoft.Graph.Authentication module is installed in the admin scope." } } else { out-logfile -string "The Microsoft.Graph.Authentication module is not installed." } update-powershellModule -powershellModuleName $telmetryHelpderModuleName $installedVersion = Test-PowershellModule -powershellModuleName $msGraphModuleName -getInstalledVersion $TRUE $galleryVersion = Test-PowershellModule -powershellModuleName $msGraphModuleName -getInstalledVersion $FALSE if ($galleryVersion -ne $installedVersion) { out-logfile -string "The installed version of the Microsoft.Graph.Authentication module is not the same as the gallery version." out-logfile -string ("Installed Version: "+$installedVersion) out-logfile -string ("Gallery Version: "+$galleryVersion) out-logfile -string "Updating to the latest version of the graph authentication module." } else { out-logfile -string "The installed version of the Microsoft.Graph.Authentication module is the same as the gallery version." out-logfile -string ("Installed Version: "+$installedVersion) out-logfile -string ("Gallery Version: "+$galleryVersion) } } |