Armbianの初期設定項目


いつもなんとなくやっちゃってるArmbianの初期設定
忘れないようにメモ書きを作成

その1: rootの初期パスワード
「1234」
初回ログイン時に変更する

その2: とりあえずOSアップデート
Armbian自体の更新+Ubuntu/Debianの更新を実施
「apt-get update」「apt-get upgrade」

その3: NFSクライアントインストール
うちの環境ではOrange Pi Plus2によるNFSサーバがあり、データ共有をしているのでnfs-commonをインストール
「apt-get install nfs-common」

その4: Locale/Timezone設定
言語設定
「dpkg-reconfigure locales」
タイムゾーン設定
「dpkg-reconfigure tzdata」
キーボードの言語設定(キー配列)
「dpkg-reconfigure keyboard-configuration」

その5:動作CPU範囲設定
ファイル「/etc/default/cpufrequtils」にて記載。
機種によって異なり、Orange Pi Oneでは下記の様に、「480MHz~1200MHz」がCPUの動作範囲となる

ENABLE=true
MIN_SPEED=480000
MAX_SPEED=1200000
GOVERNOR=interactive

ファイルを編集した場合は、「service cpufrequtils restart」で適用

Power Shell Core 6.0をCentOS7で使ってみる


2017/02/01にPowerShell Core 6.0がLinux環境向けにもリリースされた
Installing latest PowerShell Core 6.0 Release on Linux just got easier!

PowerShellの開発はGithubの「https://github.com/PowerShell/PowerShell」で行われており、導入手順も書かれている。
github上の「Linux向けインストール手順」では、直接RPMファイル/debファイルを指定してインストールする、というものが記載されている。

しかし、「Installing latest PowerShell Core 6.0 Release on Linux just got easier!」の記事の中では、yumやaptなどでプログラムの更新をサポートする形でのインストール手順が示されている。

CentOS7だと下記のようになる

# curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/microsoft.repo
# yum install powershell
#

実際に実行してみると下記の様になります。

[root@blog ~]# curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/microsoft.repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   193  100   193    0     0    209      0 --:--:-- --:--:-- --:--:--   210
[root@blog ~]# yum install powershell
読み込んだプラグイン:fastestmirror, langpacks
packages-microsoft-com-prod                              | 2.9 kB     00:00
packages-microsoft-com-prod/primary_db                     | 9.9 kB   00:00
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: ftp.riken.jp
 * extras: ftp.iij.ad.jp
 * updates: ftp.iij.ad.jp
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ powershell.x86_64 0:6.0.0_alpha.15-1.el7.centos を インストール
--> 依存性の処理をしています: uuid のパッケージ: powershell-6.0.0_alpha.15-1.el7.centos.x86_64
--> 依存性の処理をしています: libicu のパッケージ: powershell-6.0.0_alpha.15-1.el7.centos.x86_64
--> 依存性の処理をしています: libunwind のパッケージ: powershell-6.0.0_alpha.15-1.el7.centos.x86_64
--> トランザクションの確認を実行しています。
---> パッケージ libicu.x86_64 0:50.1.2-15.el7 を インストール
---> パッケージ libunwind.x86_64 2:1.1-5.el7_2.2 を インストール
---> パッケージ uuid.x86_64 0:1.6.2-26.el7 を インストール
--> 依存性解決を終了しました。

依存性を解決しました

================================================================================
 Package   アーキテクチャー
                  バージョン                  リポジトリー                 容量
================================================================================
インストール中:
 powershell
           x86_64 6.0.0_alpha.15-1.el7.centos packages-microsoft-com-prod  39 M
依存性関連でのインストールをします:
 libicu    x86_64 50.1.2-15.el7               base                        6.9 M
 libunwind x86_64 2:1.1-5.el7_2.2             base                         56 k
 uuid      x86_64 1.6.2-26.el7                base                         55 k

トランザクションの要約
================================================================================
インストール  1 パッケージ (+3 個の依存関係のパッケージ)

総ダウンロード容量: 46 M
インストール容量: 64 M
Is this ok [y/d/N]: y
Downloading packages:
(1/4): uuid-1.6.2-26.el7.x86_64.rpm                        |  55 kB   00:00
(2/4): libunwind-1.1-5.el7_2.2.x86_64.rpm                  |  56 kB   00:00
(3/4): libicu-50.1.2-15.el7.x86_64.rpm                     | 6.9 MB   00:04
warning: /var/cache/yum/x86_64/7/packages-microsoft-com-prod/packages/powershell-6.0.0_alpha.15-1.el7.centos.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID be1229cf: NOKEY
powershell-6.0.0_alpha.15-1.el7.centos.x86_64.rpm の公開鍵がインストールされていません
(4/4): powershell-6.0.0_alpha.15-1.el7.centos.x86_64.rpm   |  39 MB   00:21
--------------------------------------------------------------------------------
合計                                               2.2 MB/s |  46 MB  00:21
https://packages.microsoft.com/keys/microsoft.asc から鍵を取得中です。
Importing GPG key 0xBE1229CF:
 Userid     : "Microsoft (Release signing) <gpgsecurity@microsoft.com>"
 Fingerprint: bc52 8686 b50d 79e3 39d3 721c eb3e 94ad be12 29cf
 From       : https://packages.microsoft.com/keys/microsoft.asc
上記の処理を行います。よろしいでしょうか? [y/N]y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  インストール中          : uuid-1.6.2-26.el7.x86_64                        1/4
  インストール中          : 2:libunwind-1.1-5.el7_2.2.x86_64                2/4
  インストール中          : libicu-50.1.2-15.el7.x86_64                     3/4
  インストール中          : powershell-6.0.0_alpha.15-1.el7.centos.x86_64   4/4
  検証中                  : powershell-6.0.0_alpha.15-1.el7.centos.x86_64   1/4
  検証中                  : libicu-50.1.2-15.el7.x86_64                     2/4
  検証中                  : 2:libunwind-1.1-5.el7_2.2.x86_64                3/4
  検証中                  : uuid-1.6.2-26.el7.x86_64                        4/4

インストール:
  powershell.x86_64 0:6.0.0_alpha.15-1.el7.centos

依存性関連をインストールしました:
  libicu.x86_64 0:50.1.2-15.el7         libunwind.x86_64 2:1.1-5.el7_2.2
  uuid.x86_64 0:1.6.2-26.el7

完了しました!
[root@blog ~]#

が・・・
私の環境では、いつもの癖で「ls」と実行してしまったら・・・

bash-4.2$ ls
11-0-1-0048_SAS_FW_Image_1-40-342-1650.zip  MegaSAS.log  sql  web  work
bash-4.2$ powershell
PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.

PS /home/osakanataro> ls
11-0-1-0048_SAS_FW_Image_1-40-342-1650.zip  MegaSAS.log  sql  web  work
(ここで応答が無くなる)

ん???
UNIX系コマンドをPowerShellから実行した場合の動作に難有りなのかも?

PS /home/osakanataro> Get-Item *| ForEach-Object { $_ }


    Directory: /home/osakanataro


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-r---       2017/02/06     17:35                sql
d-----       2017/02/03     19:08                web
d-----       2017/02/03     19:19                work
------       2017/01/04     13:01        1528036 11-0-1-0048_SAS_FW_Image_1-40-
                                                 342-1650.zip
--r---       2017/01/04     13:07            390 MegaSAS.log

PS /home/osakanataro> dir


    Directory: /home/osakanataro


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-r---       2017/02/06     17:35                sql
d-----       2017/02/03     19:08                web
d-----       2017/02/03     19:19                work
------       2017/01/04     13:01        1528036 11-0-1-0048_SAS_FW_Image_1-40-
                                                 342-1650.zip
--r---       2017/01/04     13:07            390 MegaSAS.log


PS /home/osakanataro>

PwerShellらしいこと、ということで、下記の処理をやってみる

PS /home/osakanataro> $results=Get-Item *| ForEach-Object { $_ }
PS /home/osakanataro> $results | Export-Csv test.csv -Encoding UTF  (タブ補完で候補を出す)
UTF32  UTF7   UTF8
PS /home/osakanataro> $results | Export-Csv test.csv -Encoding UTF8 -No  (タブ補完で候補を出す)
NoClobber          NoOverwrite        NoTypeInformation
PS /home/osakanataro> $results | Export-Csv test.csv -Encoding UTF8 -NoTypeInformation
PS /home/osakanataro>

出力結果のcsvは、Windows上のPowerShellで実行した場合と同じ書式のモノとなりました。

$PSVersionTableの内容は下記のようになっていました。

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.0.0-alpha
PSEdition                      Core
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   3.0.0.0
GitCommitId                    v6.0.0-alpha.15
CLRVersion
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

以下はおまけ。
Microsoftのレポジトリとして指定されている「https://packages.microsoft.com/rhel/7/prod/」とか「https://packages.microsoft.com/config/rhel/7/」を見ていくとなかなか面白い
https://packages.microsoft.com/config/rhel/7/mssql-server.repo」という用にCentOS7向けのMSSQL Serverっぽいレポジトリファイルがある。RPMファイルは「https://packages.microsoft.com/rhel/7/mssql-server/」にある。

MSSQL Serverのインストール手順については「Install SQL Server on Linux」を参照のこと。

Allwinner H5搭載Orange Pi PC2向けにArmbianの開発中版が出た


Allwinner H5搭載のOrange Pi PC2で動くLinux OSは、Orange Pi公式が出しているDebianとUbuntuだけでした。

Orange Pi公式の問題点は1つ。
kernelのアップデート提供実績がほぼ無い。
ある場合はOSイメージまるごと配布。

こんなんじゃ、継続運用に使えないわけです。
Allwinner系を中心にARM SoC向けにDebian/Ubuntuベースのディストリビューションとして「Armbian」というものがあります。
Allwinner H3搭載のOrange Pi向けも各機種出てますが、この度、Orange Pi PC2向けも登場しました。

Armbain for Orange Pi PC2

現状は、まだNightly版ということで開発中のモノしかありません。
「Warning: nightly downloads are automated untested builds and no end user support is provided for them!」とあるように、とりあえず出している、というやつです。

しかしながら、X-Windowが表示されるDesktop版も、しばらく使ってみた感じでは問題無く動いているようですし、一般的な用途では使えそうです。
ただ、ヒートシンクもしくは冷却ファンが必須です。
標準状態ではかなり発熱します。

2017/02/07時点でダウンロード可能な「Armbian_5.24.170202_Orangepipc2_Ubuntu_xenial_dev_4.10.0_desktop.7z」は、Ubuntu 16.04.1で、Linux kernelは4.10.0と、現在開発中の最新Linux kernelをベースとしています。

MegaRAID SAS 8708EM2のfirmware updateをstorcliで行う


NEC Express 5800で使われているSAS RAIDカードのN8103-117のfirmwareをアップデートしてみた。
詳しくは後述するが、NEC提供のfirmwareではなく、OEM元のLSI Logicが提供する最新firmwareの適用を行った。

NECでは「RAIDコントローラファームウェアアップデートモジュール(1.12.152-0589)」として配布しているもののromファイルの中身を見ると「VERSIONS=APP_1.12.152-0589,~ PACKAGE=8.0.1-0051 VALIDATION=GCA_02/25/09_12:32:30」となっている。
それに対して、LSIの最新firmwareは「VERSIONS=APP_1.40.342-1650,~ PACKAGE=11.0.1-0048 VALIDATION=GCA_05/23/12_00:52:27」である。


さて、まず、N8103-117は、LSI LogicのSASカードなので、LSIの管理ソフトをインストールする。
以前はMegaCLIというコマンドだったが、最近はstorcliという名称となりコマンドオプションもだいぶ変更になっている。

storcliのダウンロードだが、LSI Logicは、いろいろあった結果、現在Broadcomに買収されている。
このため、「Broadcomのサポートページのダウンロード」から関連ソフトを探す必要がある。

storcliの検索結果」から「Management Software and Tools」にある「MegaRAID Storcli」をダウンロードし、インスト-ルする。

storcliを使う場合、まずは、storcliで認識できるSAS/SCSIコントローラを確認する必要がある。
「storcli64 show」を実行する。

# /opt/MegaRAID/storcli/storcli64 show
Status Code = 0
Status = Success
Description = None

Number of Controllers = 1
Host Name = blog.osakana.net
Operating System  = Linux3.10.0-514.2.2.el7.x86_64

System Overview :
===============

------------------------------------------------------------------------------
Ctl Model              Ports PDs DGs DNOpt VDs VNOpt BBU sPR DS EHS ASOs Hlth
------------------------------------------------------------------------------
  0 MegaRAIDSAS8708EM2     8   3   1     0   1     0 Opt On  2  N      0 Opt
------------------------------------------------------------------------------

Ctl=Controller Index|DGs=Drive groups|VDs=Virtual drives|Fld=Failed
PDs=Physical drives|DNOpt=DG NotOptimal|VNOpt=VD NotOptimal|Opt=Optimal
Msng=Missing|Dgd=Degraded|NdAtn=Need Attention|Unkwn=Unknown
sPR=Scheduled Patrol Read|DS=DimmerSwitch|EHS=Emergency Hot Spare
Y=Yes|N=No|ASOs=Advanced Software Options|BBU=Battery backup unit
Hlth=Health|Safe=Safe-mode boot
#

「MegaRAIDSAS8708EM2」を使ったコントローラが1個みつかり、コントローラの番号は「0」であることが分かる。

続いて、そのコントローラについての詳細を確認するため「/c0」オプションを追加し「storcli64 /c0 show」を実行する。

# /opt/MegaRAID/storcli/storcli64 /c0 show
Generating detailed summary of the adapter, it may take a while to complete.

Controller = 0
Status = Success
Description = None

Product Name = MegaRAID SAS 8708EM2
Serial Number = P322610710
SAS Address =  500605b001xxxxxx
PCI Address = 00:01:00:00
System Time = 01/04/2017 11:47:12
Mfg. Date = 02/24/10
Controller Time = 01/04/2017 02:47:13
FW Package Build = 11.0.1-0008
FW Version = 1.40.32-0580
BIOS Version = 2.06.00
Driver Name = megaraid_sas
Driver Version = 06.811.02.00-rh1
Vendor Id = 0x1000
Device Id = 0x60
SubVendor Id = 0x1000
SubDevice Id = 0x1013
Host Interface = PCI-E
Device Interface = SAS-3G
Bus Number = 1
Device Number = 0
Function Number = 0
Drive Groups = 1

TOPOLOGY :
========

--------------------------------------------------------------------------
DG Arr Row EID:Slot DID Type  State BT       Size PDC  PI SED DS3  FSpace
--------------------------------------------------------------------------
 0 -   -   -        -   RAID1 Optl  N  135.937 GB dsbl N  N   dflt N
 0 0   -   -        -   RAID1 Optl  N  135.937 GB dsbl N  N   dflt N
 0 0   0   252:0    0   DRIVE Onln  N  135.937 GB dsbl N  N   dflt -
 0 0   1   252:1    1   DRIVE Onln  N  135.937 GB dsbl N  N   dflt -
--------------------------------------------------------------------------

DG=Disk Group Index|Arr=Array Index|Row=Row Index|EID=Enclosure Device ID
DID=Device ID|Type=Drive Type|Onln=Online|Rbld=Rebuild|Dgrd=Degraded
Pdgd=Partially degraded|Offln=Offline|BT=Background Task Active
PDC=PD Cache|PI=Protection Info|SED=Self Encrypting Drive|Frgn=Foreign
DS3=Dimmer Switch 3|dflt=Default|Msng=Missing|FSpace=Free Space Present

Virtual Drives = 1

VD LIST :
=======

-----------------------------------------------------------
DG/VD TYPE  State Access Consist Cache sCC       Size Name
-----------------------------------------------------------
0/0   RAID1 Optl  RW     No      NRWBD -   135.937 GB
-----------------------------------------------------------

Cac=CacheCade|Rec=Recovery|OfLn=OffLine|Pdgd=Partially Degraded|dgrd=Degraded
Optl=Optimal|RO=Read Only|RW=Read Write|HD=Hidden|B=Blocked|Consist=Consistent|
R=Read Ahead Always|NR=No Read Ahead|WB=WriteBack|
AWB=Always WriteBack|WT=WriteThrough|C=Cached IO|D=Direct IO|sCC=Scheduled
Check Consistency

Physical Drives = 3

PD LIST :
=======

-------------------------------------------------------------------------
EID:Slt DID State DG       Size Intf Med SED PI SeSz Model            Sp
-------------------------------------------------------------------------
252:0     0 Onln   0 135.937 GB SAS  HDD N   N  512B MBD2147RC        U
252:1     1 Onln   0 135.937 GB SAS  HDD N   N  512B MBD2147RC        U
252:2     2 GHS    - 135.937 GB SAS  HDD N   N  512B HUC103014CSS600  U
-------------------------------------------------------------------------

