Scripts/Get-PWVCred.ps1
function Get-PWVCred { [CmdletBinding()] param( [Parameter(Mandatory=$true)] [PSCredential]$credential, [Parameter(Mandatory=$true)] [string]$SafeName, [Parameter(Mandatory=$true)] [string]$Account, [Parameter(Mandatory=$true)] [string]$BaseURI ) try{Close-PASSession}catch{} New-PASSession -Credential $credential -BaseURI $BaseURI [SecureString]$Password = (Get-PASAccount -SafeName $SafeName | Where-Object userName -eq $Account).GetPassword().Password | ConvertTo-SecureString -AsPlainText -Force return [SecureString]$Password Close-PASSession } |