Skip to content

Commit 4287560

Browse files
committed
Change release date format
1 parent bf1c3b5 commit 4287560

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

Update-AllPowerShellModules.ps1

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ param (
1313
<#
1414
/!\/!\/!\ PLEASE READ /!\/!\/!\
1515
16-
/!\ If you look for a quick way to update, please keep in mind Microsoft has a built-in CMDlzt to update ALL the PowerShell modules installed:
16+
/!\ If you look for a quick way to update, please keep in mind Microsoft has a built-in CMDlet to update ALL the PowerShell modules installed:
1717
/!\ Update-Module [-Verbose]
1818
1919
/!\ This script is intended as a replacement of the Update-Module:
@@ -100,8 +100,12 @@ foreach ($module in $modules.Name) {
100100
Write-Warning "$module not found in the PowerShell Gallery. $($_.Exception.Message)"
101101
}
102102

103+
# Convert published date to YYYY/MM/DD HH:MM:SS format
104+
$publishedDate = [datetime]$moduleGalleryInfo.PublishedDate
105+
$publishedDate = $publishedDate.ToString("yyyy/MM/dd HH:mm:ss")
106+
103107
if ($null -eq $currentVersion) {
104-
Write-Host -ForegroundColor Cyan "$module - Install from PowerShellGallery version $($moduleGalleryInfo.Version) - Release date: $($moduleGalleryInfo.PublishedDate)"
108+
Write-Host -ForegroundColor Cyan "$module - Install from PowerShellGallery version $($moduleGalleryInfo.Version) - Release date: $publishedDate"
105109

106110
if (-not($SimulationMode)) {
107111
try {
@@ -113,7 +117,7 @@ foreach ($module in $modules.Name) {
113117
}
114118
}
115119
elseif ($moduleGalleryInfo.Version -eq $currentVersion) {
116-
Write-Host -ForegroundColor Green "$module already in latest version: $currentVersion - Release date: $($moduleGalleryInfo.PublishedDate)"
120+
Write-Host -ForegroundColor Green "$module already in latest version: $currentVersion - Release date: $publishedDate"
117121
}
118122
elseif ($currentVersion.count -gt 1) {
119123
Write-Host -ForegroundColor Yellow "$module is installed in $($currentVersion.count) versions (versions: $($currentVersion -join ' | '))"
@@ -125,7 +129,8 @@ foreach ($module in $modules.Name) {
125129
$currentVersion = (Get-InstalledModule -Name $module).Version
126130

127131
if ($moduleGalleryInfo.Version -ne $currentVersion) {
128-
Write-Host -ForegroundColor Cyan "$module - Install from PowerShellGallery version $($moduleGalleryInfo.Version) - Release date: $($moduleGalleryInfo.PublishedDate)"
132+
Write-Host -ForegroundColor Cyan "$module - Install from PowerShellGallery version $($moduleGalleryInfo.Version) - Release date: $publishedDate"
133+
129134
if (-not($SimulationMode)) {
130135
try {
131136
Install-Module -Name $module -Force -ErrorAction Stop
@@ -140,12 +145,12 @@ foreach ($module in $modules.Name) {
140145
}
141146
# https://invoke-thebrain.com/2018/12/comparing-version-numbers-powershell/
142147
elseif ([version]$currentVersion -gt [version]$moduleGalleryInfo.Version) {
143-
Write-Host -ForegroundColor Yellow "$module - the current version $currentVersion is newer than the version available on PowerShell Gallery $($moduleGalleryInfo.Version) (Release date: $($moduleGalleryInfo.PublishedDate)). Sometimes happens when you install a module from another repository or via .exe/.msi or if you change the version number manually."
148+
Write-Host -ForegroundColor Yellow "$module - the current version $currentVersion is newer than the version available on PowerShell Gallery $($moduleGalleryInfo.Version) (Release date: $publishedDate). Sometimes happens when you install a module from another repository or via .exe/.msi or if you change the version number manually."
144149
}
145150
elseif ([version]$currentVersion -lt [version]$moduleGalleryInfo.Version) {
146151
Write-Host -ForegroundColor Cyan "$module - Update from PowerShellGallery version " -NoNewline
147152
Write-Host -ForegroundColor White "$currentVersion -> $($moduleGalleryInfo.Version) " -NoNewline
148-
Write-Host -ForegroundColor Cyan "- Release date: $($moduleGalleryInfo.PublishedDate)"
153+
Write-Host -ForegroundColor Cyan "- Release date: $publishedDate"
149154

150155
if (-not($SimulationMode)) {
151156
try {
@@ -158,7 +163,7 @@ foreach ($module in $modules.Name) {
158163

159164
if ($SkipPublisherCheck.IsPresent) {
160165
Write-Host -ForegroundColor Cyan "$module - SkipPublisherCheck Parameter is present, so install will run without Authenticode check"
161-
Write-Host -ForegroundColor Cyan "$module - Install from PowerShellGallery version $($moduleGalleryInfo.Version) - Release date: $($moduleGalleryInfo.PublishedDate)"
166+
Write-Host -ForegroundColor Cyan "$module - Install from PowerShellGallery version $($moduleGalleryInfo.Version) - Release date: $publishedDate"
162167
try {
163168
Install-Module -Name $module -Force -SkipPublisherCheck
164169
}

0 commit comments

Comments
 (0)