-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathPoshCrashCourse_2016-10-20.ps1
189 lines (122 loc) · 3.13 KB
/
PoshCrashCourse_2016-10-20.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
<#
PowerShell Crashkurs
20.10.2016
Einführung
-------------
- PowerShell 1.0 verfügbar ab Windows Server 2003/Windows XP/Windows Vista, erstmals mit Microsoft Exchange Server 2007
- PowerShell ist Open Source
https://github.com/PowerShell/PowerShell
- PowerShell ist eine Cross Platform Technologie (PowerShell Core basierend auf .NET Core)
Windows
Client
Server
Linux
Ubuntu 14.04 \ 16.04
CentOs 7.1
RHEL 7
MAC OS X
OS X 10.11
Docker
https://github.com/PowerShell/PowerShell/blob/master/docs/installation
- Aktuelle Version 5.0 (Windows Management Framework 5.0),
bereits Preview für 6.0 auf GitHub erhältlich
s
- Langfristig Ersatz für cmd und VBScript/Windows Scripting Host
- Kombiniert den aus den UNIX-Shells bekannten Ansatz von Pipes und Filtern
mit dem Paradigma der objektorientierten Programmierung
- Verwendung unterschiedlichster Technologien
- .NET Framework
- ADSI
- COM
- WMI
Dateiendungen
--------------
.ps1 – Windows PowerShell Shell-Skript
.ps1xml – Windows PowerShell Format- und Typdefinitionen
.psc1 – Windows PowerShell Konsolendatei (exportierte Shell-Konfiguration)
.psd1 – Windows PowerShell Datendatei
.psm1 – Windows PowerShell Moduldatei
#>
# Powershell Version
$PSVersionTable
# PowerShell Host
Get-Host
# Vordefinierte Variablen
Get-Variable
<#
Variablen
----------
implizite Deklaration -> Datentyp muss nicht explizit angegeben werden
$i = '1'
$i = $i + 1
$j = 1
$j = $j + 1
$a = Get-Process
$b
Invoke-Command $b | Select ProcessName -Unique
#>
<#
CmdLets und Module
- CmdlLets
Konvention für CmdLet Namen: Verb-Noun
-Module
Zusammenfassung von Cmdlets
- DLL Module
- Manifest Module
- Script Module
-Aliase
- What you see is NOT, what you get!
#>
Get-Verb
Get-Verb | Group-Object -Property Group
Get-Verb | Where-Object -Property Group -EQ -Value Common
Get-Alias
Get-Module
$env:PSModulePath
<#
Wie finde ich Hilfe zu Befehlen, Datentypen, etc
Get-Help about_Core_Commands
Get-Help about_Logical_Operators
Get-Help about_Comparison_operators -ShowWindow
Get-Help about_Operators -ShowWindow
#>
Get-Help
Get-Member
Get-Module
Get-Command
<#
Pipelines
----------
Selektieren; Messen, Sortieren
Get-Service DPS
Select-Object
Where-Object
Sort-Object
Measure-Object
get-service | Where-Object { $_.Status -eq 'Stopped' }
#>
<#
Strukturen
-----------
Arrays
Hashtables
Methoden, Properties an Objekten
#>
<#
Scripting, Funktionen, Verzweigungen, Schleifen
if
foreach
while
do
for
switch
#>
<#
Find-Module
Install-Module
#>
<#
$rssUrl = "http://blogs.msdn.com/b/powershell/rss.aspx"
$blog = [xml](New-Object System.Net.WebClient).DownloadString($rssUrl)
$blog.rss.channel.item | select title -First 8
#>