实用 —— PowerCLI (一)
?
近來,安裝過較多產(chǎn)品,深感疲乏,猶如農(nóng)民伯伯在家研究種子,卻不種到地里,還不如往地里丟蠶豆,任其生長(zhǎng),還有收成。
于是,想做一些拿來就能用的文檔,方便學(xué)習(xí),《實(shí)用——PowerCLI》系列就是這樣。
?
現(xiàn)在沒有大綱,寫到哪,算到哪,形式為命令+截圖。
?
一、PowerCLI基礎(chǔ)命令
二、PowerCLI之快照
三、PowerCLI之ESXi
?
Powercli是一個(gè)命令行自動(dòng)化和腳本工具,它為VMware公司的vSphere和vCloud產(chǎn)品提供了一個(gè)的Windows?PowerShell接口。
Powercli包括高級(jí)命令,和低級(jí)別vSphere和vCloud?API的訪問
?
Powercli的安裝在前面博客介紹過,這里提供鏈接http://virtualbox.blog.51cto.com/531002/978907
?
在VMware?Community社區(qū)的WorkShop里,包括了很多基礎(chǔ)的腳本例子,我們先從這里開始
1、默認(rèn)界面
?
2、
# To see what PowerCLI can do, start with Get-VICommand # 查看PowerCLI能做哪些 Get-VICommand?
3、
# There are more than 150 commands, called "cmdlets".That's a lot! You can narrow your search based on something that interests you. #有超過150個(gè)叫“cmdlets”的命令行, 您可以根據(jù)你的興趣縮小搜索范圍 Help *VM*?
4、
# You can also use "help" to narrow your search. Let's say you want to do something with virtual switches. #你還可以使用”help”來縮小搜索范圍, 讓我們來搜小搜索virtualswitchs的訪問 。 help *virtualswitch*#?查看虛擬交換機(jī)幫助
help?Get-VirtualSwitch
5、
# Or maybe you care about firewall rules. #或者你可以看下防火墻相關(guān)的命令 help *firewall*?
6、
# Cmdlets exist to get all your favorite objects. #Cmdlets存在一些你很感興趣的對(duì)象 Get-Datacenter Get-VMHost Get-Cluster Get-VM?
7、
# These commands are made to work with each other.You can easily use a sequence of them to filter. #這些命令是相互作用的 ,你可以很輕松的進(jìn)行過濾選擇 Get-VMHost?
8、
?
9、
# We can easily identify the datastore a VM is on. #我們可以很容易識(shí)別虛擬機(jī)在哪個(gè)數(shù)據(jù)存儲(chǔ)上 Get-VM vCenter Get-VM vCenter | Get-Datastore?
10、
# We can even go the other way. #我們甚至可以走另外一條路,查看數(shù)據(jù)存儲(chǔ)上有哪些虛擬機(jī) Get-Datastore 20storage | Get-VM?
?
11、
# Objects are formatted when they are printed to the screen.But, there may be more to them than what you see with default output. #輸出屏幕上時(shí)它們被表格化 ,但是,默認(rèn)輸出的比你想看的多 Get-Datastore Get-Datastore | Format-Table * Get-Datastore | Format-List *?
12、
# Some objects are rich with properties. #一些項(xiàng)目有豐富的內(nèi)容 Get-VM | Format-List *?
13、
#可以延伸下,客戶說只看指定的虛擬機(jī)AD-25的虛擬機(jī)信息。 Get-VM AD-25 | Format-List *
14、
# Use the Select cmdlet to choose just the stuff you care about. #使用cmdlet去選擇你關(guān)心的東西 Get-VM | Select Name, Host, NumCpu, MemoryMB, HARestartPriority | Format-Table?
?
?
?
下載地址(最新版本未PowerCli?5.5,Get-PowerCLIVersion)
https://developercenter.vmware.com/web/dp/sdk/55/vsphere-powercli
轉(zhuǎn)載于:https://blog.51cto.com/virtualbox/1358364
總結(jié)
以上是生活随笔為你收集整理的实用 —— PowerCLI (一)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: flashback_transactio
- 下一篇: Ubuntu 中启用 root 帐号
