cannot run azure CLI commands from Jenkins - azure

I am trying to run some az commands from a Jenkins pipeline which (running in Windows 10) I already use in my laptopĀ“s Jenkins, but when trying to use it on another computer (also running w10) I get this error :
11:12:47 powershell.exe : az : The term 'az' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
11:12:47 At C:\Users\User\.jenkins\workspace\playground#tmp\durable-933c3d89\powershellWrapper.ps1:3 char:1
11:12:47 + & powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -Comm ...
11:12:47 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11:12:47 + CategoryInfo : NotSpecified: (az : The term '...ram. Check the :String) [], RemoteException
11:12:47 + FullyQualifiedErrorId : NativeCommandError
11:12:47
11:12:47 spelling of the name, or if a path was included, verify that the path is correct and try again.
11:12:47 At C:\Users\User\.jenkins\workspace\playground#tmp\durable-933c3d89\powershellScript.ps1:3 char:25
11:12:47 + az devops configure --defaults organization=h ...
11:12:47 + ~~
11:12:47 + CategoryInfo : ObjectNotFound: (az:String) [], CommandNotFoundException
11:12:47 + FullyQualifiedErrorId : CommandNotFoundException
11:12:47
11:12:47 az : The term 'az' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
11:12:47 spelling of the name, or if a path was included, verify that the path is correct and try again.
11:12:47 At C:\Users\User\.jenkins\workspace\playground#tmp\durable-933c3d89\powershellScript.ps1:4 char:35
11:12:47 + $output = az boards work-item show --id=89609 ...
11:12:47 + ~~
11:12:47 + CategoryInfo : ObjectNotFound: (az:String) [], CommandNotFoundException
11:12:47 + FullyQualifiedErrorId : CommandNotFoundException
However running any command from the cmd / powershell works fine. I have set the Set-ExecutionPolicy Unrestricted command but I do not get any hint of what is going wrong

Related

Register-IoTDevice : The term 'Register-IoTDevice' is not recognized as the name of a cmdlet, function, script file, or operable

i'm getting the below error while registering the IoT Device via Powershell Command
Register-IoTDevice : The term 'Register-IoTDevice' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:11
$device = Register-IoTDevice #deviceParams
~~~~~~~~~~~~~~~~~~
CategoryInfo : ObjectNotFound: (Register-IoTDevice:String) [], CommandNotFoundException
FullyQualifiedErrorId : CommandNotFoundException

Create React App not showing error message with

npx : The term 'npx' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
npx create-react-app myapp
+ CategoryInfo : ObjectNotFound: (npx:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
**Create React App not showing error message with ErrorBoundary
npx : The term 'npx' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
npx create-react-app myapp
+ CategoryInfo : ObjectNotFound: (npx:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
**

My Powershell showing this location issue The 'Set-Location' command was found in the module .but the module could not be loaded

The 'Set-Location' command was found in the module 'Microsoft.PowerShell.Management', but the module could not be
loaded. For more information, run 'Import-Module Microsoft.PowerShell.Management'.
CategoryInfo : ObjectNotFound: (Set-Location:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CouldNotAutoloadMatchingModule

Get-AzurePublishSettingFile : The term 'Get-AzurePublishSettingFile' is not recognized

I have tried installing the Azure and AZ cmdlet via the command with AllowClobber and that successfully installed. I am running PowerShell as administrator and have connected my Azure account by signing in. However, when running the command "Get-AzurePublishSettingFile" the following error appears:
Get-AzurePublishSettingFile : The term 'Get-AzurePublishSettingFile' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try again.
At line:1 char:1
Get-AzurePublishSettingFile
+ CategoryInfo : ObjectNotFound: (Get-AzurePublishSettingFile:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Make sure you have installed the ASM PowerShell module Azure, and I notice you missed an s in your command, it should be Get-AzurePublishSettingsFile, not Get-AzurePublishSettingFile.
Reference - https://learn.microsoft.com/en-us/powershell/module/servicemanagement/azure.service/get-azurepublishsettingsfile?view=azuresmps-4.0.0

Seed data in asp.net preview template web application

How should we seed data in asp.net preview web applications. I tried to use
Enable-Migrations
command but it gave me the following error:
Enable-Migrations : The term 'Enable-Migrations' is not recognized as
the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify
that the path is correct and try again. At line:1 char:1
+ Enable-Migrations
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Enable-Migrations:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

Resources