@@ -52,7 +52,9 @@ function Remove-OldPowerShellModules {
52
52
$oldVersions = Get-InstalledModule - Name $ModuleName - AllVersions - ErrorAction Stop | Where-Object { $_.Version -ne $GalleryVersion }
53
53
54
54
foreach ($oldVersion in $oldVersions ) {
55
- Write-Host - ForegroundColor Cyan " $ModuleName - Uninstall previous version ($ ( $oldVersion.Version ) )"
55
+ Write-Host - ForegroundColor Cyan " $ModuleName - Uninstall previous version" - NoNewline
56
+ Write-Host - ForegroundColor White " ($ ( $oldVersion.Version ) )"
57
+
56
58
if (-not ($SimulationMode )) {
57
59
Remove-Module $ModuleName - ErrorAction SilentlyContinue
58
60
Uninstall-Module $oldVersion - Force - ErrorAction Stop
@@ -66,7 +68,7 @@ function Remove-OldPowerShellModules {
66
68
67
69
if ($IncludedModules ) {
68
70
Write-Host - ForegroundColor Cyan " Get PowerShell modules like $IncludedModules "
69
- $modules = Get-InstalledModule | Where-Object { $_.Name -like $IncludedModules }
71
+ $modules = Get-InstalledModule | Where-Object { $_.Name -like $IncludedModules }
70
72
}
71
73
else {
72
74
Write-Host - ForegroundColor Cyan ' Get all PowerShell modules'
@@ -131,19 +133,27 @@ foreach ($module in $modules.Name) {
131
133
}
132
134
}
133
135
elseif ($moduleGalleryInfo.Version -eq $currentVersion ) {
134
- Write-Host - ForegroundColor Green " $module already in latest version: $currentVersion - Release date: $publishedDate "
136
+ Write-Host - ForegroundColor Green " $module - already in latest version: " - NoNewline
137
+ Write-Host - ForegroundColor White " $currentVersion " - NoNewline
138
+ Write-Host - ForegroundColor Green " - Release date:" - NoNewline
139
+ Write-Host - ForegroundColor White " $publishedDate "
135
140
}
136
141
elseif ($currentVersion.count -gt 1 ) {
137
- Write-Host - ForegroundColor Yellow " $module is installed in $ ( $currentVersion.count ) versions (versions: $ ( $currentVersion -join ' | ' ) )"
138
- Write-Host - ForegroundColor Cyan " $module - Uninstall previous $module version(s) below the latest version ($ ( $moduleGalleryInfo.Version ) )"
142
+ Write-Host - ForegroundColor Yellow " $module is installed in $ ( $currentVersion.count ) versions:" - NoNewline
143
+ Write-Host - ForegroundColor White " $ ( $currentVersion -join ' | ' ) "
144
+ Write-Host - ForegroundColor Cyan " $module - Uninstall previous $module version(s) below the latest version" - NoNewline
145
+ Write-Host - ForegroundColor White " ($ ( $moduleGalleryInfo.Version ) )"
139
146
140
147
Remove-OldPowerShellModules - ModuleName $module - GalleryVersion $moduleGalleryInfo.Version
141
148
142
149
# Check again the current Version as we uninstalled some old versions
143
150
$currentVersion = (Get-InstalledModule - Name $module ).Version
144
151
145
152
if ($moduleGalleryVersion -ne $currentVersion ) {
146
- Write-Host - ForegroundColor Cyan " $module - Install from PowerShellGallery version $ ( $moduleGalleryInfo.Version ) - Release date: $publishedDate "
153
+ Write-Host - ForegroundColor Cyan " $module - Install from PowerShellGallery version" - NoNewline
154
+ Write-Host - ForegroundColor White " $ ( $moduleGalleryInfo.Version ) " - NoNewline
155
+ Write-Host - ForegroundColor Cyan " - Release date:" - NoNewline
156
+ Write-Host - ForegroundColor White " $publishedDate "
147
157
148
158
if (-not ($SimulationMode )) {
149
159
try {
@@ -162,9 +172,10 @@ foreach ($module in $modules.Name) {
162
172
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."
163
173
}
164
174
elseif ([version ]$currentVersion -lt [version ]$moduleGalleryVersion ) {
165
- Write-Host - ForegroundColor Cyan " $module - Update from PowerShellGallery version " - NoNewline
166
- Write-Host - ForegroundColor White " $currentVersion -> $ ( $moduleGalleryInfo.Version ) " - NoNewline
167
- Write-Host - ForegroundColor Cyan " - Release date: $publishedDate "
175
+ Write-Host - ForegroundColor Cyan " $module - Update from PowerShellGallery version" - NoNewline
176
+ Write-Host - ForegroundColor White " $currentVersion -> $ ( $moduleGalleryInfo.Version ) " - NoNewline
177
+ Write-Host - ForegroundColor Cyan " - Release date:" - NoNewline
178
+ Write-Host - ForegroundColor White " $publishedDate "
168
179
169
180
if (-not ($SimulationMode )) {
170
181
try {
0 commit comments