1. 程式人生 > >CentOS7 安裝執行 VmwareCore

CentOS7 安裝執行 VmwareCore

powershell core vmware centos7

過去2年開始微軟一直在沸沸揚揚地宣傳PowerShell core,可以允許Windows的管理員在Linux/OSX 平臺執行Powershell的管理命令。很多第三方的廠商也紛紛推出了自己的管理模塊。不過對比起Windows下面的Powershell,Powershell core現在支持的模塊實在太少,存在的bug也很多,所以之前豆子稍微試試發現不靠譜就沒繼續了。

前兩天發現用新版本的PowerShell core 和 Vmware core模塊了,下載試試看,發現之前的一些bug已經修復,安裝也容易了很多,安裝庫裏面都已經準備好了,不需要像之前的版本去編譯。

登錄CentOS 7, 直接執行yum就可以安裝最新版本的Powershell core了

 [root@sydnagios psl-omi-provider]# yum install powershell
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: centos.mirror.serversaustralia.com.au
 * epel: mirror.nsw.coloau.com.au
 * extras: centos.mirror.serversaustralia.com.au
 * updates: centos.mirror.serversaustralia.com.au
Package powershell-6.1.0~preview.1-1.rhel.7.x86_64 already installed and latest version
Nothing to do

然後執行 pwsh就可以打開powershell core的控制臺


[root@sydnagios psl-omi-provider]# pwsh
PowerShell v6.1.0-preview.1
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/pscore6-docs
Type ‘help‘ to get help.

PS /tmp/psl-omi-provider> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.1.0-preview.1
PSEdition                      Core
GitCommitId                    v6.1.0-preview.1
OS                             Linux 3.10.0-514.10.2.el7.x86_64 #1 SMP Fri Mar 3 00:04:05 UTC 2017
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

然後在Powershell core的控制臺下直接安裝Vmware PowerCli core就行了

PS /tmp/psl-omi-provider> Install-Module -Name Vmware.PowerCli

安裝完畢之後確認一下 就可以執行相關命令了


PS /tmp/psl-omi-provider> Connect-VIServer sydvcs2012
WARNING: Please consider joining the VMware Customer Experience Improvement Program, so you can help us make PowerCLI a better product. You can join using the following command:

Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP $true

VMware‘s Customer Experience Improvement Program ("CEIP") provides VMware with information that enables VMware to improve its products and services, to fix problems, and to advise you on how best to deploy and use our products.  As part of the CEIP, VMware collects technical information about your organization?s use of VMware products and services on a regular basis in association with your organization?s VMware license key(s).  This information does not personally identify any individual.

For more details: type "help about_ceip" to see the related help article.

測試一下命令,輸出某個主機當前的內存狀態,成功

PS /tmp/psl-omi-provider> get-vmhost sydesx5.omnicom.com.au | get-stat -Realtime -MaxSamples 1 -memory                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    MetricId                Timestamp                          Value Unit     Instance                                                                                                                                                                                                                                           --------                ---------                          ----- ----     --------                                                                                                                                                                                                                                           mem.usage.average       9/04/18 1:57:40 pm                 52.15 %
mem.active.average      9/04/18 1:57:40 pm               6190728 KB
mem.vmmemctl.average    9/04/18 1:57:40 pm                     0 KB
mem.granted.average     9/04/18 1:57:40 pm              75877672 KB

CentOS7 安裝執行 VmwareCore