-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcreatecredsfile.ps1
26 lines (21 loc) · 959 Bytes
/
createcredsfile.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
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "")]
param(
[Parameter(Mandatory = $true)]
$StatusCakeApiKey,
[Parameter(Mandatory = $true)]
$StatusCakeUserName
)
Write-Output "Writing .creds and securecreds file"
$secureApiKey = ConvertTo-SecureString $StatusCakeApiKey -asplaintext -force
if(-not (Test-Path "$env:ProgramFiles\WindowsPowerShell\Modules\StatusCakeDSC"))
{
New-item -Type Directory "$env:ProgramFiles\WindowsPowerShell\Modules\StatusCakeDSC" -Force
}
[PSCustomObject]@{
UserName = $StatusCakeUserName;
ApiKey = $StatusCakeApiKey
} | ConvertTo-Json | Out-File "$env:ProgramFiles\WindowsPowerShell\Modules\StatusCakeDSC\.creds" -force -verbose
[PSCustomObject]@{
UserName = $StatusCakeUserName;
ApiKey = $secureApiKey | ConvertFrom-SecureString
} | ConvertTo-Json | Out-File "$env:ProgramFiles\WindowsPowerShell\Modules\StatusCakeDSC\.securecreds" -force -verbose