PDA

View Full Version : Azure module not recognized in PowerShell action


paxil
10-02-2023, 03:10 PM
When this is executed from windows server powershell command line manually, it works fine, but when executed through VBP, it fails saying 'Get-AzCloudService' command not recognized. User is logged in using the same creds too.

Get-AzCloudService -ResourceGroupName "%RESOURCE_GROUP%" -CloudServiceName "%CLOUD_SERVICE_NAME%"


Failure message:
>C:\Users\<****>\AppData\Local\Temp\Vis8CFA.tmp.ps1 : Failed to build because The term 'Get-AzCloudService' is not </message>
<message>recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if </message>
<message>a path was included, verify that the path is correct and try again.</message>
<message>At line:1 char:1</message>
<message>+ & C:\Users\<****>\AppData\Local\Temp\Vis8CFA.tmp.ps1</message>
<message>+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~</message>
<message> + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException</message>
<message> + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException, Vis8CFA.tmp.ps1</message>
<message> </message>
<message>Process completed with exit code 1</message>

kinook
10-02-2023, 03:48 PM
Must be running from a different PS profile. What do you get from your PowerShell instance and from Visual Build for this?

$PSVersionTable
$Profile
Get-AzCloudService

paxil
10-03-2023, 07:21 AM
PS C:\Windows\system32> $PSVersionTable

Name Value
---- -----
PSVersion 5.1.17763.4840
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.4840
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

PS C:\Windows\system32> $Profile
C:\Users\lg*****sv\Documents\WindowsPowerShell\Mic rosoft.PowerShell_profile.ps1
PS C:\Windows\system32> Get-AzCloudService

ResourceGroupName Name Location ProvisioningState
----------------- ---- -------- -----------------
GEHC-CX-IC-DEV-US-EA-WR-01-01 neal-cloud-wr eastus Succeeded

So I connect with this lg**** user to this server, who is an admin, but then login as a user with AD credentials in Azure using the az login command and then a az account set. That is all successful until I get to the Get-AzCloudService command in VBP.

kinook
10-03-2023, 07:43 AM
Please post or send the .bld file and build log file, with the Log the command-line that is used option on the Advanced tab of the PowerShell action checked.

https://www.kinook.com/Forum/showthread.php?t=3044