我们正在尝试使用PowerShell提取Azure Advisor建议。 不幸的是,顾问似乎没有RM模块。
因此依赖于DevOps Azure Task版本4. *,该版本应该用于Az模块。
但是,似乎由于以下错误,RM模块仍被加载到会话中:
##[warning]Both Az and AzureRM modules were detected on this machine. Az and AzureRM modules cannot be imported in the same session or used in the same script or runbook. If you are running PowerShell in an environment you control you can use the 'Uninstall-AzureRm' cmdlet to remove all AzureRm modules from your machine. If you are running in Azure Automation, take care that none of your runbooks import both Az and AzureRM modules. More information can be found here: https://aka.ms/azps-migration-guide
因此,我不得不使用Uninstall-AzureRM命令。
##[error]Could not find a part of the path 'C:\Users\VssAdministrator\Documents\WindowsPowerShell\Modules'.
这或多或少是我正在尝试的。
uninstall-azurerm
install-Module Az -force -scope currentuser
install-Module Az.Advisor -force -scope currentuser
import-module Az.Advisor
Get-AzAdvisor recommendations
使用RM或Az模块将为您提供任何帮助。