一、PowerCLI基础命令

二、PowerCLI之快照

三、PowerCLI之ESXi

 

 

 

虚拟机运行在ESXi之上,是虚拟机稳定运行的基础

1、

# pick a particular host./选择特定主机
$h = get-vmhost 10.132.97.19

 

实用 —— PowerCLI (三)_esxi

2、

# Let's take a look at advanced configuration options.
#查看主机高级配置,非常多参数,所以带个more会按照窗口显示
$h | Get-VMHostAdvancedConfiguration | more

 

实用 —— PowerCLI (三)_tim2009_02

3、

# That's a lot of stuff! How many options are there exactly?
#非常多参数,有多少选项是你需要的选择的
$h | Get-VMHostAdvancedConfiguration | Measure-Object

 

实用 —— PowerCLI (三)_powercli_03

 

4、

# That's not right??? Something is funny about the object. Let's take a closer look at it.
#如果没有你需要的,我们可以更精细的查看
$config = $h | Get-VMHostAdvancedConfiguration
$config | Get-Member

 

实用 —— PowerCLI (三)_tim2009_04

5、

# How do we get a specific value? 来看下我们怎样获取一些指定的参数值
$config."Cpu.MoveCurrentRunnerPcpus"

 

实用 —— PowerCLI (三)_powercli_05

6、

# Let's count the number of advanced options.
#让我们来统计高级选项的数量
$config.Keys | measure-object

 

实用 —— PowerCLI (三)_tim2009_06

7、

# Use case: NFS tuning.
# Let's set the max NFS heartbeat failures to 20 across all our hosts.
$h | Get-VMHostAdvancedConfiguration | select -expand Keys | Where { $_ -like "NFS*" }

 

实用 —— PowerCLI (三)_vsphere_07

8、

# Now let's change some settings.
# Set-VMHostAdvancedConfiguration is easy compared to Get-
# Get-VMHost | Set-VMHostAdvancedConfiguration -name NFS.HeartbeatMaxFailures -Value 10

 

实用 —— PowerCLI (三)_powercli_08

9、

# Increase the heap size to 30mb.这些命令都比较方便,不用在图形界面点过来点过去,
#为后期的自动化脚本实现提供基础命令
Get-VMHost | Set-VMHostAdvancedConfiguration -name Net.TcpipHeapSize -Value 30

 

实用 —— PowerCLI (三)_vsphere_09

10、

# Setting DNS is easy with Set-VMHostNetwork
Get-VMHost | Get-VMHostNetwork | Set-VMHostNetwork -DnsAddress 10.132.97.25

 

实用 —— PowerCLI (三)_powercli_10

# Hostname, ConsoleGateway, DNSAddress ,  IP, SubnetMask, ConsoleGateway, DNSAddress, Devicename  选择的参数非常之多
Get-VMHost | Get-VMHostNetwork | Select Hostname, PortGroupName, IP

实用 —— PowerCLI (三)_esxi_11

 

谢谢,感兴趣可以继续跟文。