Helpers/Profile/Export-ProfileEnvironmentSecureString.ps1
function Export-ProfileEnvironmentSecureString { [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [ValidateScript({ Test-Path -Path $_ })] [System.String] $Path, [Parameter(Mandatory = $true, ValueFromPipeline = $true)] [System.Management.Automation.PSCredential[]] $SecureString ) process { foreach ($SecureStringItem in $SecureString) { # Remove all non alphabetic and non numeric characters expect the # underline and add the file extension. $File = $SecureStringItem.Username $File = $File.ToUpper() -replace '[^0-9a-zA-Z_]' $File = $File + '.securestring.xml' $SecureStringItem.Password | Export-Clixml -Path (Join-Path -Path $Path -ChildPath $File) -Force } } } |