繁体   English   中英

如何使用 Azure Functions、Runbooks 或 Azure Powershell 在 Azure 虚拟机中执行程序?

[英]How execute a program in a Azure Virtual Machine using Azure Functions, Runbooks or Azure Powershell?

我有时需要每天在 Azure 上的 Windows 虚拟机上启动一个应用程序/文件,并且我不想在需要运行它时建立 RDP 连接来执行此操作。 因此,我想知道是否可以在 Powershell 中创建 Azure 函数、Runbook(自动化)或脚本来打开此应用程序/文件(如果可能,还有计划)。

我在自动化 Runbooks 上尝试了以下脚本,但没有奏效:

$Conn = Get-AutomationConnection -Name AzureRunAsConnection
Add-AzureRMAccount -ServicePrincipal -Tenant $Conn.TenantID -ApplicationId $Conn.ApplicationID -CertificateThumbprint $Conn.CertificateThumbprint
$VMs = Get-AzureRMVM | where {$_.Tags.Values -like '*TaggedMachine*'} 
$VMs | Start-Process -FilePath "notepad.exe"
Write-Output $VMs.Name

您可以尝试使用 Azure VM 运行命令功能。 如果您使用的是 Azure PowerShell,请查看: https : //docs.microsoft.com/en-us/azure/virtual-machines/windows/run-command#powershell

如果您使用AzureRM模块,请改用此命令: https : AzureRM

如果您需要更多帮助,请告诉我:)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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