EID-Enclosure Device ID|Slt-Slot No.|DID-Device ID|DG-DriveGroup
DHS-Dedicated Hot Spare|UGood-Unconfigured Good|GHS-Global Hotspare
UBad-Unconfigured Bad|Onln-Online|Offln-Offline|Intf-Interface
Med-Media Type|SED-Self Encryptive Drive|PI-Protection Info
SeSz-Sector Size|Sp-Spun|U-Up|D-Down|T-Transition|F-Foreign
UGUnsp-Unsupported|UGShld-UnConfigured shielded|HSPShld-Hotspare shielded
CFShld-Configured shielded|Cpybck-CopyBack|CBShld-Copyback Shielded


BBU_Info :
========

------------------------------------------------------------
Model State   RetentionTime Temp Mode MfgDate    Next Learn
------------------------------------------------------------
iBBU  Optimal N/A           19C  -    2010/05/14 None
------------------------------------------------------------


#

コントローラについての情報や、RAID構成に関する情報が取得できる。

また、出力結果より、「N8103-117」は「MegaRAID SAS 8708EM2」である事が判明。
同じくサポートページより最新のfirmwareを検索してみる。

MesaRAID SAS 8708EM2に関するDownload」の「Firmware」から「EF P34」をダウンロード。
Readmeには下記のバージョンが書かれており、現状の「FW Package Build = 11.0.1-0008」より新しいことが分かる。

Current Firmware Package: 11.0.1-0048 (EF-P34)

Current Package Details: APP-1.40.342-1650_BB-1.00.00.01-0012_BIOS-2.07.00_WEBBIOS-2.2-22-e_15-Rel_CTRLR-_PCLI-01.40-01000008_2012_05_11

アップデートは、firmwareファイルを「file=ファイル名」という形で指定して実行となる。
つまり「storcli64 /c0 download file=ファイル名」と実行する。

# /opt/MegaRAID/storcli/storcli64 /c0 download file=mr1078fw.rom
Download Completed.
Flashing image to adapter...
Controller = 0
Status = Success
Description = F/W Flash Completed. Please reboot the system for the changes to take effect

Current package version = 11.0.1-0008
New package version = 11.0.1-0048
#

適用したfirmwareは、OS再起動後から有効になるため、rebootする。

起動完了後、「storcli64 /c0 show」を実行し、FW Package BuildとFW Versionが変更されていることを確認。

# /opt/MegaRAID/storcli/storcli64 /c0 show
Generating detailed summary of the adapter, it may take a while to complete.

Controller = 0
Status = Success
Description = None

Product Name = MegaRAID SAS 8708EM2
Serial Number = P322610710
SAS Address =  500605b001xxxxxx
PCI Address = 00:01:00:00
System Time = 01/04/2017 13:07:49
Mfg. Date = 02/24/10
Controller Time = 01/04/2017 04:07:49
FW Package Build = 11.0.1-0048
FW Version = 1.40.342-1650
BIOS Version = 2.07.00
Driver Name = megaraid_sas
Driver Version = 06.811.02.00-rh1
Vendor Id = 0x1000
Device Id = 0x60
SubVendor Id = 0x1000
SubDevice Id = 0x1013
Host Interface = PCI-E
Device Interface = SAS-3G
Bus Number = 1
Device Number = 0
Function Number = 0
Drive Groups = 1

TOPOLOGY :
========

--------------------------------------------------------------------------
DG Arr Row EID:Slot DID Type  State BT       Size PDC  PI SED DS3  FSpace
--------------------------------------------------------------------------
 0 -   -   -        -   RAID1 Optl  N  135.937 GB dsbl N  N   dflt N
 0 0   -   -        -   RAID1 Optl  N  135.937 GB dsbl N  N   dflt N
 0 0   0   252:0    0   DRIVE Onln  N  135.937 GB dsbl N  N   dflt -
 0 0   1   252:1    1   DRIVE Onln  N  135.937 GB dsbl N  N   dflt -
--------------------------------------------------------------------------

