Powershell Credential centralized location
Create the encrypted password Using Powershell and call same from location
Read-Host -AsSecureString |ConvertFrom-SecureString |out-file c:\data\password.txt
Call the password Using variable:
$Username = "domain.com\username"
$password = Get-content \\10.10.0.28\e$\vcheck\chandru\encrypted.txt |ConvertTo-Securestring
$Cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Username,$password
Connect-VIServer ( Get-Content .\vc.txt ) -Credential $Cred –Protocol Https -WarningAction Ignore
Connect-VIServer pdvcenter.pd.local -User domain\xxxx-Password xxxxx -WarningAction Ignore
Following cmd will send the mail automatically if the script is executed,
Send-MailMessage -To Chandru@gmail.com -From admin@localexchage.com -Subject "Any subject" -Body "Message content" -Credential $cred -SMTPServer $smtpserver

Comments
Post a Comment