VMware Cloud Community
Gabrie1
Commander
Commander
Jump to solution

Hiding clear text passwords in scripts

Hi

From one central server where some Powershell scripts are running, I would like to connect to multiple vCenter Servers, all not part of the same AD. How can I store passwords in my scripts (or other location) to make scheduled tasks possible that can login, but not reveal the clear text password.

Gabrie

http://www.GabesVirtualWorld.com
Tags (3)
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

I wouldn't store them in the script itself, but in an external file.

There areseveral possibilities to store credentials (user & password) outside a script.

There is the PowerCLI credential store, see Have you seen PowerCLI’s “Credential Store” feature?

And more general, store the PSCredential in an external file. See for example PowerShell code to store user credentials encrypted for re-use or Powershell: How to encrypt and store credentials securely for use with automation scripts. .

Some functions, build on that 2nd method are available on PoshCode, they are called Export-PSCredential and Import-PSCredential.


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

View solution in original post

0 Kudos
3 Replies
RvdNieuwendijk
Leadership
Leadership
Jump to solution

I think the easiest way is to store the credentials in the PowerCLI credentials store on the central server, using the New-VICredentialStoreItem cmdlet.

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

I wouldn't store them in the script itself, but in an external file.

There areseveral possibilities to store credentials (user & password) outside a script.

There is the PowerCLI credential store, see Have you seen PowerCLI’s “Credential Store” feature?

And more general, store the PSCredential in an external file. See for example PowerShell code to store user credentials encrypted for re-use or Powershell: How to encrypt and store credentials securely for use with automation scripts. .

Some functions, build on that 2nd method are available on PoshCode, they are called Export-PSCredential and Import-PSCredential.


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

0 Kudos
Gabrie1
Commander
Commander
Jump to solution

Thank you for the replies, I'm going to check this out.

http://www.GabesVirtualWorld.com
0 Kudos