Guest User

Untitled

a guest
Aug 22nd, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. function ConvertTo-BasicAuth {
  2.  
  3. [cmdletbinding()]
  4. param (
  5.  
  6. [Parameter( ValueFromPipeline )]
  7. [PSCredential]
  8. $Credential
  9.  
  10. )
  11.  
  12. $Username = $Credential.UserName
  13. $Password = $Credential.GetNetworkCredential().Password
  14. $AuthPair = $Username + ":" + $Password
  15.  
  16. return ( [System.Convert]::ToBase64String( [System.Text.Encoding]::ASCII.GetBytes( $AuthPair )))
  17.  
  18. }
Add Comment
Please, Sign In to add comment