MicrosoftDocs/azure-docs-powershell

Offline installation steps of Azure PowerShell for Linux

Closed this issue · 8 comments

Currently this documentation only has online install steps for Linux with Install-Module cmdlet.
As GitHub releases have .tar.gz package with Installmodule.PS1 in it, it seems to better to have offline installation steps as well.


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

@thiruma0203
I've delegated this to @mikefrobbins, a content author, to review and share their valuable insights.

@thiruma0203 I've added this suggestion as an idea for a future enhancement to our documentation.

Any solution on this? looking for a way to install azurepowerhell in Redhat 7.9 version offline where internet is not enabled.

@thiruma0203 and @vivuu1989, the steps to install the Az PowerShell module offline via the tar archive are:

These instructions work cross-platform on Windows, Linux, and macOS:

  1. Install PowerShell version 7.2 or higher
  2. Download the tar archive of the Az module from the Azure PowerShell source repo releases page.
  3. Copy the file to the offline system.
  4. Unblock the file if on Windows: Unblock-File -Path <file-path>
  5. Unarchive the tar file: tar zxf <tar-file-location> -C <destination-path>
  6. Run .<destination-path>/InstallModule.ps1 from PowerShell to install the Az module from the extracted files.

6. InstallModule.ps1

Didnt Work. (Redhat version 7.9, pwsh installed version 7.2.18)

getting the below error

./InstallModule.ps1: line 1: syntax error near unexpected token newline' '/InstallModule.ps1: line 1: <#

removed the comment session as well, but again throwing the error

./InstallModule.ps1: line 3: $'.\r': command not found
./InstallModule.ps1: line 17: $'\r': command not found
./InstallModule.ps1: line 18: syntax error near unexpected token $']\r'' '/InstallModule.ps1: line 18: [cmdletbinding()]

  1. InstallModule.ps1

Didnt Work. (Redhat version 7.9, pwsh installed version 7.2.18)

getting the below error

./InstallModule.ps1: line 1: syntax error near unexpected token newline' '/InstallModule.ps1: line 1: <#

removed the comment session as well, but again throwing the error

./InstallModule.ps1: line 3: $'.\r': command not found ./InstallModule.ps1: line 17: $'\r': command not found ./InstallModule.ps1: line 18: syntax error near unexpected token $']\r'' '/InstallModule.ps1: line 18: [cmdletbinding()]

You've launched PowerShell via pwsh, correct? I receive the same error when running ./InstallModule.ps1 from Bash.

  1. InstallModule.ps1

Didnt Work. (Redhat version 7.9, pwsh installed version 7.2.18)
getting the below error
./InstallModule.ps1: line 1: syntax error near unexpected token newline' '/InstallModule.ps1: line 1: <#
removed the comment session as well, but again throwing the error
./InstallModule.ps1: line 3: ′.\r′:commandnotfound./InstallModule.ps1:line17:'\r': command not found ./InstallModule.ps1: line 18: syntax error near unexpected token $']\r'' '/InstallModule.ps1: line 18: [cmdletbinding()]

You've launched PowerShell via pwsh, correct? I receive the same error when running ./InstallModule.ps1 from Bash.

Yes, I followed the instruction which you shared above and installed powershell in redhat machine using command
sudo yum install https://github.com/PowerShell/PowerShell/releases/download/v7.4.1/powershell-7.4.1-1.rh.x86_64.rpm
So the offline installation is not possible in Linux ?

Offline installation is possible on Linux. Example of offline installation on RHEL 8.9 using the previously provided instructions:

image