-
Notifications
You must be signed in to change notification settings - Fork 4
/
notebookhelperSO.ps1
224 lines (168 loc) · 8.58 KB
/
notebookhelperSO.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
<#
notebookhelperSO.ps1
.DESCRIPTION
Hilft Notebooks nach der Windowsinstallation nach Hause zu finden
https://github.com/thelamescriptkiddiemax/soest
#>
#--- Variablen ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
$loeschuser = "crapuser" # Zu loeschender user BSP "DummerUser4"
$userPWbearbeitung = "Administrator" # User dessen Passwort geaendert werden soll BSP "User13"
$wlanProfil1 = "WLAN-1.xml" # Zu importierendes Profil 1
$wlanProfil2 = "WLAN10004.xml" # Zu importierendes Profil 2
$wlanDelay = "10" # Zu wartende Zeit nach WLAN-Beitritt um auf Adaptnerneustart zu warten in Sekunden BSP "10"
$proxyserver = "10.10.10.10:8080" # Proxy + Port BSP: "172.16.0.1:8080"
$domaintojoin = "powerpetting.party" # Domainname BSP: "pettingzoo.party"
#$oupfad = "OU=Noteboocks,OU=Raum 1408,DC=ad,DC=pettingzoo,DC=party" # Der OU-Pfad (distinguishedName) BSP: "OU=Noteboocks,OU=Raum 1408,DC=ad,DC=pettingzoo,DC=party"
#--- Vorbereitung -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
$stringhost = [System.String]::Concat("[ ", $env:UserName, " @ ", $env:computername, " @ ", ((Get-WmiObject Win32_ComputerSystem).Domain), " ", (Get-CimInstance Win32_OperatingSystem | Select-Object Caption), ": ",
((Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\" -Name ReleaseID).ReleaseId), " ] ", (Get-Date -Format "dd/MM/yyyy HH:mm:ss"), "`n", "[ ", $MyInvocation.MyCommand.Name, " ]", "`n","`n")
$stringhost = $stringhost.replace("{Caption=Microsoft"," ").replace("}", " ")
#--- Verarbeitung ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# Phase 0 - Begruessung und Credentials
Clear-Host
Write-Host " "
Write-Host " "
Write-Host " -- Notebook Helper -- "
Write-Host " "
Write-Host " "
Write-Host " "
Start-Sleep -Milliseconds 900
Clear-Host
Write-Host $stringhost -ForegroundColor Magenta
Write-Host " "
Write-Host " "
Write-Host " Hey hey hey!"
Write-Host " Hast du dich verlaufen, kleines Notebook?"
Write-Host " Ich helfe dir nach Hause..."
Write-Host " "
Write-Host " "
Start-Sleep -Seconds 2
Clear-Host
Clear-Host
Write-Host $stringhost -ForegroundColor Magenta
Write-Host " "
Write-Host " Domain Credentials benoetigt!"
Write-Host " "
Write-Host " "
$domaincredential = Get-Credential
pause
Clear-Host
Write-Host $stringhost -ForegroundColor Magenta
Write-Host " "
Write-Host " Neues Passwort"
Write-Host " $userPWbearbeitung "
Write-Host " benoetigt!"
Write-Host " "
$neuespw = read-host "Passwort $userPWbearbeitung" -asSecureString # Neues User-PW
#--- Phase I - Name, User, WLAN1 und Updates -------------------------------------------------------------------------------------------------------------------------------------------------------------------
Clear-Host
Write-Host $stringhost -ForegroundColor Magenta
Write-Host " "
Write-Host " Phase 1"
Write-Host " "
Start-Sleep -Seconds 1
Clear-Host
#------------------------------------------------------------------------------------------------------------------------------------------------------------------
Remove-LocalUser -Name $loeschuser # Ueberfluessiger User loeschen
$userX = Get-LocalUser -Name $userPWbearbeitung # Get-LocalUser binden
$userX | Set-LocalUser -Password $neuespw # Passwort fuer User aendern
Clear-Host
Write-Host $stringhost -ForegroundColor Magenta
Write-Host " "
Write-Host " Ueberfluessinger User $loeschuser entfernt!"
Write-Host " Passwort fuer $userPWbearbeitung gesetzt!"
Write-Host " "
Start-Sleep -Milliseconds 800
Clear-Host
#------------------------------------------------------------------------------------------------------------------------------------------------------------------
netsh wlan add profile filename="$PSScriptRoot\$wlanProfil1" user=all # WLAN join 1
Clear-Host
Write-Host $stringhost -ForegroundColor Magenta
Write-Host " "
Write-Host " WLAN1 $wlanProfil1 verbunden! Mache $wlanDelay Sek Pause... Lade dann Updates..."
Write-Host " "
Start-Sleep --Seconds $wlanDelay
Clear-Host
#------------------------------------------------------------------------------------------------------------------------------------------------------------------
Install-Module -Name PSWindowsUpdate -Force # PowerShell Update-Modul installieren
Import-Module PSWindowsUpdate # PowerShell Update-Modul importieren
Download-WindowsUpdate -ForceDownload # Updates downloaden
Install-WindowsUpdate -ForceInstall # Updates installieren
#------------------------------------------------------------------------------------------------------------------------------------------------------------------
Clear-Host
Write-Host $stringhost -ForegroundColor Magenta
Write-Host " "
Write-Host " Updates installiert! Entferne WLAN1 $wlanProfil1 ..."
Write-Host " "
Start-Sleep -Milliseconds 800
Clear-Host
#------------------------------------------------------------------------------------------------------------------------------------------------------------------
Netsh wlan delete profile $wlanProfil1 -Force # WLAN1 Profil loeschen
Clear-Host
Write-Host $stringhost -ForegroundColor Magenta
Write-Host " "
Write-Host " WLAN1 $wlanProfil1 entfernt!"
Write-Host " "
Start-Sleep -Milliseconds 800
Clear-Host
#--- Phase II - WLAN2, Proxy und Domainjoin -------------------------------------------------------------------------------------------------------------------
Clear-Host
Write-Host $stringhost -ForegroundColor Magenta
Write-Host " "
Write-Host " Phase 2"
Write-Host " "
Start-Sleep -Seconds 1
Clear-Host
Clear-Host
Write-Host $stringhost -ForegroundColor Magenta
Write-Host " "
Write-Host " Setze Proxy und trete WLAN2 $wlanProfil2 bei..."
Write-Host " "
Start-Sleep -Milliseconds 800
Clear-Host
#------------------------------------------------------------------------------------------------------------------------------------------------------------------
netsh winhttp set proxy $proxyserver # Proxy setzen
#------------------------------------------------------------------------------------------------------------------------------------------------------------------
netsh wlan add profile filename="$PSScriptRoot\$wlanProfil2" user=all # WLAN join 2
Clear-Host
Write-Host $stringhost -ForegroundColor Magenta
Write-Host " "
Write-Host " Proxy gesetzt!"
Write-Host " Mit WLAN2 $wlanProfil2 verbunden! Mache $wlanDelay Sek Pause, "
Write-Host " trete dann Domain $domaintojoin bei..."
Write-Host " "
Start-Sleep -Seconds $wlanDelay
Clear-Host
#------------------------------------------------------------------------------------------------------------------------------------------------------------------
Add-Computer -DomainName $domaintojoin -Credential $domaincredential # -OUPath $oupfad # Domainjoin
Clear-Host
Write-Host $stringhost -ForegroundColor Magenta
Write-Host " "
Write-Host " Domain $domaintojoin beigetreten!"
Write-Host " "
Start-Sleep -Milliseconds 500
Clear-Host
#------------------------------------------------------------------------------------------------------------------------------------------------------------------
Clear-Host
Write-Host $stringhost -ForegroundColor Magenta
Write-Host " "
Write-Host " Alles Erledigt!"
Write-Host " Das Notebook $env:computername ( $neuerName )"
Write-Host " ist jetzt zuhause..."
Write-Host " "
Start-Sleep -Seconds 2
Clear-Host
Clear-Host
Write-Host $stringhost -ForegroundColor Magenta
Write-Host " "
Write-Host " -- Notebook Helper --"
Write-Host " "
Start-Sleep -Milliseconds 900
#------------------------------------------------------------------------------------------------------------------------------------------------------------------
Clear-Host
Write-Host $stringhost -ForegroundColor Magenta
Write-Host " "
Write-Host " Neustart des Systems in 5 Sekunden!"
Write-Host " "
Start-Sleep -Seconds 5
Restart-Computer -Force # Neustart