用命令来操作vSphere:十二 PowerCLI命令--网络操作(1)

1.get-iscsihbatarget

功能:检索可用的iSCSI HBA的目标。

语法:

Get-IScsiHbaTarget [[-IScsiHba] <IScsiHba[]>] [-Type <IScsiHbaTargetType[]>] [[-IPEndPoint] <String[]>] [-Server <VIServer[]>] [<CommonParameters>]

例子:

Get-IScsiHbaTarget -Address "10.23.84.73" -Type Send

2.new-iscsihbatarget

功能:创建一个新的iSCSI HBA的目标。

语法:

New-IScsiHbaTarget -IScsiHba <IScsiHba[]> [-Address] <String[]> [[-Port] <Int32>] [-Type <IScsiHbaTargetType>] [[-IScsiName] <String>] [-ChapType <ChapType>] [-ChapName <String>] [-ChapPassword <String>] [-MutualChapEnabled [<Boolean>]] [-MutualChapName <String>] [-MutualChapPassword <String>] [-InheritChap [<Boolean>]] [-InheritMutualChap [<Boolean>]] [-Server <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]

例子:

(1)

$hba = Get-VMHost | Get-VMHostHba -Type iScsi New-IScsiHbaTarget -IScsiHba $hba -Address 10.23.84.73 (2) Get-VMHost | Get-VMHostHba -Type iScsi | New-IScsiHbaTarget -Address "10.23.84.73" -ChapType Preferred -ChapName user -ChapPassword pass

 

3.remove-iscsihbatarget

功能:删除iSCSI HBA

语法:

Remove-IScsiHbaTarget [-Target] <IScsiHbaTarget[]> [-Server <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]

例子:

(1)Get-IScsiHbaTarget -Address 10.23.84.73 -Type Send | Remove-IScsiHbaTarget

(2)Remove-IScsiHbaTarget -Target (Get-IScsiHbaTarget -Address 10.23.84.73)

4.set-iscsihbatarget

功能:配置iSCSI HBA

语法:

Set-IScsiHbaTarget -Target <IScsiHbaTarget[]> [-ChapType <ChapType>] [-ChapName <String>] [-ChapPassword <String>] [-MutualChapEnabled [<Boolean>]] [-MutualChapName <String>] [-MutualChapPassword <String>] [-InheritChap [<Boolean>]] [-InheritMutualChap [<Boolean>]] [-Server <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]

例子:

(1)Get-IScsiHbaTarget -Address "10.23.84.73" -Type Static | Set-IScsiHbaTarget -ChapType Prohibited

(2)$target = Get-IScsiHbaTarget -Address "10.23.84.73" -Type Send Set-IScsiHbaTarget -Target $target -ChapType Required -ChapPassword pass1 -MutualChapEnabled -MutualChapPassword pass2

5.get-nicteamingpolicy

功能:检索网卡绑定指定的虚拟交换机和虚拟端口组的策略。

语法:

Get-NicTeamingPolicy [-VirtualSwitch] <VirtualSwitch[]> [<CommonParameters>]
Get-NicTeamingPolicy [-VirtualPortGroup] <VirtualPortGroup[]> [<CommonParameters>]

例子:

(1)

Get-VirtualPortGroup -VMHost (Get-VMHost *.128) -Name Virtual* | Get-NicTeamingPolicy | fl is* (2) Get-VirtualSwitch -VMHost (Get-VMHost *.128) -Name vswitch | Get-NicTeamingPolicy

6.set-nicteamingpolicy

功能:配置指定的网卡绑定的策略。

语法:

