Azure Automation: PSGallery Version Check
Hi All,
I don't check daily if there are any new PowerShell modules in PSGallery.
So i wrote me a Script of my most used Modules to Inform me if there are any new Modules available.
With the following Code i check for the current Version of the Modules and put them into a PSCustomObject with the Attributes Release, Module, Version (for GA and Prerelease Versions).
###############################################################################
# Check PSGallery Modules
###############################################################################
#Create Empty Array
$MyArray = @()
$Modules = @("AZ","MSOnline", "AzureADPreview", "ExchangeOnlineManagement", "Icewolf.EXO.SpamAnalyze", "MicrosoftTeams", "Microsoft.Online.SharePoint.PowerShell","PnP.PowerShell" , "ORCA", "O365CentralizedAddInDeployment", "MSCommerce", "WhiteboardAdmin", "Microsoft.Graph", "MSAL.PS", "MSIdentityTools" )
foreach ($Module in $Modules)
{
#Check GA Version
$Result = Find-Module -Name $Module
$Version = $Result.Version
Write-Output "GA: $Module $Version"
#Create Custom Object to Store Information
$myObject = [PSCustomObject]@{
Release = 'GA'
Module = $Module
Version = $Version
}
#Add to Array
$MyArray += $myObject
#Check PreRelease Version
$Result = Find-Module -Name $Module -AllowPrerelease
$Version = $Result.Version
Write-Output "PreRelease: $Module $Version"
#Create Custom Object to Store Information
$myObject = [PSCustomObject]@{
Release = 'PreRelease'
Module = $Module
Version = $Version
}
#Add to Array
$MyArray += $myObject
}
# Check PSGallery Modules
###############################################################################
#Create Empty Array
$MyArray = @()
$Modules = @("AZ","MSOnline", "AzureADPreview", "ExchangeOnlineManagement", "Icewolf.EXO.SpamAnalyze", "MicrosoftTeams", "Microsoft.Online.SharePoint.PowerShell","PnP.PowerShell" , "ORCA", "O365CentralizedAddInDeployment", "MSCommerce", "WhiteboardAdmin", "Microsoft.Graph", "MSAL.PS", "MSIdentityTools" )
foreach ($Module in $Modules)
{
#Check GA Version
$Result = Find-Module -Name $Module
$Version = $Result.Version
Write-Output "GA: $Module $Version"
#Create Custom Object to Store Information
$myObject = [PSCustomObject]@{
Release = 'GA'
Module = $Module
Version = $Version
}
#Add to Array
$MyArray += $myObject
#Check PreRelease Version
$Result = Find-Module -Name $Module -AllowPrerelease
$Version = $Result.Version
Write-Output "PreRelease: $Module $Version"
#Create Custom Object to Store Information
$myObject = [PSCustomObject]@{
Release = 'PreRelease'
Module = $Module
Version = $Version
}
#Add to Array
$MyArray += $myObject
}
I have saved this PSCustomObject into a CSV
$MyArray | Export-CSV -Path $DestinationFile -encoding UTF8 -NoTypeInformation
If i import the CSV i can compare the two Versions
$CSV = Import-CSV -Path $PathToCSV
$Compare = Compare-Object -ReferenceObject $MyArray -DifferenceObject $CSV -Property Release,Module,Version
$Compare
$Compare
I did write me a Azure Automate PowerShell 7 Script to run daily and send me a Mail
The Script is published at my GitHub Repo https://github.com/BohrenAn/GitHub_PowerShellScripts/blob/main/CheckPSModules.ps1
And these are the Mails i receive
Regards
Andres Bohren