-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmove_group_to_csv.ps1
27 lines (22 loc) · 1.14 KB
/
move_group_to_csv.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# $username = ""
# $password = ""
# $move_group_id = ""
# $subdomain = ""
$body = @{
"username" = $username
"password" = $password
}
$access_token = Invoke-WebRequest -Uri "https://${subdomain}.tidalmg.com/api/v1/authenticate" -Method "Post" `
-Body ($body|ConvertTo-Json) -ContentType "application/json" `
| ConvertFrom-Json `
| Select -ExpandProperty access_token
$auth = @{"Authorization" = "Bearer ${access_token}";}
$servers = Invoke-WebRequest -Uri "https://${subdomain}.tidalmg.com/api/v1/move_groups/${move_group_id}" -Method "Get" `
-Headers $auth -ContentType "application/json" `
| ConvertFrom-Json `
| Select-Object -Expand servers `
| Select-Object -Property host_name,
@{Name = 'username'; Expression = { $_.custom_fields.username }}, `
@{Name = 'password'; Expression = { $_.custom_fields.password }}, `
@{Name = 'domain'; Expression = { $_.custom_fields.domain }} `
echo $servers | ConvertTo-Csv