File tree Expand file tree Collapse file tree 1 file changed +23
-23
lines changed Expand file tree Collapse file tree 1 file changed +23
-23
lines changed Original file line number Diff line number Diff line change 1
1
function Convert-SecureStringText {
2
- <#
3
- Objective: Convert between plaintext and SecureString text
4
- #>
5
- [cmdletbinding ()]
6
- param (
7
- [Parameter (Mandatory = $true )]
8
- [ValidateSet (" to" , " from" )]
9
- [string ]$action ,
10
- [Parameter (Mandatory = $true , ValueFromPipeline = $true )]
11
- [string ]$MyInput
12
- )
13
-
14
- Try {
15
- If ($action -eq " to" ) {
16
- $result = $MyInput.Trim () | ConvertTo-SecureString - AsPlainText - Force | ConvertFrom-SecureString - ErrorAction SilentlyContinue
17
- }
18
- else {
19
- $result = [Net.NetworkCredential ]::new(' ' , (($MyInput.Trim ()) | ConvertTo-SecureString )).password
20
- }
21
- return $result
2
+ <#
3
+ Objective: Convert between plaintext and SecureString text
4
+ #>
5
+ [cmdletbinding ()]
6
+ param (
7
+ [Parameter (Mandatory = $true )]
8
+ [ValidateSet (" to" , " from" )]
9
+ [string ]$action ,
10
+ [Parameter (Mandatory = $true , ValueFromPipeline = $true )]
11
+ [string ]$MyInput
12
+ )
13
+
14
+ Try {
15
+ If ($action -eq " to" ) {
16
+ $result = $MyInput.Trim () | ConvertTo-SecureString - AsPlainText - Force | ConvertFrom-SecureString - ErrorAction SilentlyContinue
22
17
}
23
- catch {
24
- Write-Warning " Unable to convert..... `n`n $ ( $_ .Exception ) "
18
+ else {
19
+ $result = [ Net.NetworkCredential ]::new( ' ' , (( $MyInput .Trim ()) | ConvertTo-SecureString )).password
25
20
}
26
- }
21
+ return $result
22
+ }
23
+ catch {
24
+ Write-Warning " Unable to convert.....`n`n $ ( $_.Exception ) "
25
+ }
26
+ }
You can’t perform that action at this time.
0 commit comments