Skip to content

Commit e3fa7e8

Browse files
author
Robin Stolpe
committed
updated verbose
1 parent 46be743 commit e3fa7e8

8 files changed

+247
-8
lines changed

.src/Public/Function/Uninstall-RSModule.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,5 +90,5 @@
9090
Write-Verbose "$($m) don't have any older versions installed then $($GetAllInstalledVersions), no need to uninstall anything."
9191
}
9292
}
93-
Write-Output "`n---/// Script Finished! ///---"
93+
Write-Output "`n=== \\\ Script Finished! /// ===`n"
9494
}

.src/Public/Function/Update-RSModule.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
[version]$LatestInstalledVersion = $($GetAllInstalledVersions | Select-Object Version -First 1).version
136136

137137
# Collects the latest version of module from the source where the module was installed from
138-
Write-Output "Looking up the latest version of $($m)..."
138+
Write-Verbose "Looking up the latest version of $($m)..."
139139
[version]$CollectLatestVersion = $(Find-Module -Name $m -AllVersions | Sort-Object { $_.Version -as [version] } -Descending | Select-Object Version -First 1).version
140140

141141
# Looking if the version of the module are the latest version, it it's not the latest it will install the latest version.
@@ -155,6 +155,7 @@
155155
# If switch -UninstallOldVersion has been used then the old versions will be uninstalled from the module
156156
if ($UninstallOldVersion -eq $true) {
157157
if ($GetAllInstalledVersions.Count -gt 1) {
158+
Write-Output "Uninstalling old versions $($LatestInstalledVersion) of $($m)..."
158159
Uninstall-RSModule -Module $m
159160
}
160161
}
@@ -206,5 +207,5 @@
206207
}
207208
}
208209
}
209-
Write-Output "`n---/// Script Finished! ///---"
210+
Write-Output "`n=== \\\ Script Finished! /// ===`n"
210211
}

MaintainModule/MaintainModule.psd1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#
2828
# Generated by: Robin Stolpe
2929
#
30-
# Generated on: 2023-01-18
30+
# Generated on: 2023-01-19
3131
#
3232

3333
@{
@@ -36,7 +36,7 @@
3636
RootModule = '.\MaintainModule.psm1'
3737

3838
# Version number of this module.
39-
ModuleVersion = '0.1.4'
39+
ModuleVersion = '0.1.5'
4040

4141
# Supported PSEditions
4242
# CompatiblePSEditions = @()

MaintainModule/MaintainModule.psm1

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ Function Uninstall-RSModule {
113113
Write-Verbose "$($m) don't have any older versions installed then $($GetAllInstalledVersions), no need to uninstall anything."
114114
}
115115
}
116-
Write-Output "`n---/// Script Finished! ///---"
116+
Write-Output "`n=== \\\ Script Finished! /// ===`n"
117117
}
118118
Function Update-RSModule {
119119
<#
@@ -252,7 +252,7 @@ Function Update-RSModule {
252252
[version]$LatestInstalledVersion = $($GetAllInstalledVersions | Select-Object Version -First 1).version
253253

254254
# Collects the latest version of module from the source where the module was installed from
255-
Write-Output "Looking up the latest version of $($m)..."
255+
Write-Verbose "Looking up the latest version of $($m)..."
256256
[version]$CollectLatestVersion = $(Find-Module -Name $m -AllVersions | Sort-Object { $_.Version -as [version] } -Descending | Select-Object Version -First 1).version
257257

258258
# Looking if the version of the module are the latest version, it it's not the latest it will install the latest version.
@@ -272,6 +272,7 @@ Function Update-RSModule {
272272
# If switch -UninstallOldVersion has been used then the old versions will be uninstalled from the module
273273
if ($UninstallOldVersion -eq $true) {
274274
if ($GetAllInstalledVersions.Count -gt 1) {
275+
Write-Output "Uninstalling old versions $($LatestInstalledVersion) of $($m)..."
275276
Uninstall-RSModule -Module $m
276277
}
277278
}
@@ -323,5 +324,5 @@ Function Update-RSModule {
323324
}
324325
}
325326
}
326-
Write-Output "`n---/// Script Finished! ///---"
327+
Write-Output "`n=== \\\ Script Finished! /// ===`n"
327328
}

help/Uninstall-RSModule.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
2+
NAME
3+
Uninstall-RSModule
4+
5+
SYNOPSIS
6+
Uninstall older versions of your modules in a easy way.
7+
8+
9+
SYNTAX
10+
Uninstall-RSModule [[-Module] <String[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
11+
12+
13+
DESCRIPTION
14+
This script let users uninstall older versions of the modules that are installed on the system.
15+
16+
17+
PARAMETERS
18+
-Module <String[]>
19+
Specify modules that you want to uninstall older versions from, if this is left empty all of the older versions of the systems modules will be uninstalled
20+
21+
Required? false
22+
Position? 1
23+
Default value
24+
Accept pipeline input? false
25+
Accept wildcard characters? false
26+
27+
-WhatIf [<SwitchParameter>]
28+
29+
Required? false
30+
Position? named
31+
Default value
32+
Accept pipeline input? false
33+
Accept wildcard characters? false
34+
35+
-Confirm [<SwitchParameter>]
36+
37+
Required? false
38+
Position? named
39+
Default value
40+
Accept pipeline input? false
41+
Accept wildcard characters? false
42+
43+
<CommonParameters>
44+
This cmdlet supports the common parameters: Verbose, Debug,
45+
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
46+
OutBuffer, PipelineVariable, and OutVariable. For more information, see
47+
about_CommonParameters (https://go.microsoft.com/fwlink/?LinkID=113216).
48+
49+
INPUTS
50+
51+
OUTPUTS
52+
53+
NOTES
54+
55+
56+
Author: Robin Stolpe
57+
Mail: robin@stolpe.io
58+
Twitter: https://twitter.com/rstolpes
59+
Linkedin: https://www.linkedin.com/in/rstolpe/
60+
Website/Blog: https://stolpe.io
61+
GitHub: https://github.com/rstolpe
62+
PSGallery: https://www.powershellgallery.com/profiles/rstolpe
63+
64+
-------------------------- EXAMPLE 1 --------------------------
65+
66+
PS > Uninstall-RSModule -Module "VMWare.PowerCLI"
67+
# This will uninstall all older versions of the module VMWare.PowerCLI system.
68+
69+
70+
71+
72+
73+
74+
-------------------------- EXAMPLE 2 --------------------------
75+
76+
PS > Uninstall-RSModule -Module "VMWare.PowerCLI", "ImportExcel"
77+
# This will uninstall all older versions of VMWare.PowerCLI and ImportExcel from the system.
78+
79+
80+
81+
82+
83+
84+
85+
RELATED LINKS
86+
https://github.com/rstolpe/MaintainModule/blob/main/README.md
87+
88+

help/Update-RSModule.md

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
2+
NAME
3+
Update-RSModule
4+
5+
SYNOPSIS
6+
This module let you maintain your installed modules in a easy way.
7+
8+
9+
SYNTAX
10+
Update-RSModule [[-Module] <String[]>] [[-Scope] <String>] [-ImportModule] [-UninstallOldVersion] [-InstallMissing] [-WhatIf] [-Confirm] [<CommonParameters>]
11+
12+
13+
DESCRIPTION
14+
This function let you update all of your installed modules and also uninstall the old versions to keep things clean.
15+
You can also specify module or modules that you want to update. It's also possible to install the module if it's missing and import the modules in the end of the script.
16+
17+
18+
PARAMETERS
19+
-Module <String[]>
20+
Specify the module or modules that you want to update, if you don't specify any module all installed modules are updated
21+
22+
Required? false
23+
Position? 1
24+
Default value
25+
Accept pipeline input? false
26+
Accept wildcard characters? false
27+
28+
-Scope <String>
29+
Need to specify scope of the installation/update for the module, either AllUsers or CurrentUser. Default is CurrentUser.
30+
If this parameter is empty it will use CurrentUser
31+
The parameter -Scope don't effect the uninstall-module function this is because of limitation from Microsoft.
32+
- Scope effect Install/update module function.
33+
34+
Required? false
35+
Position? 2
36+
Default value CurrentUser
37+
Accept pipeline input? false
38+
Accept wildcard characters? false
39+
40+
-ImportModule [<SwitchParameter>]
41+
If this switch are used the module will import all the modules that are specified in the Module parameter at the end of the script.
42+
This only works if you have specified modules in the Module parameter
43+
44+
Required? false
45+
Position? named
46+
Default value False
47+
Accept pipeline input? false
48+
Accept wildcard characters? false
49+
50+
-UninstallOldVersion [<SwitchParameter>]
51+
If this switch are used all of the old versions of your modules will get uninstalled and only the current version will be installed
52+
53+
Required? false
54+
Position? named
55+
Default value False
56+
Accept pipeline input? false
57+
Accept wildcard characters? false
58+
59+
-InstallMissing [<SwitchParameter>]
60+
If you use this switch and the modules that are specified in the Module parameter are not installed on the system they will be installed.
61+
62+
Required? false
63+
Position? named
64+
Default value False
65+
Accept pipeline input? false
66+
Accept wildcard characters? false
67+
68+
-WhatIf [<SwitchParameter>]
69+
70+
Required? false
71+
Position? named
72+
Default value
73+
Accept pipeline input? false
74+
Accept wildcard characters? false
75+
76+
-Confirm [<SwitchParameter>]
77+
78+
Required? false
79+
Position? named
80+
Default value
81+
Accept pipeline input? false
82+
Accept wildcard characters? false
83+
84+
<CommonParameters>
85+
This cmdlet supports the common parameters: Verbose, Debug,
86+
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
87+
OutBuffer, PipelineVariable, and OutVariable. For more information, see
88+
about_CommonParameters (https://go.microsoft.com/fwlink/?LinkID=113216).
89+
90+
INPUTS
91+
92+
OUTPUTS
93+
94+
NOTES
95+
96+
97+
Author: Robin Stolpe
98+
Mail: robin@stolpe.io
99+
Twitter: https://twitter.com/rstolpes
100+
Linkedin: https://www.linkedin.com/in/rstolpe/
101+
Website/Blog: https://stolpe.io
102+
GitHub: https://github.com/rstolpe
103+
PSGallery: https://www.powershellgallery.com/profiles/rstolpe
104+
105+
-------------------------- EXAMPLE 1 --------------------------
106+
107+
PS > Update-RSModule -Module "PowerCLI", "ImportExcel" -Scope CurrentUser
108+
# This will update the modules PowerCLI, ImportExcel for the current user
109+
110+
111+
112+
113+
114+
115+
-------------------------- EXAMPLE 2 --------------------------
116+
117+
PS > Update-RSModule -Module "PowerCLI", "ImportExcel" -UninstallOldVersion
118+
# This will update the modules PowerCLI, ImportExcel and delete all of the old versions that are installed of PowerCLI, ImportExcel.
119+
120+
121+
122+
123+
124+
125+
-------------------------- EXAMPLE 3 --------------------------
126+
127+
PS > Update-RSModule -Module "PowerCLI", "ImportExcel" -InstallMissing
128+
# This will install the modules PowerCLI and/or ImportExcel on the system if they are missing, if the modules are installed already they will only get updated.
129+
130+
131+
132+
133+
134+
135+
-------------------------- EXAMPLE 4 --------------------------
136+
137+
PS > Update-RSModule -Module "PowerCLI", "ImportExcel" -UninstallOldVersion -ImportModule
138+
# This will update the modules PowerCLI and ImportExcel and delete all of the old versions that are installed of PowerCLI and ImportExcel and then import the modules.
139+
140+
141+
142+
143+
144+
145+
146+
RELATED LINKS
147+
https://github.com/rstolpe/MaintainModule/blob/main/README.md
148+
149+
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)