VMware Cloud Community
MrVmware9423
Expert
Expert

POwercli script "Prompt for Credentials everytime"

Dear Team,

in the powercli windows if i run the attached health check script  then it prompt to enter vcenter server admin credentials once it reached at (VC Service, VC Error Event Logs, VC Warning Event Logs), Once i entered the credentials then it proceed further and not disconnecting  automatically from vcenter server asking me to press A and generate a report not sending the same on email. my query is y everytime it is asking me to enter a credentials for the same and vcenter session is ending automatically, becase of that i m unable to automate the health check script. Dear team request you to help me on the same.

regards

Mr VMware.


0 Kudos
15 Replies
RvdNieuwendijk
Leadership
Leadership

You are trying to run vCheck version 1.0 while there is already a new vCheck version 6.15 that has much more features. You can download this new version from http://www.virtu-al.net/vcheck-pluginsheaders/vcheck/. I would suggest that you try the new version first. If you have problems running the new version then let me know.

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
LucD
Leadership
Leadership

The prompt to confirm the disconnect from the vCenter is in the last line.

Change that line to

$VIServer | Disconnect-VIServer -Confirm:$false

and you will not be prompted anymore.

The prompt to provide credentials for the Connect-VIServer can be avoided when you run the script under an account that has priviliges to connect to the vCenter.

See the comment

#### Detail Settings ####
# Set the username of the account with permissions to access the VI Server
# for event logs and service details - you will be asked for the same username and password
# only the first time this runs after setting the below username.
# If it is left blank it will use the credentials of the user who runs the script
$SetUsername = "IFRE9393"

Do you run this under an authorised account ?

If yes, set the $SetUsername to blank.

Btw, we already discussed this before, but you should consider using the latest vCheck version


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

MrVmware9423
Expert
Expert

Dear LucD,

many thanks , if i want to send this report to n number of user then how  to add additonal email id entries ??

regads

Mr VMware

0 Kudos
LucD
Leadership
Leadership

Yes, add additional recipients to the $EmailTo variable, separate them with a semi-column

# Set the Email address to send the email to
$EmailTo = "personal@gmail.com ; wintel@abc.co.in"


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

0 Kudos
MrVmware9423
Expert
Expert

many thanks lucd,

if  additional email ids r specified then it won't email the report just save it on a C:\ drive and how to specify more than one ntp server

regards

Mr Vmware

0 Kudos
LucD
Leadership
Leadership

That is strange, I can send to multiple recipients.

Did you separate the recipients with a multi-column ?

Are the recipients valied email addresses ?

Sending to multiple SMTP servers would be a bit more tricky I'm afraid.

How would you define which recipients goes via which SMTP server ?


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

0 Kudos
MrVmware9423
Expert
Expert

Dear LucD,

following are the details.

$EmailTo = "personal@gmail.com ; wintel@abc.co.in"

i have mentioned my ntp server ip, but in health check report its giving message like this

ntp.jpg

For you reference i have attached the script.

regards

Mr VMware

0 Kudos
RvdNieuwendijk
Leadership
Leadership

For the ntp server problem you should remove the # sign at the beginning of the line:

#$ntpserver = "192.16.7.10"

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
MrVmware9423
Expert
Expert

Friend i have removed then i have ran the same and getting this error......

0 Kudos
RvdNieuwendijk
Leadership
Leadership

The NTP server IP address in the script is "192.16.7.10". In the screenshot it is "172.16.7.10" Looks like a typo in the script to me. Smiley Wink

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
MrVmware9423
Expert
Expert

yes it's a typo mistake, still same problem sir....

0 Kudos
MrVmware9423
Expert
Expert

how to mentioned more than one ntp server setting.

regards

Mr VMware

0 Kudos
LucD
Leadership
Leadership

I assume you mean "how to check for multiple NTP servers" ?


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

0 Kudos
RvdNieuwendijk
Leadership
Leadership

You can use a vertical bar between the IP addresses of the NTP servers. For example:

$ntpserver = "192.16.7.10|192.16.7.11"

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
MrVmware9423
Expert
Expert

Dear Lucd Sir,

mutiple reciepts things is s not working if i m trying to send more than one recepients

let me know which is the correct format....

$EmailTo = "personal@abc.co.in ; wintel@abc.co.in"

or

$EmailTo = "personal@abc.co.in" ; "wintel@abc.co.in"

between two email id shall i put space or without space ....

regards

Mr Vmware

0 Kudos