Skip to content

Commit a2eb28f

Browse files
authored
fix issue with installmodule script (Azure#22055)
1 parent 211d23d commit a2eb28f

11 files changed

+16
-12
lines changed

docker/Dockerfile-alpine-3.13

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ RUN if [ "${LATEST}" = True ] ; then \
3636
pwsh -Command Invoke-WebRequest -uri ${BLOB_URL} -OutFile latest.tar.gz && \
3737
mkdir latest && \
3838
tar -zxvf ./latest.tar.gz -C ./latest && \
39-
pwsh -Command ./latest/InstallModule.ps1 ;\
39+
pwsh -Command ./latest/InstallModule.ps1 -Scope AllUsers ;\
4040
else \
4141
# install old azure-powershell from PSGallery
4242
pwsh -Command Set-PSRepository -Name ${REPOSITORY} -InstallationPolicy Trusted && \

docker/Dockerfile-alpine-3.14

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ RUN if [ "${LATEST}" = True ] ; then \
3636
pwsh -Command Invoke-WebRequest -uri ${BLOB_URL} -OutFile latest.tar.gz && \
3737
mkdir latest && \
3838
tar -zxvf ./latest.tar.gz -C ./latest && \
39-
pwsh -Command ./latest/InstallModule.ps1 ;\
39+
pwsh -Command ./latest/InstallModule.ps1 -Scope AllUsers;\
4040
else \
4141
# install old azure-powershell from PSGallery
4242
pwsh -Command Set-PSRepository -Name ${REPOSITORY} -InstallationPolicy Trusted && \

docker/Dockerfile-centos-7

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ RUN if [ "${LATEST}" = True ] ; then \
3636
pwsh -Command Invoke-WebRequest -uri ${BLOB_URL} -OutFile latest.tar.gz && \
3737
mkdir latest && \
3838
tar -zxvf ./latest.tar.gz -C ./latest && \
39-
pwsh -Command ./latest/InstallModule.ps1 ;\
39+
pwsh -Command ./latest/InstallModule.ps1 -Scope AllUsers ;\
4040
else \
4141
# install old azure-powershell from PSGallery
4242
pwsh -Command Set-PSRepository -Name ${REPOSITORY} -InstallationPolicy Trusted && \

docker/Dockerfile-debian-10

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ RUN if [ "${LATEST}" = True ] ; then \
3636
pwsh -Command Invoke-WebRequest -uri ${BLOB_URL} -OutFile latest.tar.gz && \
3737
mkdir latest && \
3838
tar -zxvf ./latest.tar.gz -C ./latest && \
39-
pwsh -Command ./latest/InstallModule.ps1 ;\
39+
pwsh -Command ./latest/InstallModule.ps1 -Scope AllUsers ;\
4040
else \
4141
# install old azure-powershell from PSGallery
4242
pwsh -Command Set-PSRepository -Name ${REPOSITORY} -InstallationPolicy Trusted && \

docker/Dockerfile-debian-11

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ RUN if [ "${LATEST}" = True ] ; then \
3636
pwsh -Command Invoke-WebRequest -uri ${BLOB_URL} -OutFile latest.tar.gz && \
3737
mkdir latest && \
3838
tar -zxvf ./latest.tar.gz -C ./latest && \
39-
pwsh -Command ./latest/InstallModule.ps1 ;\
39+
pwsh -Command ./latest/InstallModule.ps1 -Scope AllUsers ;\
4040
else \
4141
# install old azure-powershell from PSGallery
4242
pwsh -Command Set-PSRepository -Name ${REPOSITORY} -InstallationPolicy Trusted && \

docker/Dockerfile-mariner-2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ RUN if [ "${LATEST}" = True ] ; then \
3838
tdnf install -y tar gzip && \
3939
tdnf clean all && \
4040
tar -zxvf ./latest.tar.gz -C ./latest && \
41-
pwsh -Command ./latest/InstallModule.ps1 ;\
41+
pwsh -Command ./latest/InstallModule.ps1 -Scope AllUsers ;\
4242
else \
4343
# install old azure-powershell from PSGallery
4444
pwsh -Command Set-PSRepository -Name ${REPOSITORY} -InstallationPolicy Trusted && \

docker/Dockerfile-mariner-2-arm64

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ RUN if [ "${LATEST}" = True ] ; then \
3838
tdnf install -y tar gzip && \
3939
tdnf clean all && \
4040
tar -zxvf ./latest.tar.gz -C ./latest && \
41-
pwsh -Command ./latest/InstallModule.ps1 ;\
41+
pwsh -Command ./latest/InstallModule.ps1 -Scope AllUsers ;\
4242
else \
4343
# install old azure-powershell from PSGallery
4444
pwsh -Command Set-PSRepository -Name ${REPOSITORY} -InstallationPolicy Trusted && \

docker/Dockerfile-ubuntu-18.04

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ RUN if [ "${LATEST}" = True ] ; then \
3636
pwsh -Command Invoke-WebRequest -uri ${BLOB_URL} -OutFile latest.tar.gz && \
3737
mkdir latest && \
3838
tar -zxvf ./latest.tar.gz -C ./latest && \
39-
pwsh -Command ./latest/InstallModule.ps1 ;\
39+
pwsh -Command ./latest/InstallModule.ps1 -Scope AllUsers ;\
4040
else \
4141
# install old azure-powershell from PSGallery
4242
pwsh -Command Set-PSRepository -Name ${REPOSITORY} -InstallationPolicy Trusted && \

docker/Dockerfile-ubuntu-20.04

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ RUN if [ "${LATEST}" = True ] ; then \
3636
pwsh -Command Invoke-WebRequest -uri ${BLOB_URL} -OutFile latest.tar.gz && \
3737
mkdir latest && \
3838
tar -zxvf ./latest.tar.gz -C ./latest && \
39-
pwsh -Command ./latest/InstallModule.ps1 ;\
39+
pwsh -Command ./latest/InstallModule.ps1 -Scope AllUsers ;\
4040
else \
4141
# install old azure-powershell from PSGallery
4242
pwsh -Command Set-PSRepository -Name ${REPOSITORY} -InstallationPolicy Trusted && \

docker/Dockerfile-ubuntu-22.04

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ RUN if [ "${LATEST}" = True ] ; then \
3636
pwsh -Command Invoke-WebRequest -uri ${BLOB_URL} -OutFile latest.tar.gz && \
3737
mkdir latest && \
3838
tar -zxvf ./latest.tar.gz -C ./latest && \
39-
pwsh -Command ./latest/InstallModule.ps1 ;\
39+
pwsh -Command ./latest/InstallModule.ps1 -Scope AllUsers;\
4040
else \
4141
# install old azure-powershell from PSGallery
4242
pwsh -Command Set-PSRepository -Name ${REPOSITORY} -InstallationPolicy Trusted && \

tools/Installer/InstallModule.ps1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ param(
2222
$ModuleName = "Az",
2323
[string]
2424
[Parameter(Mandatory = $false, Position = 1, HelpMessage = "Specifies the path for discovering and installing modules from.")]
25-
$SourceLocation = $PSScriptRoot
25+
$SourceLocation = $PSScriptRoot,
26+
[string]
27+
[ValidateSet("CurrentUser", "AllUsers")]
28+
[Parameter(Mandatory = $false, Position = 2, HelpMessage = "The scope of the installed module")]
29+
$Scope = "CurrentUser"
2630
)
2731

2832
$gallery = [guid]::NewGuid().ToString()
@@ -31,7 +35,7 @@ Register-PSRepository -Name $gallery -SourceLocation $SourceLocation -PackageMan
3135

3236
try {
3337
Write-Host "Installing $ModuleName..."
34-
Install-Module -Name $ModuleName -Repository $gallery -Scope CurrentUser -AllowClobber -Force
38+
Install-Module -Name $ModuleName -Repository $gallery -Scope $Scope -AllowClobber -Force
3539
}
3640
finally {
3741
Write-Host "Unregistering gallery $gallery..."

0 commit comments

Comments
 (0)