VMware Cloud Community
CNorris_Const
Enthusiast
Enthusiast

Write-PowerCLIError when running Get-VITrustedCertificate

Hello,

When trying to run Get-VITrustedCertificate the following error message comes up for each certificate entry instead of the actual certificate data:

Write-PowerCLIError : The variable '$UidUtil' cannot be retrieved because it has not been set.
At C:\Program
Files\WindowsPowerShell\Modules\VMware.PowerCLI.VCenter\12.5.0.19094331\commands\Get-VITrustedCertificate.ps1:348
char:10
+ Write-PowerCLIError `
+ ~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (UidUtil:String) [Write-Error], RuntimeException
+ FullyQualifiedErrorId : VariableIsUndefined,Write-PowerCLIError

The issue persists across multiple datacenters/vcenters and two separate environments. I tried running the command from multiple different servers, laptops, and admin accounts. I've also tried on a few different PowerCLI versions including the latest release.

Any suggestions?

Tags (3)
0 Kudos
5 Replies
LucD
Leadership
Leadership

Can you check what the following returns.

Get-Command -Name Get-VITrustedCertificate
Get-Command -Name Write-PowerCLIError

Also, which PowerCLI, PowerShell, and vSphere versions are you using.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
CNorris_Const
Enthusiast
Enthusiast

Hey LucD,


Also, which PowerCLI, PowerShell, and vSphere versions are you using.


PowerCLI 12.5.0.19094331 and 12.6.0.19600125

PowerShell 5.1 and PowerShell 7.2.3

vSphere 7.0.3.00500 Build 19480866 and 7.0.2.00500 Build 18455184

Here's the results for two PowerCLI installs, it looks like Write-PowerCLIError is not there for both:

 

 

CommandType : Function
Name : Get-VITrustedCertificate
Version : 12.5.0.19094331
Source : VMware.PowerCLI.VCenter

Get-Command : The term 'Write-PowerCLIError' is not recognized as the name of a cmdlet, function, script file, or
operable program.

CommandType : Function
Name : Get-VITrustedCertificate
Version : 12.6.0.19600125
Source : VMware.PowerCLI.VCenter

Get-Command : The term 'Write-PowerCLIError' is not recognized as the name of a cmdlet, function, script file, or operable program.

 

 

Thanks for the quick response. 🙂

0 Kudos
LucD
Leadership
Leadership

That is a strange situation.
The Get-VITrustedCertificate works for me without an issue.

You could try to completely remove PowerCLI and reinstall it, but since you seem to experience the same on multiple installations, that will probably not help.

I have never seen a Write-PowerCLIError cmdlet, no clue where that is coming from.
Might this be something you specify in your PS profile?

If not, I think the last option is opening an SR.

 


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
CNorris_Const
Enthusiast
Enthusiast

I had a feeling this would be a strange one, as I've never encountered anything like it before while using PowerCLI. I'm also not familiar with Write-PowerCLIError or where that could be coming from so I'm at a loss there.

I'll move forward with opening an SR and keep my fingers crossed. Thanks for looking into it either way, I appreciate it!

0 Kudos
Sergioigseq
Contributor
Contributor

Hey @CNorris_Const @LucD 

 

I just had a similar issue within all our scripting servers, which made me find your topic. My problem is due to the vCenter certificate:

 

Write-PowerCLIError : The underlying connection was closed: Could not establish trust relationship for the SSL/TLS
secure channel.
At
C:\Windows\system32\WindowsPowerShell\v1.0\Modules\VMware.PowerCLI.VCenter\commands\Get-VIMachineCertificate.ps1:157
char:13
+ Write-PowerCLIError `
+ ~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Write-PowerCLIError

 

And the solution for me was to change the default config from PowerCLI for that session:

Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false

 

In the middle of my research, I looked for yours, which lead me to this part of PowerCLI reference documents:

about_uid - vSphere PowerCLI Cmdlets Reference (vmware.com)

It's only a guess, but maybe the issue is with your certificate too, but when PowerCLI looks for the actual uid of the object in the inventory. If you didn't find the solution yet, it could be worth to try to regenerate your certificate?

Kind regards,

Sergio.

0 Kudos