@@ -13,7 +13,7 @@ param (
13
13
<#
14
14
/!\/!\/!\ PLEASE READ /!\/!\/!\
15
15
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:
17
17
/!\ Update-Module [-Verbose]
18
18
19
19
/!\ This script is intended as a replacement of the Update-Module:
@@ -100,8 +100,12 @@ foreach ($module in $modules.Name) {
100
100
Write-Warning " $module not found in the PowerShell Gallery. $ ( $_.Exception.Message ) "
101
101
}
102
102
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
+
103
107
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 "
105
109
106
110
if (-not ($SimulationMode )) {
107
111
try {
@@ -113,7 +117,7 @@ foreach ($module in $modules.Name) {
113
117
}
114
118
}
115
119
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 "
117
121
}
118
122
elseif ($currentVersion.count -gt 1 ) {
119
123
Write-Host - ForegroundColor Yellow " $module is installed in $ ( $currentVersion.count ) versions (versions: $ ( $currentVersion -join ' | ' ) )"
@@ -125,7 +129,8 @@ foreach ($module in $modules.Name) {
125
129
$currentVersion = (Get-InstalledModule - Name $module ).Version
126
130
127
131
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
+
129
134
if (-not ($SimulationMode )) {
130
135
try {
131
136
Install-Module - Name $module - Force - ErrorAction Stop
@@ -140,12 +145,12 @@ foreach ($module in $modules.Name) {
140
145
}
141
146
# https://invoke-thebrain.com/2018/12/comparing-version-numbers-powershell/
142
147
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."
144
149
}
145
150
elseif ([version ]$currentVersion -lt [version ]$moduleGalleryInfo.Version ) {
146
151
Write-Host - ForegroundColor Cyan " $module - Update from PowerShellGallery version " - NoNewline
147
152
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 "
149
154
150
155
if (-not ($SimulationMode )) {
151
156
try {
@@ -158,7 +163,7 @@ foreach ($module in $modules.Name) {
158
163
159
164
if ($SkipPublisherCheck.IsPresent ) {
160
165
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 "
162
167
try {
163
168
Install-Module - Name $module - Force - SkipPublisherCheck
164
169
}
0 commit comments