Mirage PowerCLI에서 작성한 샘플 스크립트입니다. 이 스크립트는 Mirage PowerCLI에서 보류 중인 디바이스를 프로비저닝하기 위한 절차를 자세히 보여 줍니다.

param($server, $username, $password, $volumename, $policyname, $baselayername, $domain, $domainuser, $domainpassword)

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

"----------Get-MirageVolume---------"
$volume = Get-MirageVolume $volumename | Select-Object -First 1
if (!$volume)
{
	"Can not get volume with name $volumename."
	return
}
$volume

"----------Get-MiragePolicy---------"
$policy = Get-MiragePolicy $policyname | Select-Object -First 1
if (!$policy)
{
	"Can not get policy with name $policyname."
	return
}
$policy

"---------Get-MirageBaseLayer--------"
$baselayer = Get-MirageBaseLayer $baselayername | Select-Object -First 1
if (!$baselayer)
{
	"Can not get base layer with name $baselayername."
	return
}
$baselayer

"------Get-MiragePendingDevice------"
$device = Get-MiragePendingDevice | Select-Object -First 1
if (!$device)
{
	"There's no pending device on Mirage server."
	return
}
$device

"-----------ProvisionFlow-----------"
$cvd = $device | New-MirageCvd -Policy $policy -Volume $volume -BaseLayer $baselayer -Domain $domain -User $domainuser -Password $domainpassword -Provision -Force
if(!$cvd)
{
	"Provision flow fails"
	return
}

"Provision flow starts"
$maxRetries = 100
$retryCount = 0
while ($true)
{
	Start-Sleep -s 60
	$assignment = Get-MirageAssignment -CVD $cvd -TaskType 'DeviceProvision'
	if($assignment)
	{
		if($assignment.Status -eq 'Failed')
		{
			"Provision flow fails"
			return
		}
		if($assignment.Status -eq 'Completed')
		{
			Get-MirageCvd -Device $device
			"Provision flow succeeds."
			return
		}
	}
	$retryCount++
	if($retryCount -gt $maxRetries)
	{
		"Provision assignment is not created/completed, retry times: $retryCount"
		return
	}	
}