简体   繁体   中英

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 ("username@dev.com", $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!

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.

在此处输入图片说明

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

在此处输入图片说明

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

在此处输入图片说明

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

在此处输入图片说明

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

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM