Skip to content

Commit 25aed54

Browse files
authored
Merge pull request #3 from VeeamCommunity/Secure-credential
-Credential
2 parents d674c4a + 132cf54 commit 25aed54

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

veeam-powershell-sdk.psm1

+6-7
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function New-VBRConnection {
99
.OUTPUTS
1010
Returns the Veeam Server connection.
1111
.EXAMPLE
12-
New-VBRConnection -Endpoint <FQDN or IP> -Port <default 9419> -User <Administrator> -Pass <Password>
12+
New-VBRConnection -Endpoint <FQDN or IP> -Port <default 9419> -Credential $(Get-Credential)
1313
1414
#>
1515

@@ -22,17 +22,16 @@ function New-VBRConnection {
2222
[Parameter(Position=1,mandatory=$true)]
2323
[string]$Port,
2424

25-
[Parameter(Position=2,mandatory=$true)]
26-
[string]$User,
27-
28-
[Parameter(Position=3,mandatory=$true)]
29-
[string]$Pass
25+
[Parameter(Mandatory=$true,ParameterSetName="Credential")]
26+
[ValidateNotNullOrEmpty()]
27+
[Management.Automation.PSCredential]$Credential
3028

3129
)
3230

3331
$apiUrl = "https://$($Endpoint):$($Port)/api/oauth2/token"
3432

35-
33+
$User = $Credential.UserName
34+
$Pass = $Credential.GetNetworkCredential().Password
3635

3736
# Define the headers for the API request
3837
$headers = @{

0 commit comments

Comments
 (0)