简体   繁体   English

Azure VM中的远程Powershell

[英]remote powershell in azure VM

Since many days I am trying to sysprep an azure virtual machine. 许多天以来,我一直在尝试准备一台蔚蓝的虚拟机。

Following is the command that I am using to connect to the VM from local and executing the Upload-GoldImage.ps1 script 以下是我用于从本地连接到VM并执行Upload-GoldImage.ps1脚本的命令

Invoke-Command -ConnectionUri $uri -SessionOption (New-PSSessionOption -SkipCACheck -SkipCNCheck) -Credential $credential -ScriptBlock {C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe -file "c:\\program files\\WindowsPowershell\\Upload-GoldImage.ps1" -validateCurrentOS} 调用命令-ConnectionUri $ uri -SessionOption(New-PSSessionOption -SkipCACheck -SkipCNCheck)-凭据$ credential -ScriptBlock {C:\\ Windows \\ system32 \\ WindowsPowerShell \\ v1.0 \\ powershell.exe-文件“ c:\\ program files \\ WindowsPowershell \\ Upload-GoldImage.ps1“ -validateCurrentOS}

remote machine gets connected successfully. 远程计算机成功连接。 All the commands in the ps1 file are executed successfully but only the sysprep command isn't executing. ps1文件中的所有命令均已成功执行,但仅sysprep命令未执行。

The ps1 mentioned above contains one command to sysprep the machine - Start-Process -FilePath C:\\Windows\\System32\\Sysprep\\sysprep.exe -ArgumentList '/generalize /oobe /shutdown /quiet' 上面提到的ps1包含一个用于对计算机进行sysprep的命令-Start -Process -FilePath C:\\ Windows \\ System32 \\ Sysprep \\ sysprep.exe -ArgumentList'/ generalize / oobe / shutdown / quiet'

Write-Host("After sysprep") 写主机(“ Sysprep之后”)

When this gets executed on my local powershell prompt - "After sysprep" is getting printed. 当此命令在我的本地Powershell提示符下执行时-打印“ After sysprep”。 I am getting no error in the sysprep command. 我在sysprep命令中没有任何错误。 Still the machine is not getting sysprepped. 机器仍然没有系统准备。

Please if anyone could help me out 如果有人可以帮助我,请

Thanks. 谢谢。

Finally I was able to sysprep the machine from my local powershell. 最终,我能够从本地Powershell对计算机进行sysprep。

Previously my script used Start-Process command. 以前,我的脚本使用Start-Process命令。

But then, http://social.technet.microsoft.com/wiki/contents/articles/7703.powershell-running-executables.aspx#Diagnostics_Process_Start - this link helped me out, where I tried various several ways mentioned in the link. 但是,然后http://social.technet.microsoft.com/wiki/contents/articles/7703.powershell-running-executables.aspx#Diagnostics_Process_Start-此链接对我有所帮助,在那里我尝试了该链接中提到的多种方法。

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

相关问题 Sysprep Azure VM 与远程 PowerShell - Sysprep Azure VM with Remote PowerShell Azure Runbook - 在远程 VM 上运行 Powershell - Azure runbook - run Powershell on remote VM 将Azure PowerShell Cmdlet加载到远程VM - Load Azure PowerShell Cmdlets onto Remote VM 通过Azure远程通过Powershell访问Azure虚拟机 - Accessing an azure vm through Powershell remote from Azure Automation 如何连接到Azure Windows VM并使用PowerShell运行远程脚本? - How Connect to a Azure Windows VM and run a remote script with PowerShell? 无法运行位于远程 Azure VM D 中的远程 powershell 脚本:使用 Invoke-Command 的驱动器 - Unable to run remote powershell script which is located in remote Azure VM D: drive using Invoke-Command Azure - 通过 Azure Z3D265B4E1EEEF0DDF178sZCC 输入命令和远程 Linux VM 连接 - Azure - Connect to a remote Linux VM via Azure PowerShell runbooks and input commands 如何对Azure Data Factory V2中的现有Azure VM运行远程命令(PowerShell / Bash)? - How to run a remote command (powershell/bash) against an existing Azure VM in Azure Data Factory V2? Azure VM OS构建-Powershell - Azure VM OS Build - Powershell 通过PowerShell获取Azure VM详细信息 - Get Azure VM Detail by PowerShell
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM