[英]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.