VMware / Microsoft 製品はこう使う。

好きなことを好きに描く.

PowerCLI 10.0/Connect-VIServer で証明書のエラーになる。

メモ。

 

手元の環境で、PowerCLI 10.0 でConnect-VIServerしようとしたら証明書のエラーになり、えー(´・ω・`) と思っていたのですが、-force オプション付けるだけでよかったです。

 

【環境】

PowerCLI 10.0

vCenter 6.7(vCSA)

ESXi6.0/6.5 混在環境

 

【内容】

PowerCLI 10.0 を起動して、ログインしようしたら証明書のエラーになる。

■エラー内容

Connect-VIServer : 2018/09/27 20:39:08 Connect-VIServer Error: Invalid server certificate. Use Set-PowerCLIConfiguration to set the value for
the InvalidCertificateAction option to Prompt if you'd like to connect once or to add a permanent exception for this server.
Additional Information: 機関 'vcsa65-main.17f.local' との SSL/TLS のセキュリティで保護されているチャネルに対する信頼関係を確立できませんでした

発生場所 行:1 文字:1
+ Connect-VIServer -server vcsa65-main.17f.local -User Administrator@vS ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : セキュリティ エラー: (: ) [Connect-VIServer]、ViSecurityNegotiationException
+ FullyQualifiedErrorId : Client20_ConnectivityServiceImpl_Reconnect_CertificateError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Connec
tVIServer

 

【解決策】

-force オプションを付ける。

f:id:japan-vmware:20180927205514p:plain

■メッセージ全文記載

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.


PS C:\> Connect-VIServer -server vcsa65-main.17f.local -User Administrator@vSphere.local -Password "    "
Connect-VIServer : 2018/09/27 20:39:08 Connect-VIServer Error: Invalid server certificate. Use Set-PowerCLIConfiguration to set the value for
the InvalidCertificateAction option to Prompt if you'd like to connect once or to add a permanent exception for this server.
Additional Information: 機関 'vcsa65-main.17f.local' との SSL/TLS のセキュリティで保護されているチャネルに対する信頼関係を確立できませんでした

発生場所 行:1 文字:1
+ Connect-VIServer -server vcsa65-main.17f.local -User Administrator@vS ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : セキュリティ エラー: (: ) [Connect-VIServer]、ViSecurityNegotiationException
+ FullyQualifiedErrorId : Client20_ConnectivityServiceImpl_Reconnect_CertificateError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Connec
tVIServer

PS C:\> Connect-VIServer -server vcsa65-main.17f.local -User Administrator@vSphere.local -Password "     " -force

Name Port User
---- ---- ----
vcsa65-main.17f.local 443 VSPHERE.LOCAL\Administrator

==================

 

PowerCLI 10.0 でデフォルト値が変わっている。常に無視したいなら設定変更もあり。

https://blogs.vmware.com/PowerCLI/2018/02/powercli-10.html

Default Certificate Handling

This version changes the way certificates are handled when connecting to a vCenter server or ESXi host with the Connect-VIServer cmdlet. If your connection endpoint is using an invalid certificate (self-signed or otherwise), PowerCLI would previously return back a warning. The handling has been updated to be more secure and now return back an error.

If you are using an invalid certificate, you can correct the error with the ‘Set-PowerCLIConfiguration’ cmdlet. The parameter needing to be configured is ‘InvalidCertificateAction’ and the available settings are Fail, Warn, Ignore, Prompt, and Unset.

The following code will configure the ‘InvalidCertificateAction’ parameter to be Ignore:

Set-PowerCLIConfiguration -InvalidCertificateAction Ignore