LoginSignup
4
3

More than 5 years have passed since last update.

RHEL7.2にPowerCLI coreをインストール

Last updated at Posted at 2016-11-24

RHEL7.2にPowerCLI coreをインストールしてみました。
PowerCLI Coreのダウンロードはこちらから。

前提

主だったものとして以下の環境で実施しました。

  • Red Hat Enterprise Linux 7.2
  • インターネット接続あり
  • インストールメディアからyumが実行できる

PowerShellのインストール

PowerCLI coreを使用するためにはPowerShellが必要なので最初にインストールします。

PowerShellのrpmパッケージをダウンロード。

# wget https://github.com/PowerShell/PowerShell/releases/download/v6.0.0-alpha.13/powershell-6.0.0_alpha.13-1.el7.centos.x86_64.rpm

DVD(/mediaにマウント済み)からyumができるようにするために
/etc/yum.repos.d/media.repoファイルを以下の内容で作成。

[media]
name=media
baseurl=file:///media/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

PowerShelのrpmパッケージをインストール。

# yum localinstall powershell-6.0.0_alpha.13-1.el7.centos.x86_64.rpm`

PowerCLI coreのインストール

以下のディレクトリを作成。

# mkdir /root/.local/share/powershell/Modules

PowerCLI coreのzipファイルをこのディレクトリに移動。

# mv PowerCLI_Core.zip /root/.local/share/powershell/Modules

zipファイルを解凍

# cd /root/.local/share/powershell/Modules
# unzip PowerCLI_Core.zip

展開されて出てきたzipファイルもさらに解凍

# unzip PowerCLI.ViCore.zip
# unzip PowerCLI.Vds.zip

実行

PowerShellの実行。

# powershell
PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.
PS /root>

PowerCLIはzipファイルに含まれていたStart-PowerCLI.ps1から起動。

PS /root> ./.local/share/powershell/Modules/Start-PowerCLI.ps1
          Welcome to VMware vSphere PowerCLI!

Log in to a vCenter Server or ESX host:              Connect-VIServer
To find out what commands are available, type:       Get-VICommand
Once you've connected, display all virtual machines: Get-VM

       Copyright (C) VMware, Inc. All rights reserved.


PS /root>

これでConnect-VIserverでESXiに接続するとエラーになりました。

PS /root> Connect-VIServer -Server 192.168.1.10

Specify Credential
Please specify server credential
User: root
Password for user root: ********

Connect-VIServer : YYYY/MM/DD h:mm:ss   Connect-VIServer                The libcurl library in use (7.29.0) and its SSL backend ("NSS/
3.16.2.3 Basic ECC") do not support custom handling of certificates. A libcurl built with OpenSSL is required.
At line:1 char:1
+ Connect-VIServer -Server 192.168.1.10
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Connect-VIServer], ViError
    + FullyQualifiedErrorId : Client20_ConnectivityServiceImpl_Reconnect_Exception,VMware.VimAutomation.ViCore.Cmdlet
   s.Commands.ConnectVIServer

PS /root>

この対処としてlibcurl-opensslのrpmパッケージをインストール。

# wget http://ftp.riken.jp/Linux/cern/centos/7/cern/x86_64/Packages/libcurl-openssl-7.51.0-2.1.el7.cern.x86_64.rpm
# yum localinstall libcurl-openssl-7.51.0-2.1.el7.cern.x86_64.rpm

さらに以下のスクリプトを作成。

#!/bin/bash
export LD_LIBRARY_PATH=/opt/shibboleth/lib64/:$LD_LIBRARY_PATH
powershell

作成したスクリプトからpowershellを実行。

# sh powercli.sh
PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.

PS /root>

モジュールのインポートと証明書のエラー無視設定

PS /root> Get-Module -ListAvailable PowerCLI* | Import-Module
PS /root> Set-PowerCLIConfiguration -InvalidCertificateAction Ignore

Connect-VIServerすると今度は成功しました

PS /work> Connect-VIServer -server 192.168.1.10

Specify Credential
Please specify server credential
User: root
Password for user root: ********


Name                           Port  User
----                           ----  ----
192.168.1.10                   443   root
4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3