Last active
February 26, 2019 16:27
-
-
Save jasonchester/8d659390afa493b3db89f7273610c22c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$config = ([XML](Get-Content -Path "$env:APPDATA\NuGet\nuget.config")) | |
Add-Type -AssemblyName 'System.Security' | |
function Decrypt-NugetPassword ([string] $encryptedString) | |
{ | |
$entropyBytes = [System.Text.Encoding]::UTF8.GetBytes('NuGet') | |
$encryptedBytes = [Convert]::FromBase64String($encryptedString) | |
$passwordBytes = [System.Security.Cryptography.ProtectedData]::Unprotect($encryptedBytes, $entropyBytes, [System.Security.Cryptography.DataProtectionScope]::CurrentUser) | |
return [System.Text.Encoding]::UTF8.GetString($passwordBytes) | |
} | |
$config.configuration.packageSourceCredentials.ChildNodes | | |
ForEach-Object { | |
[PSCustomObject]@{ | |
Name = $_.Name | |
Username = ($_.add | Where-Object 'key' -eq 'Username').value | |
Password = Decrypt-NugetPassword(($_.add | Where-Object 'key' -eq 'Password').value) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment