In a previous post, I explained how to create an Azure file share. Today, I want to show you how to connect and mount an Azure file share with Azure PowerShell.


  • This tutorial assumes that you already have a Microsoft Azure account configured.
  • You can use an existing Azure File Share, or you can create a new one. If you want to know how to create an Azure File Share using PowerShell, check out this link.

Azure PowerShell Workaround

If you want to know how to install the PowerShell Azure module on your machine, check out this link.

The simplest way to get started is to sign in interactively at the command line.

This cmdlet will bring up a dialog box prompting you for your email address and password associated with your Azure account.
If you have more than one subscription associated with your mail account, you can choose the default subscription. To perform this task, we will use the following commands:

Once you set your default subscription, you’re ready to start.

Set the variables

Here, we define the characteristics of our environment and the resource’s properties.


If you connect from a computer from outside the Azure network, remember to open outgoing TCP port 445 on your local network.

Let’s go

Using the ConvertTo-SecureString cmdlet we convert the account key into a secure string.


Now, the variable created in the previous step; we use it to create the PSCredential object.

Azure File Share Drive

and finally, the credentials are passed to the New-PSDrive cmdlet, which maps the drive.

Azure File Share Drive

Important: Run the New-PSdrive cmdlet in a non-administrative Shell.

If you want to automatically reconnect and map the drive after restarting your computer, you should use the cmdkey command to store your credentials.

For the correct execution of the command, you should replace the <StorageAccountName> and <StorageAccountKey> values ​​with the values ​​of your Storage Account.

If you want to delete the stored credential for Azure File Services, use the following command:

Thanks for reading my post. I hope you find it useful.

To know more about Azure File services, check out this link: