VMware Cloud Community
vmk2014
Expert
Expert

vCheck report error while running from power cli console

Hi All,

While running the vCheck from power Cli console it shows following error in transcript. Any pointer will be much appreciated.

WARNING:

Begin Plugin Processing

[19:57:31] ..start calculating Connection settings for vCenter by Alan Renouf v1.20 [1 of 3]

Connect-VIServer : 1/2/2020 7:58:14 PM Connect-VIServer Could not determine user name and/or password for server

USAUR2APWP8500.cfsad.com

At D:\vmk\vcheck\plugins\00 Initialize\00 Connection Plugin for vCenter.ps1:151 char:20

+    $VIConnection = Connect-VIServer -Server $VIServer -Port $Port

+                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Connect-VIServer], ViServerConnectionException

    + FullyQualifiedErrorId :

ViCore_Login_CredentialNotFound,VMware.VimAutomation.ViCore.Cmdlets.Commands.ConnectVIServer

Connect-VIServer : 1/2/2020 7:58:14 PM Connect-VIServer Could not determine user name and/or password for server

USXYZ2APWPxxx.domain.com

At D:\vmk\vcheck\plugins\00 Initialize\00 Connection Plugin for vCenter.ps1:151 char:20

+    $VIConnection = Connect-VIServer -Server $VIServer -Port $Port

+                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Connect-VIServer], ViServerConnectionException

    + FullyQualifiedErrorId : ViCore_Login_CredentialNotFound,VMware.VimAutomation.ViCore.Cmdlets.Commands.ConnectVISe

   rver

D:\vmk\vcheck\plugins\00 Initialize\00 Connection Plugin for vCenter.ps1 : Unable to connect to vCenter, please

ensure you have altered the vCenter server address correctly. To specify a username and password edit the connection

string in the file $GlobalVariables

At D:\vmk\vcheck\vCheck.ps1:896 char:56

+ ... = [math]::round((Measure-Command { $Details = @(. $_.FullName)}).Tota ...

+                                                     ~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException

    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,00 Connection Plugin for vCenter.ps1

D:\vmk\vcheck\plugins\00 Initialize\00 Connection Plugin for vCenter.ps1 : Unable to connect to vCenter, please

ensure you have altered the vCenter server address correctly. To specify a username and password edit the connection

string in the file $GlobalVariables

At D:\vmk\vcheck\vCheck.ps1:896 char:56

+ ... = [math]::round((Measure-Command { $Details = @(. $_.FullName)}).Tota ..

Thanks

vmk.

Tags (1)
0 Kudos
17 Replies
LucD
Leadership
Leadership

This is a problem with the vSphere Server connection credentials.
There are a couple of possible solutions

  • Connect to the vCenter before calling vCheck.ps1. Then the script will reuse that connection
  • Create a VICredentialStoreItem entry for the vCenter (with the same user and from the same station as where the vCheck.ps1 script will run)
  • Change the Connect-VIServer line in plugin00 to include a User and Password


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

0 Kudos
vmk2014
Expert
Expert

LucD,

Do i  need to change line#151 in connection00 Plugin vCenter.ps1

From - $VIConnection = Connect-VIServer -Server $VIServer -Port $Port

To - Connect-VIServer vc1.my.domain.com  -user mydomain\user1  -password Welcome

thanks

vmk

0 Kudos
LucD
Leadership
Leadership

Yes, that is one way of providing the credentials.
But be aware that the credentials will be in clear text in that code.


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

0 Kudos
vmk2014
Expert
Expert

Thank LucD,

Any other way to secure password ? Since, its a jump server. However, i'll test to isolate the issue and validate if its working.

thanks

v

0 Kudos
LucD
Leadership
Leadership

You could use the SessionId from an existing connection.

On station A, do the Connect-VIServer.

Then retrieve the sessionid value (a string)

$id = $global:DefaultVIServer.SessionId

Then on station B, use this id to connect

Connect-VIServer -Server <vcsa-fqdn> -Session $id

In this setup you have to pass the id from station A to station B, but no credentials in clear text.


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

0 Kudos
vmk2014
Expert
Expert

LucD,

I'll try the credential part later, but when i tried to implement the vCheck for another vCenter server through task scheduler it keep running without output as earlier i was facing issue.

From power cli console, i did try and it seems it  stuck at plugin level and when i hit enter key then the script start moving to collect other plugin and generate the report and send mail.

How to fix to avoid enter key hit, so that i can run through the task scheduler.

Sort-Object : Exception getting "Name": "One or more errors occurred."

At D:\scripts\vCheck\Plugins\00 Initialize\00 Connection Plugin for vCenter.ps1:202 char:16

+ $VM = Get-VM | Sort-Object Name

+                ~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidResult: (:PSObject) [Sort-Object], GetValueInvocationException

    + FullyQualifiedErrorId : ExpressionEvaluation,Microsoft.PowerShell.Commands.SortObjectCommand

Sort-Object : Exception getting "Name": "One or more errors occurred."

At D:\scripts\vCheck\Plugins\00 Initialize\00 Connection Plugin for vCenter.ps1:202 char:16

+ $VM = Get-VM | Sort-Object Name

+                ~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidResult: (:PSObject) [Sort-Object], GetValueInvocationException

    + FullyQualifiedErrorId : ExpressionEvaluation,Microsoft.PowerShell.Commands.SortObjectCommand

Sort-Object : Exception getting "Name": "One or more errors occurred."

At D:\scripts\vCheck\Plugins\00 Initialize\00 Connection Plugin for vCenter.ps1:202 char:16

+ $VM = Get-VM | Sort-Object Name

+                ~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidResult: (:PSObject) [Sort-Object], GetValueInvocationException

    + FullyQualifiedErrorId : ExpressionEvaluation,Microsoft.PowerShell.Commands.SortObjectCommand

Sort-Object : Exception getting "Name": "One or more errors occurred."

At D:\scripts\vCheck\Plugins\00 Initialize\00 Connection Plugin for vCenter.ps1:202 char:16

+ $VM = Get-VM | Sort-Object Name

+                ~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidResult: (:PSObject) [Sort-Object], GetValueInvocationException

    + FullyQualifiedErrorId : ExpressionEvaluation,Microsoft.PowerShell.Commands.SortObjectCommand

Sort-Object : Exception getting "Name": "One or more errors occurred."

At D:\scripts\vCheck\Plugins\00 Initialize\00 Connection Plugin for vCenter.ps1:202 char:16

+ $VM = Get-VM | Sort-Object Name

thanks

v

0 Kudos
LucD
Leadership
Leadership

There seems to be an issue with the Sort-Object.

Any 'funny' characters in the names of the VMs on that vCenter?


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

0 Kudos
vmk2014
Expert
Expert

Sure, let me check. Also, another thing noticed that when the task scheduler run the first job and the next next job, when i tried to run from either scheduler or power cli console manually, it generates or combined the vcheck in one report which confuse a lot. It's seems after running the vcheck the session still remains connected for earlier vCenter when the next job for another vCenter start.

Note :- I have created two task scheduler for 2 different VC and planning to do similar for each VC at different time schedule.

thanks

v

0 Kudos
LucD
Leadership
Leadership

If you have a script where you do the Connect-VIServer and then calls vCheck.ps, you will have to do the Disconnect-VIServer, before starting another run.

Otherwise you will indeed have multiple connections open


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

0 Kudos
vmk2014
Expert
Expert

LucD,

1) You are absolutely right there are around 30 VM's having funny names starting with -_esXpress:VMName  and poweredoff state.

2) If you have a script where you do the Connect-VIServer and then calls vCheck.ps, you will have to do the Disconnect-VIServer, before starting another run.

