Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $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)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement