Managing tenants
Since we have the token, we can start exploring the vRA environment. We will start by managing the tenants. First, let's get a list of existing tenants. From now onwards, we need to provide authorization for working with the resources. Since we already have a token, we need to pass the authorization as a parameter in the header itself. We will use the following format:
Authorization: Bearer $token
Here, $token
holds the authorization token. For this, we will build out the header. So, define a new object:
PS C:\>$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
Next, add the components of the header:
PS C:\> $headers.Add('Accept', 'application/json') PS C:\> $headers.Add('Authorization', "Bearer $token")
Note the Authorization
parameter; there needs to be a space between bearer and token. Next, get the information:
PS C:\> Invoke-RestMethod -Method Get -Uri "https://vra.lab.com/identity/api/tenants" -Headers $headers | FL
Putting...