Otherwise you will indeed have multiple connections open - What about task scheduler job ? Whole purpose of job to remove the manual intervention. For manual connection, i disconnect the VI Server. Does it mean disconnect plugin not working ?

thanks

v

0 Kudos
LucD
Leadership
Leadership

No, it should work.
But I don't know if you saw my reference in one of your other threads.

There is an issue with vCheck and Windows Task Scheduler.

See vCheck is not running as scheduled task · Issue #642 · alanrenouf/vCheck-vSphere · GitHub

We'll be looking at this in the upcoming new version for vCheck


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

0 Kudos
LucD
Leadership
Leadership

On the VM names, can you try the following against that vCenter where you have the Sort-Object error?

Get-VM | Sort-Object Name


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

0 Kudos
vmk2014
Expert
Expert

Sounds good. Let me try through batch file using task scheduler. It worked earlier

thanks

v

0 Kudos
vmk2014
Expert
Expert

Ok, i missed your last thread, i'll check the Get-VM | Sort-Object Name

So how to disconnect the session from vcenter after the job is completed. Does the plugin not working from vCheck  or i need to wait until the task scheduler issue fixed as you mentioned in last thread.

0 Kudos
vmk2014
Expert
Expert

LucD,

Please find the output

PowerCLI D:\scripts\vmanme1> Get-VM | Sort-Object Name _esXpress: vmname Helper 01

Sort-Object : A positional parameter cannot be found that accepts argument '_esXpress:'.

At line:1 char:10

+ Get-VM | Sort-Object Name _esXpress: vmname Helper 01

+          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidArgument: (:) [Sort-Object], ParameterBindingException

    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.SortObjectCommand

thanks

v

0 Kudos
LucD
Leadership
Leadership

What is the string '_esXpress: vmname Helper 01' doing in there?

The line I want you to run is

Get-VM | Sort-Object -Property Name
The disconnect is indeed done in plugin999.
But are you sure that plugin was executed?

Perhaps the vCheck never got there due to a previous error


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

0 Kudos
vmk2014
Expert
Expert

LucD,

will get back. It bad luck VC is down now and its legacy environment that's why trying to configure report.

thanks

v

0 Kudos