繁体   English   中英

使用 PowerShell 从位于其中的 Azure VM 调用文件

[英]To Call a File from Azure VM which resides within it using PowerShell

如何使用 Powershell(本地 ISE)调用文件路径位于Azure VM中的文件。

在本地计算机上使用 Powershell ISE 并尝试调用位于 Azure Vm 中的 Ps 文件。

如果您打算在 VM 内运行 .ps1 文件,则可以使用 PowerShell 命令Invoke-AzVMRunCommand 您可以在本地计算机上创建一个脚本,然后将要在 VM 中运行 .ps1 的命令放入该脚本。 例如:

本地计算机中的脚本script.ps1

powershell.exe -f 'C:\script_inside_VM.ps1'    # this is the command that will run inside the VM

使用 PowerShell 命令:

Invoke-AzVMRunCommand -ResourceGroupName groupName -VMName vmName -CommandId 'RunPowerShellScript' -ScriptPath '\path\script.ps1'

暂无
暂无

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

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