Silver Light and Blue Sky

C# and Infrastructure. Code is everything.

Azure PowerShell preview on Linux

PowerShell is now open sourced and can run on Linux.

blogs.msdn.microsoft.com

Azure PowerShell depends on full .NET Framework, so it can't run on Linux now.

github.com

However, preview version for .NET Core is released and I tried it.

At first, install powershell on Linux. I use Red Hat Enterprise Linux 7.2, so I use CentOS rpm.

github.com

Please replace the version as you like.

# wget https://github.com/PowerShell/PowerShell/releases/download/v6.0.0-alpha.9/powershell-6.0.0_alpha.9-1.el7.centos.x86_64.rpm
# yum localinstall powershell-6.0.0_alpha.9-1.el7.centos.x86_64.rpm

Next, confirm the PSModulePath. I use the one for user directory.

$ powershell
PS /home/user1> $env:PSMODULEPATH                                                                                           
/home/user1/.local/share/powershell/Modules:/usr/local/share/powershell/Modules:/opt/microsoft/powershell/6.0.0-alpha.9/Modules

Then, install the package.

PS /home/user1> Install-Package -Name AzureRM.NetCore.Preview -Source https://www.powershellgallery.com/api/v2 -ProviderName NuGet -ExcludeVersion -Destination /home/user1/.local/share/powershell/Modules   
PS /home/user1> Import-Module AzureRM.NetCore.Preview
PS /home/user1> Login-AzureRMAccount
VERBOSE: To sign in, use a web browser to open the page https://aka.ms/devicelogin. Enter the code AAAAAAAAA to authenticate.

You can use Azure PowerShell on Linux now!