Ariel Larisma
Ariel Larisma

Reputation: 37

How to run Azure Powershell Cmdlets in Visual Studio

Install-Module AzureAD 
$password = ConvertTo-SecureString "password" -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential ("[email protected]", $password)
Connect-AzureAD -Credential $Cred

This is my sample Azure Powershell script. I've run it through Windows PowerShell ISE. Is there any way to run Azure cmdlets using Visual Studio 2017? Or any Nuget Packages available for referencing the library for Azure Powershell commands?

Thanks!

Upvotes: 0

Views: 2422

Answers (2)

Tom Sun
Tom Sun

Reputation: 24549

Additional for PRADEEP. We could install the Powershell tool with Visual Studio Installer. We also could install it from VS extensions and updates.

enter image description here

After that we could create the PowerShell project and script. We also could debug and run the scrpits in the VS.

enter image description here

Note: If you want to install Module, then we need to run the VS with administrator rights, or will get the error info Administrator rights are required to install modules

enter image description here

Upvotes: 0

CHEEKATLAPRADEEP
CHEEKATLAPRADEEP

Reputation: 12768

You can install PowerShell Tools from the Visual Studio Installer as an individual component or as a part of the "Azure development" workload.

To install PowerShell Tools as an individual component:

  1. Click the "Individual components" tab.
  2. List itemScroll to the "Code tools" section.
  3. Check "PowerShell tools".
  4. Click "Install" or "Modify" to apply the change.

enter image description here

After installing click on View => Other Windows => PowerShell Interactive Window => and run your cmdlet:

enter image description here

Upvotes: 1

Related Questions