Tests/Set-LegacyDataTestCredential.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<#
.SYNOPSIS
Get a stored set of credentials for testing this project.
 
.LINK
See https://www.jaapbrasser.com/quickly-and-securely-storing-your-credentials-powershell/
While Export- and Import-Clixml is pretty widely used, I took the basic structure of the XML file from Jaap Brasser's blog
 
#>





$FileDirectory = "${env:\userprofile}"
$FileName = 'LegacyData.Tests.cred'

$FilePath = Join-Path -Path $FileDirectory -child $FileName

# I am only using 'User' at this time.
$Hash = @{
    # 'Admin' = Get-Credential -Message 'Please enter administrative credentials'
    # 'RemoteUser' = Get-Credential -Message 'Please enter remote user credentials'
    # 'User' = Get-Credential -Message 'Please enter user credentials'
    'SqlServerUser' = Get-Credential -Message 'Please enter Sql Server user credentials'
}
$Hash | Export-Clixml -Path $FilePath

Write-Verbose -Verbose -Message "Wrote credentials to '$FilePath'"