20 lines
627 B
PowerShell
20 lines
627 B
PowerShell
Function Get-SecureString {
|
|
<#
|
|
.SYNOPSIS
|
|
Convert a string to a SecureString. This function is to allow for mocking, and to allow for auditing of the usage of SecureStrings.
|
|
|
|
.PARAMETER String
|
|
The string to be converted. This name corresponds with ConvertTo-SecureString parameters.
|
|
#>
|
|
[CmdletBinding()]
|
|
Param (
|
|
[Parameter(Position = 0, ValueFromPipeline = $true, Mandatory = $true)]
|
|
[string]$String
|
|
)
|
|
|
|
$secureString = New-Object SecureString
|
|
foreach($char in $String.ToCharArray()) {
|
|
$secureString.AppendChar($char)
|
|
}
|
|
return $secureString
|
|
} |