-
Notifications
You must be signed in to change notification settings - Fork 2
/
kickOff.ps1
87 lines (65 loc) · 3.36 KB
/
kickOff.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#############################################################################
# Starts the provisioning job
#############################################################################
Set-ExecutionPolicy RemoteSigned -Force
# Kicking off
$logfilename = "provisioning"
# Import the module
$moduleUrl = "https://raw.githubusercontent.com/sonykey2003/win-auto-pilot/master/main.psm1"
$script = [scriptblock]::Create((Invoke-RestMethod -Method get -Uri $moduleUrl))
New-Module -Name wap.main -ScriptBlock $script | Out-Null
# Set timezone based on the geo location
$countryInfo = Get-GeoApi
set-tz -countryname $countryInfo.country_name
# Change the hostname to new and not rebooting
$newHostname = Set-Hostname
# Installing JC agent
## Getting the connet key
$getConnkey_url = "https://hook.us1.make.com/b6rlunkty6aff82mc0sy89u3wpl5xkmh" #change it to your webhook url
#retry 5 times if there is wrong inputs
$retry = 5
do {
if ($retry -lt 5){
Write-Host "Trying again...please input the correct info!" -ForegroundColor DarkYellow
}
$onboardInfo = getConnKey -url $getConnkey_url
$retry -= 1
} while (
($null -eq $onboardInfo.conn_key) -and ($retry -gt 0)
)
$BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($onboardInfo.conn_key)
$conn_Key = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)
$jcConfig = "C:\Program Files\JumpCloud\Plugins\Contrib\jcagent.conf"
## installation
installJCAgent -conn_key $conn_Key
$systemKey = (ConvertFrom-Json (Get-Content $jcConfig)).systemKey
[string]$sudo = "false" #user will not be the local admin on the device by default.
[string]$sudoWithoutPW = "false" #sudo with pw option only valid when sudo = true
# JC user & system operations
$jcSystemBindUser_url = "https://hook.us1.make.com/y85m9lxkhgrjlcco6ahzakasg3bt7cr7" #change it to your webhook url
$jcSystemAddGroup_url = "https://hook.us1.make.com/8hakbgiqck9iojz5mn5e35em6p84q1ry" #change it to your webhook url
## Do user binding
jcSystemBindUser -url $jcSystemBindUser_url `
-systemKey $systemKey `
-newHostname $newHostname `
-user_id $onboardInfo.user_id `
-sudo $sudo -sudoWithoutPW $sudoWithoutPW
sleep 10
## Add the device to a default group
$groupName = "All Windows"
jcSysAddGroup -url $jcSystemAddGroup_url -systemKey $systemKey -groupName $groupName
# Prep for reboot
$Banner = @"
________ ___ ___ ________ ________ ________ _______ ___
|\ __ \|\ \ |\ \ |\ ___ \|\ __ \|\ ___ \|\ ___ \ |\ \
\ \ \|\ \ \ \ \ \ \ \ \ \_|\ \ \ \|\ \ \ \\ \ \ \ __/|\ \ \
\ \ __ \ \ \ \ \ \ \ \ \ \\ \ \ \\\ \ \ \\ \ \ \ \_|/_\ \ \
\ \ \ \ \ \ \____\ \ \____ \ \ \_\\ \ \ \\\ \ \ \\ \ \ \ \_|\ \ \__\
\ \__\ \__\ \_______\ \_______\ \ \_______\ \_______\ \__\\ \__\ \_______\|__|
\|__|\|__|\|_______|\|_______| \|_______|\|_______|\|__| \|__|\|_______| ___
|\__\
\|__|
"@
Write-Host $Banner -ForegroundColor Green
sleep 10
Restart-Computer -force