在管道中使用PowerShell任务Sysprep Azure VM [英] Sysprep an Azure VM using PowerShell task in a pipeline

查看:46
本文介绍了在管道中使用PowerShell任务Sysprep Azure VM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的(dotNET)应用程序是从构建管道构建的(使用Windows Hosted代理),在随后的发布管道中,我预配置了16GB-Win2016 VM(启用RDP,HTTP,HTTPS,WinRM和SSH),我手动将其放入RDP(这里有一个手动干预任务),并配置WinRM(遵循本文:

My (dotNET) application is built (using a Windows Hosted agent), from a build pipeline, and in the subsequent Release pipeline, I provision a 16GB-Win2016 VM (enabling RDP, HTTP, HTTPS, WinRM and SSH), into which I RDP manually (there is a Manual Intervention task here), and configure WinRM (following this article: https://docs.microsoft.com/en-us/azure/marketplace/cloud-partner-portal/virtual-machine/cpp-configure-winrm-after-vm-creation#configure-vm-to-enable-winrm). Everything is fine until here. The next task is a Azure File Copy task, which essentially copies the Build artifacts (from $(System.DefaultWorkingDirectory)) and pastes into a directory I specify. Works like a charm. The next task I have is to create a VHD of this whole VM (essentially after the copying is done).

我知道我可以再次手动将RDP导入VM和 sysprep (使用oobe/generalize/shutdown),然后也许返回Azure门户并磁盘导出OS磁盘(指定SAS URL过期时间为什么(每篇文章为36000条),但是这可以全部自动化吗?

I know I can manually RDP into the VM (again) and sysprep (with oobe/generalize/shutdown), then maybe go back to the Azure Portal and Disk Export the OS Disk (specifying the SAS URL expiration time at whatever (36000 per the article)) BUT can this all be automated?

长话短说-我想知道 sysprep oobe/generalize/shutdown 是否可以通过PS任务远程执行.我知道它的另一部分(导出磁盘和全部磁盘)可以,但是如果sysprep可以远程完成,那么就什么也没有.

So, long story short - I'd like to know if sysprep oobe/generalize/shutdown can be performed remotely preferably over a PS task. I understand the other part of it (exporting the disk and all) can be, but if sysprep can be done remotely nothing like it.

推荐答案

我尝试了一下,得到了我想要的东西:

I tried this and got what I wanted:

$sysprep= 'C:\Windows\System32\Sysprep\Sysprep.exe'
$arg1 = '/generalize'
$arg2 = '/oobe'
$arg3 = '/shutdown'
$arg4 = '/quiet'

& $sysprep $arg1 $arg2 $arg3 $arg4 -Wait

这篇关于在管道中使用PowerShell任务Sysprep Azure VM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