Create Connect-ZertoAnalytics.ps1
This commit is contained in:
@@ -0,0 +1,19 @@
|
|||||||
|
function Connect-ZertoAnalytics {
|
||||||
|
[cmdletbinding()]
|
||||||
|
param(
|
||||||
|
[Parameter(
|
||||||
|
Mandatory = $true,
|
||||||
|
HelpMessage = "PSCredential Object containing username and password authorized for the Zerto Analytics site",
|
||||||
|
Position = 0
|
||||||
|
)]
|
||||||
|
[System.Management.Automation.PSCredential]$credential
|
||||||
|
)
|
||||||
|
|
||||||
|
$uri = "auth/token"
|
||||||
|
Set-Variable -Name zaHeaders -Scope Script -Value @{"Accept" = "application/json" }
|
||||||
|
Set-Variable -Name zaLastActionTime -Scope Script -Value $(Get-date).Ticks
|
||||||
|
$body = @{"username" = $credential.UserName; "password" = $credential.GetNetworkCredential().password }
|
||||||
|
$result = Invoke-ZARestRequest -Uri $uri -body $($body | ConvertTo-Json) -Method POST
|
||||||
|
$Script:zaHeaders["Authorization"] = "Bearer $($result.Token)"
|
||||||
|
$Script:zaHeaders
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user