VMware Cloud Community
JimKnopf99
Commander
Commander
Jump to solution

connect to vcenter

Hi all,

i am new with the powershell and want to knwo how i can do a secure connection to the vcenter.

I knwo it is possible with the connect-viserver cmd´let. But i do not want do type my user an password in clear.

So i wan´t a connection with the local user that is logged on my pc. I read something about a cred file but i am not sure how it works

Thanks for your help

Frank

If you find this information useful, please award points for "correct" or "helpful".
Reply
0 Kudos
1 Solution

Accepted Solutions
RvdNieuwendijk
Leadership
Leadership
Jump to solution

The default credentials that are used to connect to the vCenter server with the Connect-VIServer cmdlet, are the credentials that you logged into your client computer. If these credentials are sufficient to connect to the vCenter server, you don't have to specify the credentials to the cmdlet. In this case the next command will connect to your vcenter server:

Connect-VIServer YourvCenterServer

This is very usefull if you run a PowerCLI script as a scheduled task. Create a service account with enough rights and run the task with this account.

If you need to specify different credentials, you can do this without showing the password in clear text with:

Connect-VIServer YourvCenterServer -Credential (Get-Credential)

In this case you get a "Windows PowerShell Credential Request" pop-up box, in which you can specify the username and password.

Regards, Robert

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

View solution in original post

Reply
0 Kudos
5 Replies
jeveenj
Enthusiast
Enthusiast
Jump to solution

Hi Frank,

You can try below step,

Firstly you need to store credential:

New-VICredentialStoreItem -Host 192.168.101.1 -Password password -User root -file C:\vicredentials.xml

This will save the password in encrypted form in an xml.

then you can use this cred file as shown below,

$creds = Get-VICredentialStoreItem -file C:\vicredentials.xml
Connect-VIServer -Server $creds.Host -user $creds.User -password $creds.Password



-If you found this information useful, please consider awarding points for Correct or Helpful.

-If you found this information useful, please consider awarding points for Correct or Helpful.
JimKnopf99
Commander
Commander
Jump to solution

Hi thanks for the fast reply,

in the first section to store the credential, i do not want to type the passwort in the script. So is it possible to get something like a popup or window where you can write the credentials in it?

Frank

If you find this information useful, please award points for "correct" or "helpful".
Reply
0 Kudos
RvdNieuwendijk
Leadership
Leadership
Jump to solution

The default credentials that are used to connect to the vCenter server with the Connect-VIServer cmdlet, are the credentials that you logged into your client computer. If these credentials are sufficient to connect to the vCenter server, you don't have to specify the credentials to the cmdlet. In this case the next command will connect to your vcenter server:

Connect-VIServer YourvCenterServer

This is very usefull if you run a PowerCLI script as a scheduled task. Create a service account with enough rights and run the task with this account.

If you need to specify different credentials, you can do this without showing the password in clear text with:

Connect-VIServer YourvCenterServer -Credential (Get-Credential)

In this case you get a "Windows PowerShell Credential Request" pop-up box, in which you can specify the username and password.

Regards, Robert

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
Reply
0 Kudos
JimKnopf99
Commander
Commander
Jump to solution

Wow,

thanks both very much.

Thats what i am searching for.

Frank

If you find this information useful, please award points for "correct" or "helpful".

If you find this information useful, please award points for "correct" or "helpful".
Reply
0 Kudos
JimKnopf99
Commander
Commander
Jump to solution

Wow,

thanks both very much.

Thats what i am searching for.

Frank

If you find this information useful, please award points for "correct" or "helpful".

If you find this information useful, please award points for "correct" or "helpful".
Reply
0 Kudos