# Powershell Installation and Modules

# Install latest version of Azure CLI on Mac

```powershell
brew update && brew install azure-cli
```

[Original Article](https://wikipedia.mutschlerhome.com/attachments/31)

# Install latest version of Azure CLI on Linux

```
# YOLO
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
```

Resources: [https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-linux?pivots=apt](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-linux?pivots=apt) [https://docs.microsoft.com/en-us/powershell/azure/install-az-ps?view=azps-5.5.0](https://docs.microsoft.com/en-us/powershell/azure/install-az-ps?view=azps-5.5.0)

# Install PowerShell

```
brew install --cask powershell-preview
```

Run a powershell terminal with:

```
pwsh-preview
```

# Update Powershell

```powershell
brew update
brew upgrade powershell-preview --cask
```

# Uninstall Powershell

```
brew uninstall --cask powershell
sudo rm -rf /usr/local/bin/pwsh-preview /usr/local/microsoft/powershell
```

Resource: [https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-macos?view=powershell-7.1](https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-macos?view=powershell-7.1)

# Install Azure PowerShell module

For the current user:

```
if ($PSVersionTable.PSEdition -eq 'Desktop' -and (Get-Module -Name AzureRM -ListAvailable)) {
    Write-Warning -Message ('Az module not installed. Having both the AzureRM and ' +
      'Az modules installed at the same time is not supported.')
} else {
    Install-Module -Name Az -AllowClobber -Scope CurrentUser
}
```

Resource: [https://docs.microsoft.com/en-us/powershell/azure/install-az-ps?view=azps-5.5.0](https://docs.microsoft.com/en-us/powershell/azure/install-az-ps?view=azps-5.5.0)

# Setup the AzureRMAlias module

This will deal with incompatibilities with older scripts that use AzureRM:

```
Enable-AzureRmAlias
```

# List available modules

```powershell
Get-Module -ListAvailable
```

# Get authenticated in Powershell

```powershell
Connect-AzAccount %USERNAME
```

# List commands in a module

```powershell
Get-Command -Module <module name>
```

# List functions in a module

```powershell
Get-Command -Module <module name> -Type Function
```

# Authenticate via the CLI

Run this command to get authenticated:

```
az login
```

This will result in a web browser opening, or a URL prompt. Navigating to this url will prompt you for a code, which you’ve been provided in the command line. Paste it in, click next, and select the proper account.

Resource: [https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-macos](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-macos)