Files
Zack Meier 1d304511b8 update
2026-04-15 15:45:50 -05:00

30 lines
1.1 KiB
PowerShell

$Title = 'itdwinautot1.nd.gov'
$Username = 'svczmtest005'
$Credential = $Secret:svcitdiaasauto
$FullRecord = $false
ConvertTo-SecureString -String "things" -AsPlainText -Force
$Uri = 'https://itdpv.nd.gov/winapi/searchpasswords/?'
If ($Title) { $Uri += 'title=' + $Title + '&' }
If ($UserName) { $Uri += 'username=' + "$UserName" + '&' }
$Uri = $Uri.TrimEnd('&')
$InvokeResult = Invoke-RestMethod -Method Get -Uri $Uri -Credential $Credential
$OutResult = $InvokeResult | Select-Object PasswordListID, PasswordList, PasswordID, Title, Description, UserName, @{n = 'SecurePassword'; e = { $_.Password | ConvertTo-SecureString -AsPlainText -Force } }, AccountTypeId, AccountType
If (@($OutResult).count -eq 1) {
If ($PSCmdlet.ParameterSetName -eq "ToClipboard") {
$InvokeResult.Password | Set-Clipboard
}
If ($FullRecord) {
Write-Output $OutResult
}
Else {
$OutCred = New-Object System.Management.Automation.PSCredential($OutResult.UserName, $OutResult.SecurePassword)
Write-Output $OutCred
}
}
Else {
Write-Output $OutResult
}