本文共 4047 字,大约阅读时间需要 13 分钟。
过去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 powershellLoaded plugins: fastestmirror, langpacksLoading 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.auPackage powershell-6.1.0~preview.1-1.rhel.7.x86_64 already installed and latest versionNothing to do
然后执行 pwsh就可以打开powershell core的控制台
[root@sydnagios psl-omi-provider]# pwshPowerShell v6.1.0-preview.1Copyright (c) Microsoft Corporation. All rights reserved.https://aka.ms/pscore6-docsType 'help' to get help.PS /tmp/psl-omi-provider> $PSVersionTableName Value---- -----PSVersion 6.1.0-preview.1PSEdition CoreGitCommitId v6.1.0-preview.1OS Linux 3.10.0-514.10.2.el7.x86_64 #1 SMP Fri Mar 3 00:04:05 UTC 2017Platform UnixPSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}PSRemotingProtocolVersion 2.3SerializationVersion 1.1.0.1WSManStackVersion 3.0
然后在Powershell core的控制台下直接安装Vmware PowerCli core就行了
PS /tmp/psl-omi-provider> Install-Module -Name Vmware.PowerCli
安装完毕之后确认一下 就可以执行相关命令了
PS /tmp/psl-omi-provider> Connect-VIServer sydvcs2012WARNING: 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 $trueVMware'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 KBmem.vmmemctl.average 9/04/18 1:57:40 pm 0 KBmem.granted.average 9/04/18 1:57:40 pm 75877672 KB
转载地址:http://rppoo.baihongyu.com/