Advertisement
Guest User

Untitled

a guest
Mar 1st, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. $config = ([XML](Get-Content -Path "$env:APPDATA\NuGet\nuget.config"))
  2.  
  3. Add-Type -AssemblyName 'System.Security'
  4.  
  5. function Decrypt-NugetPassword ([string] $encryptedString)
  6. {
  7. $entropyBytes = [System.Text.Encoding]::UTF8.GetBytes('NuGet')
  8. $encryptedBytes = [Convert]::FromBase64String($encryptedString)
  9. $passwordBytes = [System.Security.Cryptography.ProtectedData]::Unprotect($encryptedBytes, $entropyBytes, [System.Security.Cryptography.DataProtectionScope]::CurrentUser)
  10. return [System.Text.Encoding]::UTF8.GetString($passwordBytes)
  11. }
  12.  
  13. $config.configuration.packageSourceCredentials.ChildNodes |
  14. ForEach-Object {
  15. [PSCustomObject]@{
  16. Name = $_.Name
  17. Username = ($_.add | Where-Object 'key' -eq 'Username').value
  18. Password = Decrypt-NugetPassword(($_.add | Where-Object 'key' -eq 'Password').value)
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement