Skip to content

Commit fc183c4

Browse files
author
Robin Stolpe
authored
Merge pull request #8 from rstolpe/dev
Dev
2 parents 74d592b + 7243bb9 commit fc183c4

10 files changed

Lines changed: 324 additions & 86 deletions

.src/MaintainModule.psd1.source

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<#
2-
Copyright (C) {{year}} Robin Stolpe.
2+
Copyright (C) {{year}} Robin Stolpe.
33
<https://stolpe.io>
44
This program is free software: you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -125,7 +125,7 @@
125125
ReleaseNotes = 'https://github.com/rstolpe/MaintainModule/releases'
126126

127127
# Prerelease string of this module
128-
Prerelease = '{{preReleaseTag}}'
128+
# Prerelease = '{{preReleaseTag}}'
129129

130130
# Flag to indicate whether the module requires explicit user acceptance for install/update/save
131131
RequireLicenseAcceptance = $false

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
Uninstall-RSModule -Module "VMWare.PowerCLI, ImportExcel"
1818
# This will uninstall all older versions of VMWare.PowerCLI and ImportExcel from the system.
1919
20-
.RELATED LINKS
20+
.LINK
2121
https://github.com/rstolpe/MaintainModule/blob/main/README.md
2222
2323
.NOTES

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Function Update-RSModule {
2-
<#
2+
<#
33
.SYNOPSIS
44
This module let you maintain your installed modules in a easy way.
55
@@ -13,7 +13,7 @@
1313
.PARAMETER Scope
1414
Need to specify scope of the installation/update for the module, either AllUsers or CurrentUser. Default is CurrentUser.
1515
If this parameter is empty it will use CurrentUser
16-
The parameter -Scope don't effect the uninstall-module function this is because of limitation from Microsoft.
16+
The parameter -Scope don't effect the uninstall-module function this is because of limitation from Microsoft.
1717
- Scope effect Install/update module function.
1818
1919
.PARAMETER ImportModule
@@ -42,7 +42,7 @@
4242
Update-RSModule -Module "PowerCLI, ImportExcel" -UninstallOldVersion -ImportModule
4343
# 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.
4444
45-
.RELATED LINKS
45+
.LINK
4646
https://github.com/rstolpe/MaintainModule/blob/main/README.md
4747
4848
.NOTES
@@ -58,8 +58,8 @@
5858
Param(
5959
[Parameter(Mandatory = $false, HelpMessage = "Enter module or modules (separated with ,) that you want to update, if you don't enter any all of the modules will be updated")]
6060
[string]$Module,
61-
[ValidateSet("CurrentUser", "AllUsers")]
62-
[Parameter(Mandatory = $true, HelpMessage = "Enter CurrentUser or AllUsers depending on what scope you want to change your modules")]
61+
[ValidateSet("CurrentUser", "AllUsers")]
62+
[Parameter(Mandatory = $false, HelpMessage = "Enter CurrentUser or AllUsers depending on what scope you want to change your modules")]
6363
[string]$Scope = "CurrentUser",
6464
[Parameter(Mandatory = $false, HelpMessage = "Import modules that has been entered in the module parameter at the end of this function")]
6565
[switch]$ImportModule = $false,
@@ -168,7 +168,7 @@
168168
# Collect all of the imported modules.
169169
Write-Verbose "Collecting all of the installed modules..."
170170
$ImportedModules = Get-Module | Select-Object Name, Version
171-
171+
172172
# Import module if it's not imported
173173
Write-Verbose "Starting to import the modules..."
174174
foreach ($m in $Module.Split()) {

Help/Uninstall-RSModule.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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+
Website: https://stolpe.io
59+
GitHub: https://github.com/rstolpe
60+
Twitter: https://twitter.com/rstolpes
61+
PSGallery: https://www.powershellgallery.com/profiles/rstolpe
62+
63+
-------------------------- EXAMPLE 1 --------------------------
64+
65+
PS > Uninstall-RSModule -Module "VMWare.PowerCLI"
66+
# This will uninstall all older versions of the module VMWare.PowerCLI system.
67+
68+
69+
70+
71+
72+
73+
-------------------------- EXAMPLE 2 --------------------------
74+
75+
PS > Uninstall-RSModule -Module "VMWare.PowerCLI, ImportExcel"
76+
# This will uninstall all older versions of VMWare.PowerCLI and ImportExcel from the system.
77+
78+
79+
80+
81+
82+
83+
84+
RELATED LINKS
85+
https://github.com/rstolpe/MaintainModule/blob/main/README.md
86+
87+

Help/Update-RSModule.md

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
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: @rstolpes
100+
Website: https://stolpe.io
101+
GitHub: https://github.com/rstolpe
102+
PSGallery: https://www.powershellgallery.com/profiles/rstolpe
103+
104+
-------------------------- EXAMPLE 1 --------------------------
105+
106+
PS > Update-RSModule -Module "PowerCLI, ImportExcel" -Scope CurrentUser
107+
# This will update the modules PowerCLI, ImportExcel for the current user
108+
109+
110+
111+
112+
113+
114+
-------------------------- EXAMPLE 2 --------------------------
115+
116+
PS > Update-RSModule -Module "PowerCLI, ImportExcel" -UninstallOldVersion
117+
# This will update the modules PowerCLI, ImportExcel and delete all of the old versions that are installed of PowerCLI, ImportExcel.
118+
119+
120+
121+
122+
123+
124+
-------------------------- EXAMPLE 3 --------------------------
125+
126+
PS > Update-RSModule -Module "PowerCLI, ImportExcel" -InstallMissing
127+
# 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.
128+
129+
130+
131+
132+
133+
134+
-------------------------- EXAMPLE 4 --------------------------
135+
136+
PS > Update-RSModule -Module "PowerCLI, ImportExcel" -UninstallOldVersion -ImportModule
137+
# 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.
138+
139+
140+
141+
142+
143+
144+
145+
RELATED LINKS
146+
https://github.com/rstolpe/MaintainModule/blob/main/README.md
147+
148+

MaintainModule/MaintainModule.psd1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<#
2-
Copyright (C) 2022 Robin Stolpe.
2+
Copyright (C) 2022 Robin Stolpe.
33
<https://stolpe.io>
44
This program is free software: you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -18,7 +18,7 @@
1818
#
1919
# Generated by: Robin Stolpe
2020
#
21-
# Generated on: 2022-11-27
21+
# Generated on: 2022-11-29
2222
#
2323

2424
@{
@@ -27,7 +27,7 @@
2727
RootModule = '.\MaintainModule.psm1'
2828

2929
# Version number of this module.
30-
ModuleVersion = '0.0.8'
30+
ModuleVersion = '1.0.0'
3131

3232
# Supported PSEditions
3333
# CompatiblePSEditions = @()
@@ -125,7 +125,7 @@
125125
ReleaseNotes = 'https://github.com/rstolpe/MaintainModule/releases'
126126

127127
# Prerelease string of this module
128-
Prerelease = 'beta'
128+
# Prerelease = ''
129129

130130
# Flag to indicate whether the module requires explicit user acceptance for install/update/save
131131
RequireLicenseAcceptance = $false

MaintainModule/MaintainModule.psm1

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Function Uninstall-RSModule {
3333
Uninstall-RSModule -Module "VMWare.PowerCLI, ImportExcel"
3434
# This will uninstall all older versions of VMWare.PowerCLI and ImportExcel from the system.
3535
36-
.RELATED LINKS
36+
.LINK
3737
https://github.com/rstolpe/MaintainModule/blob/main/README.md
3838
3939
.NOTES
@@ -97,7 +97,7 @@ Function Uninstall-RSModule {
9797
Write-Output "`n---/// Script Finished! ///---"
9898
}
9999
Function Update-RSModule {
100-
<#
100+
<#
101101
.SYNOPSIS
102102
This module let you maintain your installed modules in a easy way.
103103
@@ -111,7 +111,7 @@ Function Update-RSModule {
111111
.PARAMETER Scope
112112
Need to specify scope of the installation/update for the module, either AllUsers or CurrentUser. Default is CurrentUser.
113113
If this parameter is empty it will use CurrentUser
114-
The parameter -Scope don't effect the uninstall-module function this is because of limitation from Microsoft.
114+
The parameter -Scope don't effect the uninstall-module function this is because of limitation from Microsoft.
115115
- Scope effect Install/update module function.
116116
117117
.PARAMETER ImportModule
@@ -140,7 +140,7 @@ Function Update-RSModule {
140140
Update-RSModule -Module "PowerCLI, ImportExcel" -UninstallOldVersion -ImportModule
141141
# 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.
142142
143-
.RELATED LINKS
143+
.LINK
144144
https://github.com/rstolpe/MaintainModule/blob/main/README.md
145145
146146
.NOTES
@@ -156,8 +156,8 @@ Function Update-RSModule {
156156
Param(
157157
[Parameter(Mandatory = $false, HelpMessage = "Enter module or modules (separated with ,) that you want to update, if you don't enter any all of the modules will be updated")]
158158
[string]$Module,
159-
[ValidateSet("CurrentUser", "AllUsers")]
160-
[Parameter(Mandatory = $true, HelpMessage = "Enter CurrentUser or AllUsers depending on what scope you want to change your modules")]
159+
[ValidateSet("CurrentUser", "AllUsers")]
160+
[Parameter(Mandatory = $false, HelpMessage = "Enter CurrentUser or AllUsers depending on what scope you want to change your modules")]
161161
[string]$Scope = "CurrentUser",
162162
[Parameter(Mandatory = $false, HelpMessage = "Import modules that has been entered in the module parameter at the end of this function")]
163163
[switch]$ImportModule = $false,
@@ -266,7 +266,7 @@ Function Update-RSModule {
266266
# Collect all of the imported modules.
267267
Write-Verbose "Collecting all of the installed modules..."
268268
$ImportedModules = Get-Module | Select-Object Name, Version
269-
269+
270270
# Import module if it's not imported
271271
Write-Verbose "Starting to import the modules..."
272272
foreach ($m in $Module.Split()) {

0 commit comments

Comments
 (0)