Reputation: 27
How am I able to run PowerShell commands against a Windows 2016 vm in Azure without using winrm or pssession where I have to install\configure a self signed cert?
Does anyone know
Upvotes: 0
Views: 4611
Reputation: 28216
Can I run powershell commands from Azure DevOps to vm's in Azure?
Run PowerShell scripts in your Windows VM by using Run Command provides two possible directions:
You can use Azure CLI task in azure devops pipeline to run az vm start
and az vm run-command invoke commands. The az vm start
will start the VM, the second command will then run the PS commands.
You can use Azure Powershell task in azure devops pipeline to run Start-AzVM and Invoke-AzVMRunCommand commands.
Note:
It requires several seconds even when starting VM in web portal, so it's recommended to have 10~15 seconds as interval between these two commands(Start VM
and Run PS
). eg:
Try Start-Sleep -s 15.
Upvotes: 1
Reputation: 973
If I understand your query correctly, you want to run PowerShell commands on Azure VM
Other than that, there are several ways to run commands and scripts on Azure VMs depending on the design you need to implement.
You can use Azure portal to execute predefined, custom PowerShell commands on a VM using Virtual Machine blade in Azure portal.
Also please take a look at these docs for more reference :
Upvotes: 1
Reputation: 612
If you are not required to run only one command frequently, you can simply run any PowerShell command just from the portal using Run command, please take a look at the screenshot.
Upvotes: 1
Reputation: 442
Better to use Azure Automation account than Azure DevOps if you want to do PowerShell.
Read this on how to create an automation account.
See here how to create a Runbook in Azure Automation using PowerShell.
Upvotes: 1