用命令来操作vSphere:十九 PowerCLI命令--vShphere服务器(1) 推荐
2011-06-21 22:39
471 查看
1.Get-Annotation
功能:检索注释
语法:
Get-Annotation [[-CustomAttribute] <CustomAttribute[]>] [-Entity] <InventoryItem> [-Server <VIServer[]>] [<CommonParameters>]
例子:
Get-Cluster Cluster | Get-Annotation -CustomAttribute PhysicalLocation
2.Set-Annotation
功能:更改指定注释的名称
语法:
Set-Annotation [-Entity] <InventoryItem> [-CustomAttribute] <CustomAttribute> [-Value] <String> [-Server <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
(1)
Set-Annotation -Entity $host -CustomAttribute "PhysicalLocation" -Value SofiaOffice
(2)
Get-Cluster Cluster | Set-Annotation -CustomAttribute "PhysicalLocation" -Value California
3.Get-CustomAttribute
功能:检索自定义属性。
语法:
Get-CustomAttribute [[-Name] <String[]>] [[-TargetType] <CustomAttributeTargetType[]>] [-Global] [-Server <VIServer[]>] [<CommonParameters>]
例子:
Get-CustomAttribute -Name Cluster* -TargetType Cluster
4.New-CustomAttribute
功能:创建一个新的自定义属性。
语法:
New-CustomAttribute [-Name] <String> [[-TargetType] <CustomAttributeTargetType[]>] [-Server <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
New-CustomAttribute -Name "CompanyName" -TargetType VMHost, VirtualMachine
5.Remove-CustomAttribute
功能:删除自定义属性。
语法:
Remove-CustomAttribute [-CustomAttribute] <CustomAttribute[]> [-Server <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
Remove-CustomAttribute -CustomAttribute "CompanyID", "Owner" -Server $agent007
6.Set-CustomAttribute
功能:重命名自定义属性。
语法:
Set-CustomAttribute [-CustomAttribute] <CustomAttribute> [-Name] <String> [-Server <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
Set-CustomAttribute -CustomAttribute "PhysicalLocation" -Name "Area"
7.Remove-CustomField
功能:删除一个特定清单项目类型的新的自定义字段。
语法:
Remove-CustomField [-Entity] <InventoryItem> [-Name] <String> [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
Remove-CustomField -Entity VM -Name CPUMaxLoad
8.New-CustomField
功能:创建一个特定清单项目类型的新的自定义字段。
语法:
New-CustomField [-Entity] <InventoryItem> [-Name] <String> [[-Value] <String>] [-Global] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
New-CustomField -Entity VM -Name CPUMaxLoad -Value 300
9.Set-CustomField
功能:设置为特定的清单项目的自定义字段的值。
语法:
Set-CustomField [-Entity] <InventoryItem> [-Name] <String> [[-Value] <String>] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
Get-VM VM | Set-CustomField -Name CF - Value 10
10.Get-Datacenter
功能:检索存储上提供一个vSphere服务器。
语法:
Get-Datacenter [-VM <VirtualMachine[]>] [-Cluster <Cluster[]>] [-VMHost <VMHost[]>] [-Location <VIContainer[]>] [[-Name] <String[]>] [-Id <String[]>] [-NoRecursion] [-Server <VIServer[]>] [<CommonParameters>]
例子:
Get-Datacenter -Name Datacenter*
11.New-Datastore
功能:创建一个新的数据存储。
语法:
New-Datastore [-Server <VIServer[]>] [-VMHost] <VMHost[]> [-Name] <String> -Path <String> [-Nfs] -NfsHost <String> [-ReadOnly] [-WhatIf] [-Confirm] [<CommonParameters>]
New-Datastore [-Server <VIServer[]>] [-VMHost] <VMHost[]> [-Name] <String> -Path <String> [-Vmfs] [-BlockSizeMB <Int32>] [-WhatIf] [-Confirm] [<CommonParameters>]
New-Datastore [-Server <VIServer[]>] [-VMHost] <VMHost[]> [-Name] <String> -Path <String> -NfsHost <String> [-ReadOnly] [-Cifs] -Username <String> -Password <String> [-WhatIf] [-Confirm] [<CommonParameters>]
New-Datastore [-Server <VIServer[]>] [-VMHost] <VMHost[]> [-Name] <String> -Path <String> [-Local] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
(1)
New-Datastore -Nfs -VMHost 10.23.112.345 -Name Datastore -Path $remotePath -NfsHost $remoteHost
(2)
Get-VMHost | New-Datastore -Nfs -Name NFS1 -Path "/mnt/nfs1/nfs11/test1" -NfsHost 10.91.246.21
12.Remove-Datastore
功能:移除指定位置的数据存储。
语法:
Remove-Datastore [-Datastore] <Datastore> [-VMHost] <VMHost> [-Server <VIServer[]>] [-RunAsync] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
Remove-Datastore -Datastore Datastore -VMHost 10.23.112.234 -Confirm:$false
13.Set-Datastore
功能:更改指定数据存储的属性。
语法:
Set-Datastore [-Datastore] <Datastore> [-Name] <String> [-Server <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
Get-Datastore -Name Datastore1 | Set-Datastore -Name Datastore2
14.Get-Datastore
功能:检索vSphere服务器上的数据存储。
语法:
Get-Datastore [-Server <VIServer[]>] [[-Name] <String[]>] [-Datacenter <Datacenter[]>] [-VMHost <VMHost[]>] [-VM <VirtualMachine[]>] [-Entity <VIObject[]>] [-Refresh] [<CommonParameters>]
例子:
(1)
Get-Datastore -VMHost (Get-VMHost -Id HostSystem-host-8)
(2)
$datastores = Get-Datastore | where {$_.type -eq "NFS"}
15.Copy-DatastoreItem
功能:在数据存储和数据存储之间复制本地文件系统。
语法:
Copy-DatastoreItem [-Item] <Object[]> [[-Destination] <Object>] [-Force] [-PassThru] [-Recurse] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
(1)
Copy-DatastoreItem ds:\VM\* c:\VMFolder\VM\
(2)
Copy-DatastoreItem c:\VMFolder\NewVM\* ds:\VM\ -Force
16.Apply-DrsRecommendation
功能:应用指定的DRS设置。
语法:
Apply-DrsRecommendation [-DrsRecommendation] <DrsRecommendation[]> [-RunAsync] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
(1)
Get-DrsRecommendation -Priority 1,2 | Apply-DrsRecommendation
(2)
$drs = Get-DrsRecommendation -Cluster Cluster Apply-DrsRecommendation -DrsRecommendation $drs -RunAsync
17.Get-DrsRecommendation
功能:检索DRS群集可用的设置。
语法:
Get-DrsRecommendation [[-Cluster] <Cluster[]>] [-Refresh] [-Priority <Int32[]>] [-Server <VIServer[]>] [<CommonParameters>]
例子:
(1)
Get-Cluster Cluster | Get-DrsRecommendation -Priority 4,5
(2)
Get-DrsRecommendation -Cluster Cluster –Refresh
18.Get-DrsRule
功能:检索DRS规则指定的集群名单。
语法:
Get-DrsRule [[-Name] <String[]>] [-Cluster] <Cluster[]> [[-VM] <VirtualMachine[]>] [-Server <VIServer[]>] [<CommonParameters>]
例子:
Get-DrsRule -Cluster $cluster -Name "*Rule1*"
19.New-DrsRule
功能:创建一个新的DRS规则。
语法:
New-DrsRule [-Name] <String> [-Cluster] <Cluster[]> [-Enabled [<Boolean>]] -KeepTogether [<Boolean>] -VM <VirtualMachine[]> [-RunAsync] [-Server <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
New-DrsRule -Cluster $cluster -Name antiAffinityRule1 -KeepTogether $false -VM $antiAffinityVMs
201.Remove-DrsRule
功能:删除一个DRS规则。
语法:
Remove-DrsRule [-Rule] <DrsVMAffinityRule[]> [-RunAsync] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
$rules = Get-DrsRule -Cluster $cluster -Name "*Rule1*" Remove-DrsRule $rules -Confirm:$false
21.Set-DrsRule
功能:修改现有的DRS规则。
语法:
Set-DrsRule [[-Enabled] [<Boolean>]] [-Rule] <DrsVMAffinityRule[]> [-Name <String>] [-VM <VirtualMachine[]>] [-RunAsync] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
$vm = Get-VM DrsRuleVM1* Set-DrsRule -Rule $affinityRule -VM $vm -Enabled $true;
功能:检索注释
语法:
Get-Annotation [[-CustomAttribute] <CustomAttribute[]>] [-Entity] <InventoryItem> [-Server <VIServer[]>] [<CommonParameters>]
例子:
Get-Cluster Cluster | Get-Annotation -CustomAttribute PhysicalLocation
2.Set-Annotation
功能:更改指定注释的名称
语法:
Set-Annotation [-Entity] <InventoryItem> [-CustomAttribute] <CustomAttribute> [-Value] <String> [-Server <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
(1)
Set-Annotation -Entity $host -CustomAttribute "PhysicalLocation" -Value SofiaOffice
(2)
Get-Cluster Cluster | Set-Annotation -CustomAttribute "PhysicalLocation" -Value California
3.Get-CustomAttribute
功能:检索自定义属性。
语法:
Get-CustomAttribute [[-Name] <String[]>] [[-TargetType] <CustomAttributeTargetType[]>] [-Global] [-Server <VIServer[]>] [<CommonParameters>]
例子:
Get-CustomAttribute -Name Cluster* -TargetType Cluster
4.New-CustomAttribute
功能:创建一个新的自定义属性。
语法:
New-CustomAttribute [-Name] <String> [[-TargetType] <CustomAttributeTargetType[]>] [-Server <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
New-CustomAttribute -Name "CompanyName" -TargetType VMHost, VirtualMachine
5.Remove-CustomAttribute
功能:删除自定义属性。
语法:
Remove-CustomAttribute [-CustomAttribute] <CustomAttribute[]> [-Server <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
Remove-CustomAttribute -CustomAttribute "CompanyID", "Owner" -Server $agent007
6.Set-CustomAttribute
功能:重命名自定义属性。
语法:
Set-CustomAttribute [-CustomAttribute] <CustomAttribute> [-Name] <String> [-Server <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
Set-CustomAttribute -CustomAttribute "PhysicalLocation" -Name "Area"
7.Remove-CustomField
功能:删除一个特定清单项目类型的新的自定义字段。
语法:
Remove-CustomField [-Entity] <InventoryItem> [-Name] <String> [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
Remove-CustomField -Entity VM -Name CPUMaxLoad
8.New-CustomField
功能:创建一个特定清单项目类型的新的自定义字段。
语法:
New-CustomField [-Entity] <InventoryItem> [-Name] <String> [[-Value] <String>] [-Global] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
New-CustomField -Entity VM -Name CPUMaxLoad -Value 300
9.Set-CustomField
功能:设置为特定的清单项目的自定义字段的值。
语法:
Set-CustomField [-Entity] <InventoryItem> [-Name] <String> [[-Value] <String>] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
Get-VM VM | Set-CustomField -Name CF - Value 10
10.Get-Datacenter
功能:检索存储上提供一个vSphere服务器。
语法:
Get-Datacenter [-VM <VirtualMachine[]>] [-Cluster <Cluster[]>] [-VMHost <VMHost[]>] [-Location <VIContainer[]>] [[-Name] <String[]>] [-Id <String[]>] [-NoRecursion] [-Server <VIServer[]>] [<CommonParameters>]
例子:
Get-Datacenter -Name Datacenter*
11.New-Datastore
功能:创建一个新的数据存储。
语法:
New-Datastore [-Server <VIServer[]>] [-VMHost] <VMHost[]> [-Name] <String> -Path <String> [-Nfs] -NfsHost <String> [-ReadOnly] [-WhatIf] [-Confirm] [<CommonParameters>]
New-Datastore [-Server <VIServer[]>] [-VMHost] <VMHost[]> [-Name] <String> -Path <String> [-Vmfs] [-BlockSizeMB <Int32>] [-WhatIf] [-Confirm] [<CommonParameters>]
New-Datastore [-Server <VIServer[]>] [-VMHost] <VMHost[]> [-Name] <String> -Path <String> -NfsHost <String> [-ReadOnly] [-Cifs] -Username <String> -Password <String> [-WhatIf] [-Confirm] [<CommonParameters>]
New-Datastore [-Server <VIServer[]>] [-VMHost] <VMHost[]> [-Name] <String> -Path <String> [-Local] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
(1)
New-Datastore -Nfs -VMHost 10.23.112.345 -Name Datastore -Path $remotePath -NfsHost $remoteHost
(2)
Get-VMHost | New-Datastore -Nfs -Name NFS1 -Path "/mnt/nfs1/nfs11/test1" -NfsHost 10.91.246.21
12.Remove-Datastore
功能:移除指定位置的数据存储。
语法:
Remove-Datastore [-Datastore] <Datastore> [-VMHost] <VMHost> [-Server <VIServer[]>] [-RunAsync] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
Remove-Datastore -Datastore Datastore -VMHost 10.23.112.234 -Confirm:$false
13.Set-Datastore
功能:更改指定数据存储的属性。
语法:
Set-Datastore [-Datastore] <Datastore> [-Name] <String> [-Server <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
Get-Datastore -Name Datastore1 | Set-Datastore -Name Datastore2
14.Get-Datastore
功能:检索vSphere服务器上的数据存储。
语法:
Get-Datastore [-Server <VIServer[]>] [[-Name] <String[]>] [-Datacenter <Datacenter[]>] [-VMHost <VMHost[]>] [-VM <VirtualMachine[]>] [-Entity <VIObject[]>] [-Refresh] [<CommonParameters>]
例子:
(1)
Get-Datastore -VMHost (Get-VMHost -Id HostSystem-host-8)
(2)
$datastores = Get-Datastore | where {$_.type -eq "NFS"}
15.Copy-DatastoreItem
功能:在数据存储和数据存储之间复制本地文件系统。
语法:
Copy-DatastoreItem [-Item] <Object[]> [[-Destination] <Object>] [-Force] [-PassThru] [-Recurse] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
(1)
Copy-DatastoreItem ds:\VM\* c:\VMFolder\VM\
(2)
Copy-DatastoreItem c:\VMFolder\NewVM\* ds:\VM\ -Force
16.Apply-DrsRecommendation
功能:应用指定的DRS设置。
语法:
Apply-DrsRecommendation [-DrsRecommendation] <DrsRecommendation[]> [-RunAsync] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
(1)
Get-DrsRecommendation -Priority 1,2 | Apply-DrsRecommendation
(2)
$drs = Get-DrsRecommendation -Cluster Cluster Apply-DrsRecommendation -DrsRecommendation $drs -RunAsync
17.Get-DrsRecommendation
功能:检索DRS群集可用的设置。
语法:
Get-DrsRecommendation [[-Cluster] <Cluster[]>] [-Refresh] [-Priority <Int32[]>] [-Server <VIServer[]>] [<CommonParameters>]
例子:
(1)
Get-Cluster Cluster | Get-DrsRecommendation -Priority 4,5
(2)
Get-DrsRecommendation -Cluster Cluster –Refresh
18.Get-DrsRule
功能:检索DRS规则指定的集群名单。
语法:
Get-DrsRule [[-Name] <String[]>] [-Cluster] <Cluster[]> [[-VM] <VirtualMachine[]>] [-Server <VIServer[]>] [<CommonParameters>]
例子:
Get-DrsRule -Cluster $cluster -Name "*Rule1*"
19.New-DrsRule
功能:创建一个新的DRS规则。
语法:
New-DrsRule [-Name] <String> [-Cluster] <Cluster[]> [-Enabled [<Boolean>]] -KeepTogether [<Boolean>] -VM <VirtualMachine[]> [-RunAsync] [-Server <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
New-DrsRule -Cluster $cluster -Name antiAffinityRule1 -KeepTogether $false -VM $antiAffinityVMs
201.Remove-DrsRule
功能:删除一个DRS规则。
语法:
Remove-DrsRule [-Rule] <DrsVMAffinityRule[]> [-RunAsync] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
$rules = Get-DrsRule -Cluster $cluster -Name "*Rule1*" Remove-DrsRule $rules -Confirm:$false
21.Set-DrsRule
功能:修改现有的DRS规则。
语法:
Set-DrsRule [[-Enabled] [<Boolean>]] [-Rule] <DrsVMAffinityRule[]> [-Name <String>] [-VM <VirtualMachine[]>] [-RunAsync] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
$vm = Get-VM DrsRuleVM1* Set-DrsRule -Rule $affinityRule -VM $vm -Enabled $true;
相关文章推荐
- 用命令来操作vSphere:二十一 PowerCLI命令--vShphere服务器(3)
- 用命令来操作vSphere:二十 PowerCLI命令--vShphere服务器(2)
- 用命令来操作vSphere:十二 PowerCLI命令--网络操作(1) 推荐
- 用命令来操作vSphere:十一 PowerCLI命令--虚拟机操作
- 用命令来操作vSphere:二十四 PowerCLI命令--日志/报告/配置
- 用命令来操作vSphere:十七 PowerCLI命令--存储操作
- 用命令来操作vSphere:二十二 PowerCLI命令--虚拟主机操作(1)
- 用命令来操作vSphere:二十三 PowerCLI命令--虚拟主机操作(2)
- 用命令来操作vSphere:十三 PowerCLI命令--网络操作(2)
- 用命令来操作vSphere:十八 PowerCLI命令--资源池操作
- 用命令来操作vSphere:九 VMware vSphere 4.1 PowerCLI
- 用命令来操作vSphere:十五 PowerCLI命令--客户机操作系统
- 用命令来操作vSphere:十六 PowerCLI命令--群集操作
- 用命令来操作vSphere:二十六 PowerCLI脚本—vCheck (日报) 使用方法
- 用命令来操作vSphere:二十九 PowerCLI脚本—生成word报告
- 用命令来操作vSphere: 三十 PowerCLI脚本—自定义站点恢复管理计划
- 用命令来操作vSphere:十四 PowerCLI命令--主机配置文件
- 用命令来操作vSphere:二十七 PowerCLI脚本—谁创建了虚拟机
- 用命令来操作vSphere:二十八 PowerCLI脚本—创建vSwitch端口
- 用命令来操作vSphere:一开启ESXi或ESX中的SSH