DG=Disk Group Index|Arr=Array Index|Row=Row Index|EID=Enclosure Device ID
DID=Device ID|Type=Drive Type|Onln=Online|Rbld=Rebuild|Dgrd=Degraded
Pdgd=Partially degraded|Offln=Offline|BT=Background Task Active
PDC=PD Cache|PI=Protection Info|SED=Self Encrypting Drive|Frgn=Foreign
DS3=Dimmer Switch 3|dflt=Default|Msng=Missing|FSpace=Free Space Present

Virtual Drives = 1

VD LIST :
=======

-----------------------------------------------------------
DG/VD TYPE  State Access Consist Cache sCC       Size Name
-----------------------------------------------------------
0/0   RAID1 Optl  RW     No      NRWBD -   135.937 GB
-----------------------------------------------------------

Cac=CacheCade|Rec=Recovery|OfLn=OffLine|Pdgd=Partially Degraded|dgrd=Degraded
Optl=Optimal|RO=Read Only|RW=Read Write|HD=Hidden|B=Blocked|Consist=Consistent|
R=Read Ahead Always|NR=No Read Ahead|WB=WriteBack|
AWB=Always WriteBack|WT=WriteThrough|C=Cached IO|D=Direct IO|sCC=Scheduled
Check Consistency

Physical Drives = 3

PD LIST :
=======

-------------------------------------------------------------------------
EID:Slt DID State DG       Size Intf Med SED PI SeSz Model            Sp
-------------------------------------------------------------------------
252:0     0 Onln   0 135.937 GB SAS  HDD N   N  512B MBD2147RC        U
252:1     1 Onln   0 135.937 GB SAS  HDD N   N  512B MBD2147RC        U
252:2     2 GHS    - 135.937 GB SAS  HDD N   N  512B HUC103014CSS600  U
-------------------------------------------------------------------------

EID-Enclosure Device ID|Slt-Slot No.|DID-Device ID|DG-DriveGroup
DHS-Dedicated Hot Spare|UGood-Unconfigured Good|GHS-Global Hotspare
UBad-Unconfigured Bad|Onln-Online|Offln-Offline|Intf-Interface
Med-Media Type|SED-Self Encryptive Drive|PI-Protection Info
SeSz-Sector Size|Sp-Spun|U-Up|D-Down|T-Transition|F-Foreign
UGUnsp-Unsupported|UGShld-UnConfigured shielded|HSPShld-Hotspare shielded
CFShld-Configured shielded|Cpybck-CopyBack|CBShld-Copyback Shielded


BBU_Info :
========

------------------------------------------------------------
Model State   RetentionTime Temp Mode MfgDate    Next Learn
------------------------------------------------------------
iBBU  Optimal N/A           20C  -    2010/05/14 None
------------------------------------------------------------
#

vSphere PowerCLIの一部コマンドがPowerShell ISEで動作しない 2016/12/15版



2017/02/27追記
Windows環境以外でも動作するPowerCLI Coreが登場し、この手順を行おうとしたら、モジュール名が異なり実施できませんでした。
PowerCLIとPowerCLI Coreの双方で動くPowerShellスクリプトの作り方」に、対処方法を記載しています。


1年前に「vSphere PowerCLIの一部コマンドがPowerShell ISEで動作しない」というのを書いた。

最近、環境を作り直すのと一緒にPowerShellを最新にして、そして、PowerCLIを最新の6.5にしてみた。(New Release: PowerCLI 6.5 R1)

以前と同じように、PowerShell ISE上で「Add-PSSnapin VMware.VimAutomation.Core」を実行すると、「Add-PSSnapin : No snap-ins have been registered for Windows PowerShell version 5.」というエラーが発生。
「Add-PSSnapin」は使わないようだ。

 C:\Users\test3> Add-PSSnapin VMware.VimAutomation.Core


Add-PSSnapin : No snap-ins have been registered for Windows PowerShell version 5.
At line:1 char:1
+ Add-PSSnapin VMware.VimAutomation.Core
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (VMware.VimAutomation.Core:String) [Add-PSSnapin], PSArgumentException
    + FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand
 

 C:\Users\test3> 

代替はなんだろ?と確認すると「Import-Module -Name VMware.VimAutomation.Core」。

いままでスクリプトにAdd-PSSnapin~と書いていたところを、どちらでも対応できるように書き換えるとすると、下記のようになるだろうか?

if ( $PSVersionTable.PSVersion.Major -lt 5){
    Add-PSSnapin VMware.VimAutomation.Core
}else{
    Import-Module -Name VMware.VimAutomation.Core
}

