Public/Set-StoredCredential.ps1
function Set-StoredCredential { [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [string]$userName, [Parameter(Mandatory = $true)] [string]$password ) # Convert password to secure string $password = ConvertTo-SecureString $password -AsPlainText -Force # Create PSCredential object $cred = New-Object System.Management.Automation.PSCredential ($userName, $password) return $cred } |