在 VMM 脚本中使用作业组
适用对象:System Center 2012 R2 Virtual Machine Manager, System Center 2012 - Virtual Machine Manager
JobGroup 参数使用一个标识符进行分组到单个作业组包含相同作业组标识符的最后一个命令运行之前将运行为一组的一系列命令。
使用 JobGroup 参数
JobGroup 参数要求必须在设置的值为之前获取的 GUID JobGroup。 下面的命令演示如何生成全局唯一标识符 (GUID) 并将其存储在 $JobGroupID 变量:
$JobGroupID = [Guid]::NewGuid().ToString()
若要包括在作业组中的后续命令,设置 JobGroup 该命令为相同值的参数。 例如,包含的所有命令 -JobGroup $JobGroupID 之前还包括最后一个命令将不会运行 -JobGroup $JobGroupID。
下面的示例演示如何在脚本中使用 JobGroup。New-SCVirtualDiskDrive 第三个行中的 cmdlet 进行排队的工作需要完成的 New-SCVirtualDiskDrive, ,但不运行之前只是早于 New-SCVirtualMachine cmdlet。New-SCVirtualMachine 是包含的最后一个命令 JobGroup 和初始化工作,捆绑中任何以前排队工作。 在这种情况下,这意味着运行 New-SCVirtualDiskDrive 然后 New-SCVirtualMachine。
# Generate a GUID for the JobGroupID variable.
$JobGroupID = [Guid]::NewGuid().ToString()
$VHD = Get-SCVirtualHardDisk -VMMServer "VMMServer01.Contoso.com" | where {$_.Location -eq "\\LibServer01.Contoso.com\MSSCVMMLibrary\VHDs\Blank Disk - Large.vhd"}
# This is the first cmdlet that uses the JobGroup variable.
New-SCVirtualDiskDrive -IDE -Bus 0 -LUN 1 -JobGroup $JobGroupID -VirtualHardDisk $VHD
$HWProfile = Get-SCHardwareProfile | where {$_.Name -match "NewHWProfile01"}
$VMHost = Get-SCVMHost -ComputerName "VMHost03"
# This is the last cmdlet that uses the JobGroup variable, which indicates that
# New-SCVirtualDiskDrive should run just prior to the following command.
New-SCVirtualMachine -Name "VM10" -Description "New Virtual Machine VM10" -JobGroup $JobGroupID -VMMServer "VMMServer01.Contoso.com" -Owner "Contoso\Katarina" -VMHost $VMHost -Path "D:\VirtualMachinePath" -HardwareProfile $HWProfile -RunAsynchronously -StartAction NeverAutoTurnOnVM -StopAction SaveVM
Cmdlet 使用 JobGroup
您可以使用 JobGroup 参数使用以下 cmdlet:
添加 SCLibraryServer
添加 SCLibraryShare
添加 SCVMHostNetworkAdapter
Compress SCVirtualDiskDrive
Convert SCVirtualDiskDrive
复制 SCStorageVolume
禁用 SCRunAsAccount
启用 SCRunAsAccount
展开 SCVirtualDiskDrive
Get SCVMHostRating
Grant SCResource
安装 SCVMHostCluster
装入 SCStorageDisk
移动 SCVirtualHardDisk
移动 SCVirtualMachine
移动 SCVMHostGroup
新 SCCloud
新 SCHardwareProfile
新 SCP2V
新 SCRunAsAccount
新 SCUserRole
新 SCV2V
新 SCVirtualDiskDrive
新 SCVirtualDVDDrive
新 SCVirtualMachine
新 SCVirtualNetwork
新 SCVirtualNetworkAdapter
新 SCVirtualScsiAdapter
新 SCVMTemplate
注册 SCStorageLogicalUnit
注册 SCVirtualMachine
删除 SCCloud
删除 SCCustomPropertyValue
删除 SCUserRole
删除 SCVirtualDiskDrive
删除 SCVirtualDVDDrive
删除 SCVirtualHardDisk
删除 SCVirtualNetwork
删除 SCVirtualNetworkAdapter
删除 SCVirtualScsiAdapter
删除 SCVMCheckpoint
删除 SCVMHostNetworkAdapter
Revoke SCResource
集 SCApplication
集 SCApplicationSetting
集 SCBaseline
集 SCCloud
集 SCCloudCapacity
集 SCCustomPropertyValue
Set-schardwareprofile
集 SCLibraryServer
集 SCRunAsAccount
集 SCUserRole
集 SCUserRoleQuota
集 SCVirtualCOMPort
集 SCVirtualDiskDrive
集 SCVirtualDVDDrive
集 SCVirtualFloppyDrive
集 SCVirtualHardDisk
集 SCVirtualMachine
集 SCVirtualNetwork
集 SCVirtualNetworkAdapter
集 SCVirtualScsiAdapter
集 SCVMHost
集 SCVMHostCluster
集 SCVMHostGroup
集 SCVMHostNetworkAdapter
Set-scvmtemplate
开始 SCUpdateRemediation
注销 SCStorageLogicalUnit