下記は参考資料の実行ログ

PS C:\Users\test3> Get-Module

ModuleType Version    Name                                ExportedCommands                                                                           
---------- -------    ----                                ----------------                                                                           
Script     1.0.0.0    ISE                                 {Get-IseSnippet, Import-IseSnippet, New-IseSnippet}                                        
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content...}                         
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}                                  



PS C:\Users\test3> Get-Module -ListAvailable


    Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands                                                                           
---------- -------    ----                                ----------------                                                                           
Binary     1.0.0.1    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}                     
Script     1.0.0.1    PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module...}                               


    Directory: C:\Windows\system32\WindowsPowerShell\v1.0\Modules


ModuleType Version    Name                                ExportedCommands                                                                           
---------- -------    ----                                ----------------                                                                           
Manifest   1.0.0.0    AppLocker                           {Set-AppLockerPolicy, Get-AppLockerPolicy, Test-AppLockerPolicy, Get-AppLockerFileInform...
Manifest   1.0.0.0    BitsTransfer                        {Add-BitsFile, Remove-BitsTransfer, Complete-BitsTransfer, Get-BitsTransfer...}            
Manifest   1.0.0.0    CimCmdlets                          {Get-CimAssociatedInstance, Get-CimClass, Get-CimInstance, Get-CimSession...}              
Script     1.0.0.0    ISE                                 {New-IseSnippet, Import-IseSnippet, Get-IseSnippet}                                        
Manifest   1.0.0.0    Microsoft.PowerShell.Archive        {Compress-Archive, Expand-Archive}                                                         
Manifest   3.0.0.0    Microsoft.PowerShell.Diagnostics    {Get-WinEvent, Get-Counter, Import-Counter, Export-Counter...}                             
Manifest   3.0.0.0    Microsoft.PowerShell.Host           {Start-Transcript, Stop-Transcript}                                                        
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Content, Clear-Content, Clear-ItemProperty, Join-Path...}                             
Script     1.0        Microsoft.PowerShell.ODataUtils     Export-ODataEndpointProxy                                                                  
Manifest   3.0.0.0    Microsoft.PowerShell.Security       {Get-Acl, Set-Acl, Get-PfxCertificate, Get-Credential...}                                  
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Format-List, Format-Custom, Format-Table, Format-Wide...}                                 
Manifest   3.0.0.0    Microsoft.WSMan.Management          {Disable-WSManCredSSP, Enable-WSManCredSSP, Get-WSManCredSSP, Set-WSManQuickConfig...}     
Manifest   1.0.0.0    NetworkSwitchManager                {Disable-NetworkSwitchEthernetPort, Enable-NetworkSwitchEthernetPort, Get-NetworkSwitchE...
Manifest   1.1        PSDesiredStateConfiguration         {Set-DscLocalConfigurationManager, Start-DscConfiguration, Test-DscConfiguration, Publis...
Script     1.0.0.0    PSDiagnostics                       {Disable-PSTrace, Disable-PSWSManCombinedTrace, Disable-WSManTrace, Enable-PSTrace...}     
Binary     1.1.0.0    PSScheduledJob                      {New-JobTrigger, Add-JobTrigger, Remove-JobTrigger, Get-JobTrigger...}                     
Manifest   2.0.0.0    PSWorkflow                          {New-PSWorkflowExecutionOption, New-PSWorkflowSession, nwsn}                               
Manifest   1.0.0.0    PSWorkflowUtility                   Invoke-AsWorkflow                                                                          
Manifest   1.0.0.0    TroubleshootingPack                 {Get-TroubleshootingPack, Invoke-TroubleshootingPack}                                      


    Directory: C:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Modules


ModuleType Version    Name                                ExportedCommands                                                                           
---------- -------    ----                                ----------------                                                                           
Binary     6.0.0.0    VMware.DeployAutomation                                                                                                        
Binary     6.0.0.0    VMware.ImageBuilder                                                                                                            
Binary     6.5.0.4... VMware.VimAutomation.Cis.Core                                                                                                  
Binary     6.5.0.4... VMware.VimAutomation.Cloud                                                                                                     
Manifest   6.5.0.4... VMware.VimAutomation.Common                                                                                                    
Binary     6.5.0.2... VMware.VimAutomation.Core           HookGetViewAutoCompleter                                                                   
Binary     6.0.0.0    VMware.VimAutomation.HA                                                                                                        
Binary     7.0.2.4... VMware.VimAutomation.HorizonView                                                                                               
Binary     6.5.0.4... VMware.VimAutomation.License                                                                                                   
Binary     6.5.0.4... VMware.VimAutomation.PCloud                                                                                                    
Manifest   6.5.0.4... VMware.VimAutomation.Sdk            Get-PSVersion                                                                              
Binary     6.5.0.4... VMware.VimAutomation.Storage                                                                                                   
Binary     6.5.0.4... VMware.VimAutomation.Vds                                                                                                       
Binary     6.5.0.4... VMware.VimAutomation.vROps                                                                                                     
Binary     6.0.0.0    VMware.VumAutomation                                                                                                           



PS C:\Users\test3> Import-Module -Name VMware.VimAutomation.Core

 C:\Users\test3> Get-Module

ModuleType Version    Name                                ExportedCommands                                                                           
---------- -------    ----                                ----------------                                                                           
Script     0.0        Initialize-VMware_VimAutomation_Cis                                                                                            
Script     1.0.0.0    ISE                                 {Get-IseSnippet, Import-IseSnippet, New-IseSnippet}                                        
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content...}                         
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}                                  
Binary     6.5.0.4... VMware.VimAutomation.Cis.Core       {Connect-CisServer, Disconnect-CisServer, Get-CisService}                                  
Manifest   6.5.0.4... VMware.VimAutomation.Common                                                                                                    
Binary     6.5.0.2... VMware.VimAutomation.Core           {Add-PassthroughDevice, Add-VirtualSwitchPhysicalNetworkAdapter, Add-VMHost, Add-VMHostN...
Manifest   6.5.0.4... VMware.VimAutomation.Sdk            Get-PSVersion                                                                              



 C:\Users\test3> 

なお、PowerCLI 6.5を起動した場合に読み込まれているモジュール一覧は以下の通り

          Welcome to VMware PowerCLI!

Log in to a vCenter Server or ESX host:              Connect-VIServer
To find out what commands are available, type:       Get-VICommand
To show searchable help for all PowerCLI commands:   Get-PowerCLIHelp
Once you've connected, display all virtual machines: Get-VM
If you need more help, visit the PowerCLI community: Get-PowerCLICommunity

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


PowerCLI C:\> Get-Module

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     0.0        Initialize-VMware.VimAutomation....
Script     0.0        Initialize-VMware.VimAutomation....
Script     0.0        Initialize-VMware.VimAutomation....
Script     0.0        Initialize-VMware_DeployAutomation
Script     0.0        Initialize-VMware_VimAutomation_Cis
Script     0.0        Initialize-VMware_VumAutomation
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add...
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-T...
Binary     6.0.0.0    VMware.DeployAutomation             {Add-DeployRule, A...
Binary     6.0.0.0    VMware.ImageBuilder                 {Add-EsxSoftwareDe...
Binary     6.5.0.4... VMware.VimAutomation.Cis.Core       {Connect-CisServer...
Binary     6.5.0.4... VMware.VimAutomation.Cloud          {Add-CIDatastore, ...
Manifest   6.5.0.4... VMware.VimAutomation.Common
Binary     6.5.0.2... VMware.VimAutomation.Core           {Add-PassthroughDe...
Binary     6.0.0.0    VMware.VimAutomation.HA             Get-DrmInfo
Binary     7.0.2.4... VMware.VimAutomation.HorizonView    {Connect-HVServer,...
Binary     6.5.0.4... VMware.VimAutomation.License        Get-LicenseDataMan...
Binary     6.5.0.4... VMware.VimAutomation.PCloud         {Connect-PIServer,...
Manifest   6.5.0.4... VMware.VimAutomation.Sdk            Get-PSVersion
Binary     6.5.0.4... VMware.VimAutomation.Storage        {Copy-VDisk, Expor...
Binary     6.5.0.4... VMware.VimAutomation.Vds            {Add-VDSwitchPhysi...
Binary     6.5.0.4... VMware.VimAutomation.vROps          {Connect-OMServer,...
Binary     6.0.0.0    VMware.VumAutomation                {Add-EntityBaselin...


PowerCLI C:\>