我有时每天都需要在Azure上的Windows虚拟机上启动一个应用程序/文件,我不想在需要运行它的时候建立RDP连接来执行此操作。因此,我想知道是否可以在Powershell中创建Azure函数、Runbook(自动化(或脚本来打开此应用程序/文档(如果可能的话,还可以安排(。
我在Automation Runbook上尝试了以下脚本,但没有成功:
$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虚拟机运行命令功能。如果您正在使用Azure PowerShell,请参阅以下内容:https://learn.microsoft.com/en-us/azure/virtual-machines/windows/run-command#powershell
如果您使用的是AzureRM
模块,请使用以下命令:https://learn.microsoft.com/en-us/powershell/module/azurerm.compute/invoke-azurermvmruncommand?view=azurermps-6.13.0
如果你需要更多帮助,请告诉我:(