Mirage PowerCLI で書かれたサンプルスクリプトです。Mirage PowerCLI で CVD 上のアプリ レイヤをアップデートする手順が記載されています。

param($server, $username, $password, $cvdname, $applayername)

"--------Connect-MirageServer--------"
Connect-MirageServer $server $username $password -TrustUnknownCertificate

"--------Get-MirageCvd--------"
$cvd = Get-MirageCvd $cvdname | Select-Object -First 1
if (!$cvd)
{
	"Can not get cvd with name $cvdname."
	return
}
$cvd

"--------Get-MirageAppLayer--------"
$applayer = Get-MirageAppLayer $applayername | Select-Object -First 1
if (!$applayer)
{
	"Can not get app layer with name $applayername."
	return
}
$applayer

"--------Set-MirageCvdAppLayer--------"
$cvd = Set-MirageCvdAppLayer -CVD $cvd -AddLayer $applayer -IgnoreWarnings -Force -DownloadOnly
if (!$cvd)
{
	"Fail to start download app layer."
	return
}
$cvd

$success = $false
$maxRetries = 10
$retryCount = 0
while (!$success)
{
	Start-Sleep -s 20
	$assignment = Get-MirageAssignment -CVD $cvd -TaskType 'DownloadOnlyAppLayerAssignment'
	if($assignment)
	{
		$success = $true
	}
	else
	{
		$retryCount++
		if($retryCount -gt $maxRetries)
		{
			"Download only app layer assignment is not created, retry times: $retryCount"
			return
		}
	}
}
$assignment

"--------Apply-MirageAssignment--------"
$maxRetries = 100
$retryCount = 0
Apply-MirageAssignment -Assignment $assignment -Force
while($true)
{
	Start-Sleep -s 20
	$assignment = Get-MirageAssignment -CVD $cvd -Type 'AppLayerAssignment'
	if($assignment)
	{
		if($assignment.Status -eq 'Failed')
		{
			"Update app layer flow fails"
			return
		}
		if($assignment.Status -eq 'Completed')
		{
			Get-MirageCvd -Id $cvd.Id
			"Update app layer flow succeeds."
			return
		}
	}
	$retryCount++
	if($retryCount -gt $maxRetries)
	{
		"Apply layer assignment is not created/completed, retry times: $retryCount"
		return
	}
}