-
Notifications
You must be signed in to change notification settings - Fork 0
/
Stop-Computer_und_Restart-Computer.ps1
57 lines (43 loc) · 2.09 KB
/
Stop-Computer_und_Restart-Computer.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
<# _ _ _ _
__| (_) ___ ___| | ___ __ ___| |_
/ _` | |/ _ \/ __| |/ / '_ \ / _ \ __|
| (_| | | __/ (__| <| | | | __/ |_
\__,_|_|\___|\___|_|\_\_| |_|\___|\__|
PowerShell Quick Tipp
Stop-Computer_und_Restart-Computer.ps1
Mit Stop-Computer kann einer oder mehrere Computer heruntergefahren werden.
Mit Restart-Computer kann einer oder mehrere Computer neu gestartet werden.
Demo-Video dazu: https://youtube.com/shorts/T4_Nh3Fcq9E
#>
###############################
# HERUNTERFAHREN / SHUTDOWN #
###############################
# Beispiel 1
# Den lokalen, eigenen Computer herunterfahren (wenn kein Computer angegeben wird, wird immer der lokale PC genommen)
Stop-Computer
# Beispiel 2
# Den lokalen, eigenen Computer herunterfahren (hier wird explizit der lokale Computer per "localhost" referenziert)
Stop-Computer -ComputerName localhost
# Beispiel 3
# Drei bestimmte Computer werden heruntergefahren. Die einzelnen Einträge per Komma trennen.
Stop-Computer -ComputerName server01,server02,localhost
# Beispiel 4
# Den lokalen, eigenen Computer herunterfahren (wenn kein Computer angegeben wird, wird immer der lokale PC genommen)
# Das beenden von Prozessen die das herunterfahren blockieren wird erzwungen (per -Force)
Stop-Computer -Force
###############################
# NEUSTART / RESTART #
###############################
# Beispiel 5
# Den lokalen, eigenen Computer neustarten (wenn kein Computer angegeben wird, wird immer der lokale PC genommen)
Restart-Computer
# Beispiel 6
# Den lokalen, eigenen Computer neustarten (hier wird explizit der lokale Computer per "localhost" referenziert)
Restart-Computer -ComputerName localhost
# Beispiel 7
# Drei bestimmte Computer werden neugestartet. Die einzelnen Einträge per Komma trennen.
Restart-Computer -ComputerName server01,server05.mydomain.com,localhost
# Beispiel 8
# Den lokalen, eigenen Computer neustarten (wenn kein Computer angegeben wird, wird immer der lokale PC genommen)
# Das beenden von Prozessen die das herunterfahren blockieren wird erzwungen (per -Force)
Restart-Computer -Force