Set-NicTeamingPolicy [-VirtualSwitchPolicy] <NicTeamingVirtualSwitchPolicy[]> [-BeaconInterval <Int32>] [-LoadBalancingPolicy <LoadBalancingPolicy>] [-NetworkFailoverDetectionPolicy <NetworkFailoverDetectionPolicy>] [-NotifySwitches [<Boolean>]] [-FailbackEnabled [<Boolean>]] [-MakeNicActive <PhysicalNic[]>] [-MakeNicStandby <PhysicalNic[]>] [-MakeNicUnused <PhysicalNic[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
Set-NicTeamingPolicy [-VirtualPortGroupPolicy] <NicTeamingVirtualPortGroupPolicy[]> [-InheritLoadBalancingPolicy [<Boolean>]] [-InheritNetworkFailoverDetectionPolicy [<Boolean>]] [-InheritNotifySwitches [<Boolean>]] [-InheritFailback [<Boolean>]] [-InheritFailoverOrder [<Boolean>]] [-LoadBalancingPolicy <LoadBalancingPolicy>] [-NetworkFailoverDetectionPolicy <NetworkFailoverDetectionPolicy>] [-NotifySwitches [<Boolean>]] [-FailbackEnabled [<Boolean>]] [-MakeNicActive <PhysicalNic[]>] [-MakeNicStandby <PhysicalNic[]>] [-MakeNicUnused <PhysicalNic[]>] [-WhatIf] [-Confirm] [<CommonParameters>]

例子:

$policy = Get-VirtualSwitch -VMHost (Get-VMHost *.128) -Name vSwitch1 | Get-NicTeamingPolicy $policy | Set-NicTeamingPolicy -LoadBalancingPolicy LoadBalanceSrcMac

7.get-oscustomizationnicmapping

功能:检索配置NIC设置为指定的操作系统定制规范映射。

语法:

Get-OSCustomizationNicMapping [-OSCustomizationSpec] <OSCustomizationSpec[]> [-Server <VIServer[]>] [<CommonParameters>]

例子:

$spec1 = Get-OSCustomizationSpec "test" $spec2 = Get-OSCustomizationSpec "test_old" Get-OSCustomizationNicMapping -OSCustomizationSpec $spec1,$spec2

8.new-oscustomizationnicmapping

功能:添加NIC设置映射到指定的操作系统定制规格。

语法:

New-OSCustomizationNicMapping -OSCustomizationSpec <OSCustomizationSpec[]> [-Server <VIServer[]>] [-IpMode <OSCustomizationIPMode>] [-VCApplicationArgument <String>] [[-IpAddress] <String>] [[-SubnetMask] <String>] [[-DefaultGateway] <String>] [-AlternateGateway <String>] [[-Dns] <String[]>] [-Wins <String[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
New-OSCustomizationNicMapping -OSCustomizationSpec <OSCustomizationSpec[]> [-NetworkAdapterMac <String[]>] [-Server <VIServer[]>] [-IpMode <OSCustomizationIPMode>] [-VCApplicationArgument <String>] [[-IpAddress] <String>] [[-SubnetMask] <String>] [[-DefaultGateway] <String>] [-AlternateGateway <String>] [[-Dns] <String[]>] [-Wins <String[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
New-OSCustomizationNicMapping -OSCustomizationSpec <OSCustomizationSpec[]> [-Position <Int32[]>] [-Server <VIServer[]>] [-IpMode <OSCustomizationIPMode>] [-VCApplicationArgument <String>] [[-IpAddress] <String>] [[-SubnetMask] <String>] [[-DefaultGateway] <String>] [-AlternateGateway <String>] [[-Dns] <String[]>] [-Wins <String[]>] [-WhatIf] [-Confirm] [<CommonParameters>]

例子:

New-OSCustomizationNicMapping -OSCustomizationSpec $spec -IpMode UseStaticIP -IPAddress 10.0.0.1 -SubnetMask 255.255.255.0 -DefaultGateway 10.0.0.253 -DnsServer 10.0.0.253

9.remove-oscustomizationnicmapping

功能:删除指定的操作系统定制网卡映射。

语法:

Remove-OSCustomizationNicMapping [-OSCustomizationNicMapping] <OSCustomizationNicMapping[]> [-WhatIf] [-Confirm] [<CommonParameters>]

例子:

Get-OSCustomization test* | Get-OSCustomizationNicMapping | Remove-OSCustomizationNicMapping -Confrim:$false

10.set-oscustomizationnicmapping

功能:修改网卡提供操作系统定制的映射。

语法:

Set-OSCustomizationNicMapping -OSCustomizationNicMapping <OSCustomizationNicMapping[]> [-Position <Int32>] [-Server <VIServer[]>] [-IpMode <OSCustomizationIPMode>] [-VCApplicationArgument <String>] [[-IpAddress] <String>] [[-SubnetMask] <String>] [[-DefaultGateway] <String>] [-AlternateGateway <String>] [[-Dns] <String[]>] [-Wins <String[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
Set-OSCustomizationNicMapping -OSCustomizationNicMapping <OSCustomizationNicMapping[]> [-NetworkAdapterMac <String>] [-Server <VIServer[]>] [-IpMode <OSCustomizationIPMode>] [-VCApplicationArgument <String>] [[-IpAddress] <String>] [[-SubnetMask] <String>] [[-DefaultGateway] <String>] [-AlternateGateway <String>] [[-Dns] <String[]>] [-Wins <String[]>] [-WhatIf] [-Confirm] [<CommonParameters>]

例子:

(1)

Get-OSCustomizationSpec Spec | Get-OSCustomizationNicMapping | Set-OSCustomizationNicMapping -IpAddress 10.0.0.2 (2) Get-OSCustomizationSpec Spec | Get-OSCustomizationNicMapping | Set-OSCustomizationNicMapping -VcApplicationArgument "subnet2" (3) Get-OSCustomizationSpec Spec | Get-OSCustomizationNicMapping | Set-OSCustomizationNicMapping -IpMode UseStaticIp -IpAddress 10.10.0.1 -SubnetMask 255.255.255.0 -DefaultGateway 10.10.0.1 -AlternateGateway 10.10.0.1 -Dns 10.10.150.1 -PrimaryWins 10.10.150.2 (4) Set-OSCustomizationNicMapping -OSCustomizationNicMapping $nicMapping1, $nicMapping2 -IPMode UseVCApplication -VcApplicationArgument "subnet2"

11.add-passthroughdevice

功能:附加传递到指定的虚拟机设备。

语法:

Add-PassthroughDevice [-VM] <VirtualMachine[]> [-PassthroughDevice] <PassThroughDevice[]> [-Server <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]

例子:

$scsiDeviceList = Get-PassthroughDevice -VMHost Host -Type Scsi Add-PassthroughDevice -VM $vm -PassthroughDevice $scsiDeviceList[0]

12.get-passthroughdevice

功能:检索传递指定的主机,可用的虚拟机设备和模板。

语法:

Get-PassthroughDevice [-VM <VirtualMachine[]>] [-VMHost <VMHost[]>] [-Template <Template[]>] [[-Type] <PassthroughDeviceType>] [[-Name] <String[]>] [-Server <VIServer[]>] [<CommonParameters>]

例子:

Get-PassthroughDevice -VMHost Host -Type Scsi

13.remove-passthroughdevice

功能:删除指定的传递装置。

语法:

Remove-PassthroughDevice [-PassthroughDevice] <PassThroughDevice[]> [-WhatIf] [-Confirm] [<CommonParameters>]

例子:

Get-PassthroughDevice -VM VM | Remove-PassthroughDevice

14.get-scsilun

功能:检索SCSI设备上的vSphere服务器上可用。

语法:

Get-ScsiLun [[-CanonicalName] <String[]>] [-VmHost] <VMHost[]> [-Key <String[]>] [-LunType <String[]>] [-Server <VIServer[]>] [<CommonParameters>]
Get-ScsiLun [[-CanonicalName] <String[]>] [-Hba] <Hba[]> [-Key <String[]>] [-LunType <String[]>] [-Server <VIServer[]>] [<CommonParameters>]
Get-ScsiLun [[-CanonicalName] <String[]>] [-Datastore] <Datastore[]> [-Key <String[]>] [-LunType <String[]>] [-Server <VIServer[]>] [<CommonParameters>]

例子:

(1)

Get-ScsiLun -VMHost 10.23.123.100 -LunType disk

(2)

Get-VMHost | Get-ScsiLun -CanonicalName "naa.*" (3) $hba = Get-VMHost | Get-VMHostHba -Type ParallelScsi Get-ScsiLun -Hba $hba -LunType disk (4) Get-ScsiLun -Datastore Datastore -Key "key-vim.host.ScsiDisk-*"

15.set-scsilun

功能:配置一个SCSI设备。

语法:

Set-ScsiLun [[-MultipathPolicy] <ScsiLunMultipathPolicy>] [[-PreferredPath] <ScsiLunPath>] [-ScsiLun] <ScsiLun> [-CommandsToSwitchPath <Int32>] [-BlocksToSwitchPath <Int32>] [-NoCommandsSwitch] [-NoBlocksSwitch] [-WhatIf] [-Confirm] [<CommonParameters>]

例子:

$scsilun = Get-ScsiLun -VMHost 10.23.123.100 -LunType disk Set-ScsiLun -ScsiLun $scsilun -CommandsToSwitchPath 100

16.get-scsilunpath

功能:检索vmhba路径列表中的一个指定的SCSI设备。

语法:

Get-ScsiLunPath [[-Name] <String[]>] [-ScsiLun] <ScsiLun[]> [<CommonParameters>]

例子:

$scsilun = Get-ScsiLun -VMHost 10.23.123.100 -LunType disk Get-ScsiLunPath $scsilun

17.set-scsilunpath

功能:配置一个vmhba路径的SCSI设备。

语法:

Set-ScsiLunPath [[-Active] [<Boolean>]] [-ScsiLunPath] <ScsiLunPath> [-Preferred] [-WhatIf] [-Confirm] [<CommonParameters>]

例子:

$scsilun = Get-ScsiLun -VMHost 10.23.123.100 -LunType disk

$scsipath = Get-ScsiLunPath -ScsiLun $scsilun

Set-ScsiLunPath -ScsiLunPath $sp -Preferred $true

18.get-virtualportgroup

功能:检索主机,虚拟机和虚拟交换机可用的端口组。

语法:

Get-VirtualPortGroup [[-VMHost] <VMHost[]>] [-VM <VirtualMachine[]>] [-VirtualSwitch <VirtualSwitchBase[]>] [-Name <String[]>] [-Datacenter <Datacenter[]>] [-Standard] [-Distributed] [-Server <VIServer[]>] [<CommonParameters>]

例子:

$vswitch = New-VirtualSwitch -VMHost 10.23.112.123 -Name VSwitch New-VirtualPortGroup -VirtualSwitch $vswitch -Name PortGroup Get-VirtualPortGroup -VirtualSwitch $vswitch

19.new-virtualportgroup

功能:创建一个指定主机上的新的端口组。

语法:

New-VirtualPortGroup [-Name] <String> [-VirtualSwitch] <VirtualSwitch> [-VLanId <Int32>] [-WhatIf] [-Confirm] [<CommonParameters>]

例子:

$vswitch = New-VirtualSwitch -VMHost 10.23.114.234 -Name VSwitch $vportgroup = New-VirtualPortGroup -VirtualSwitch $vswitch -Name VPortGroup

20.remove-virtualportgroup

功能:删除指定的虚拟端口组。

语法:

Remove-VirtualPortGroup [-VirtualPortGroup] <VirtualPortGroup[]> [-WhatIf] [-Confirm] [<CommonParameters>]

例子:

$vswitch = New-VirtualSwitch -VMHost 10.23.112.234 -Name VirtualSwitch $vportgroup = New-VirtualPortGroup -VirtualSwitch $vswitch -Name VPortGroup Remove-VirtualPortGroup -VirtualPortGroup $vportgroup

21.set-virtualportgroup

功能:更改指定虚拟端口组的属性。

语法:

Set-VirtualPortGroup [-Name <String>] [-VLanId <Int32>] [-VirtualPortGroup] <VirtualPortGroup> [-WhatIf] [-Confirm] [<CommonParameters>]

例子:

$vswitch = New-VirtualSwitch -VMHost 10.23.112.36 -Name VSwitch $vportgroup1 = New-VirtualPortGroup -VirtualSwitch $vswitch -Name VPortGroup1 $vportgroup2 = Set-VirtualPortGroup -VirtualPortGroup $vportgroup1 -VLanId 1

22.get-virtualswitch

功能:检索与一个虚拟机主机或虚拟机使用的虚拟交换机。

语法:

Get-VirtualSwitch [[-VMHost] <VMHost[]>] [[-VM] <VirtualMachine[]>] [-Datacenter <Datacenter[]>] [-Name <String[]>] [-Standard] [-Distributed] [-Server <VIServer[]>] [<CommonParameters>]

例子:

Get-VirtualSwitch -VM VM

23.new-virtualswitch

功能:创建一个新的虚拟交换机。

语法:

New-VirtualSwitch [-VMHost] <VMHost> [-Name] <String> [[-NumPorts] <Int32>] [[-Nic] <PhysicalNic[]>] [[-Mtu] <Int32>] [-Server <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]

例子:

(1)

$vswitch = New-VirtualSwitch -VMHost 10.23.112.234 -Name VSwitch (2) $network = Get-VMHostNetwork -VMHost 10.23.112.234 $phNic = $network.PhysicalNic[0].DeviceName $vswitch = New-VirtualSwitch -VMHost 10.23.112.234 -Name VSwitch -Nic $phNic (3) Get-VMHost *.128 | New-VirtualSwitch -Name VSwitch -Nic vmnic5,vmnic6

24.remove-virtualswitch

功能:删除指定的虚拟交换机。

语法:

Remove-VirtualSwitch [-VirtualSwitch] <VirtualSwitch[]> [-WhatIf] [-Confirm] [<CommonParameters>]

例子:

$vswitch = New-VirtualSwitch -VMHost 10.23.122.145 -Name VirtualSwitch Remove-VirtualSwitch -VirtualSwitch $vswitch

25.set-virtualswitch

功能:设置指定的虚拟交换机的属性。

语法:

Set-VirtualSwitch [-VirtualSwitch] <VirtualSwitch> [[-NumPorts] <Int32>] [[-Nic] <String[]>] [[-Mtu] <Int32>] [-WhatIf] [-Confirm] [<CommonParameters>]

例子:

(1)

$vswitch = New-VirtualSwitch -Host 10.23.115.67 -Name VSwitch Set-VirtualSwitch -VirtualSwitch $vswitch -MTU 500 (2) $vswitch = New-VirtualSwitch -Host 10.23.115.67 -Name VSwitch $network = Get-VMHostNetwork -VMHost 10.23.115.67 $phNic = $network.PhysicalNic[0] Set-VirtualSwitch -VirtualSwitch $vswitch -Nic $phNic (3) Get-VMHost *.128 | Get-VirtualSwitch | Select-Object -First 1 | Set-VirtualSwitch -Nic vmnic5

26.set-vitoolkitconfiguration或Set-PowerCLIConfiguration

功能:修改vSphere PowerCLI配置。

语法:

Set-PowerCLIConfiguration [-ProxyPolicy <ProxyPolicy>] [-DefaultVIServerMode <DefaultVIServerMode>] [-WhatIf] [-Confirm] [<CommonParameters>]

例子:

(1)

Set-PowerCLIConfiguration -ProxyPolicy NoProxy –Confirm (2) Set-PowerCLIConfiguration -DefaultVIServerMode multiple ?Confirm (3) Set-PowerCLIConfiguration -ProxyPolicy NoProxy -DefaultVIServerMode Single

你可能感兴趣的:(休闲,功能,vsphere,PowerCLI,网络操)