Last active
April 28, 2017 13:33
-
-
Save quonic/c5d8f8950e06ccd5732327db97992d96 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| $StoredCredential = "$PSScriptRoot/Credential.xml" | |
| if($Crediential){ | |
| $mycreds = $Crediential | |
| Export-Clixml -Path $StoredCredential -InputObject $mycreds | |
| }elseif($Username -and $Password){ | |
| $secpasswd = ConvertTo-SecureString $Password -AsPlainText -Force | |
| $mycreds = New-Object System.Management.Automation.PSCredential ($Username, $secpasswd) | |
| Export-Clixml -Path $StoredCredential -InputObject $mycreds | |
| }else{ | |
| if($PSScriptRoot -and $(Test-Path -Path $StoredCredential)){ | |
| $mycreds = Import-Clixml -Path $StoredCredential | |
| }else{ | |
| $mycreds = Get-Credential -Message "Username and API Key as the APIKey" | |
| Export-Clixml -Path $StoredCredential -InputObject $mycreds | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment