File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ <#
2
+ . SYNOPSIS
3
+ .
4
+ . DESCRIPTION
5
+ .
6
+ . PARAMETER ModuleName
7
+ Name of the module to install. By default all modules are installed.
8
+ . PARAMETER SourceLocation
9
+ Specifies the path for discovering and installing modules from.
10
+ Taking current folder as source location by default
11
+ . EXAMPLE
12
+ C:\PS> ./InstallModule.ps1 -ModuleName Az.Accounts
13
+ . NOTES
14
+ Author: Beisi Zhou
15
+ Date: July 21, 2021
16
+ #>
17
+
18
+ [cmdletbinding ()]
19
+ param (
20
+ [string ]
21
+ [Parameter (Mandatory = $false , Position = 0 , HelpMessage = " Name of the module to install. By default all modules are installed." )]
22
+ $ModuleName = " Az" ,
23
+ [string ]
24
+ [Parameter (Mandatory = $false , Position = 1 , HelpMessage = " Specifies the path for discovering and installing modules from." )]
25
+ $SourceLocation = $PSScriptRoot
26
+ )
27
+
28
+ $gallery = [guid ]::NewGuid().ToString()
29
+ Write-Host " Registering temporary repository $gallery with InstallationPolicy Trusted..."
30
+ Register-PSRepository - Name $gallery - SourceLocation $SourceLocation - PackageManagementProvider NuGet - InstallationPolicy Trusted
31
+
32
+ try {
33
+ Write-Host " Installing $ModuleName ..."
34
+ Install-Module - Name $ModuleName - Repository $gallery - Scope CurrentUser - AllowClobber - Force
35
+ }
36
+ finally {
37
+ Write-Host " Unregistering gallery $gallery ..."
38
+ Unregister-PSRepository - Name $gallery
39
+ }
You can’t perform that action at this time.
0 commit comments