Skip to content
This repository was archived by the owner on Oct 15, 2025. It is now read-only.

Commit 2fee1a3

Browse files
Add Azure support
1 parent 16ec7f4 commit 2fee1a3

1 file changed

Lines changed: 29 additions & 9 deletions

File tree

PreInstall/TeamMachineSetup.ps1

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,47 @@ function fetchUserData {
3131
$metadata = $(
3232
try {
3333
(Invoke-WebRequest -uri http://metadata.google.internal/computeMetadata/v1/instance/attributes/parsec -Method GET -header @{'metadata-flavor'='Google'} -TimeoutSec 5)
34+
$stream = "bytes"
3435
}
3536
catch {
3637
}
3738
Try {
3839
(Invoke-WebRequest -uri http://metadata.paperspace.com/meta-data/machine -TimeoutSec 5)
40+
$stream = "bytes"
3941
}
4042
catch {
4143
}
42-
Try {
43-
(Invoke-WebRequest -Uri "http://169.254.169.254/latest/user-data?api-version=2018-10-01" -Headers @{Metadata="true"} -TimeoutSec 5)
44+
Try {
45+
(Invoke-WebRequest -Uri "http://169.254.169.254/latest/user-data?" -TimeoutSec 5)
46+
$stream = "bytes"
4447
}
45-
catch {
48+
catch {
49+
}
50+
Try {
51+
Invoke-Webrequest -Headers @{"Metadata"="true"} -Uri "http://169.254.169.254/metadata/instance/compute/userData?api-version=2021-01-01&format=text" -TimeoutSec 5
52+
$stream = "base64"
53+
}
54+
Catch {
4655
}
4756
)
4857
if ($metadata.StatusCode -eq 200) {
49-
[System.Text.Encoding]::ASCII.GetString($metadata.content).split(':')
50-
}
58+
if ($NULL -like "$metadata.Content") {
59+
if ($stream -eq "bytes") {
60+
[System.Text.Encoding]::ASCII.GetString($metadata.content).split(':')
61+
}
62+
elseif ($stream -eq "base64") {
63+
[System.Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($metadata.Content)).split(':')
64+
}
65+
}
66+
else {
67+
#no userdata found, exiting...
68+
Exit
69+
}
70+
}
5171
else {
52-
#no userdata found, exiting...
53-
exit
54-
}
72+
#no userdata found, exiting...
73+
Exit
74+
}
5575
}
5676

5777

@@ -128,7 +148,7 @@ Function PostTeamEndpoint {
128148
param (
129149
[post]$Params
130150
)
131-
$body = $Params | select * -ExcludeProperty key, team_id
151+
$body = $Params | Select-Object * -ExcludeProperty key, team_id
132152
$TeamEndpointHeaders = @{
133153
"Content-Type" = "application/json"
134154
"X-Machine-Key" = $params.key

0 commit comments

Comments
 (0)