-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPowershell
More file actions
258 lines (124 loc) Β· 4.05 KB
/
Powershell
File metadata and controls
258 lines (124 loc) Β· 4.05 KB
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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
PowerShell Basics β Beginner Command Guide
PowerShell is a task automation and configuration management framework from Microsoft. It consists of a command-line shell and a powerful scripting language built on .NET. Unlike traditional shells, PowerShell works with objects, not just text, making it extremely powerful for system administration and automation.
This guide covers core PowerShell cmdlets every beginner should know, with explanations and examples.
There is a guide you can easily copy the code to the clipboard from
https://powershell-guide.notaku.site/
---
π Getting Help & Discovering Commands
Get-Help
Displays help information about cmdlets and PowerShell concepts.
Get-Help Get-Process
What it does:
Shows documentation, parameters, examples, and usage details for Get-Process.
π‘ Tip:
Get-Help Get-Process -Examples
---
Get-Command
Lists available cmdlets, functions, aliases, and scripts.
Get-Command
What it does:
Shows all commands available in your current PowerShell session.
π‘ Useful filtering:
Get-Command *service*
---
π₯οΈ Working with Processes & Services
Get-Process
Retrieves processes running on the local or remote machine.
Get-Process
What it does:
Lists all running processes, including CPU and memory usage.
---
Get-Service
Displays services and their current status.
Get-Service
What it does:
Shows whether services are Running, Stopped, or Paused.
π‘ Example:
Get-Service | Where-Object Status -eq "Running"
---
π Script Execution & Security
Set-ExecutionPolicy
Controls which PowerShell scripts are allowed to run.
Set-ExecutionPolicy RemoteSigned
What it does:
Allows locally created scripts to run and requires downloaded scripts to be signed.
β οΈ Best Practice:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
---
π File System Navigation & Management
Get-Item
Gets information about a file or directory.
Get-Item C:\Windows
What it does:
Returns properties such as size, creation date, and attributes.
---
Get-ChildItem
Lists files and folders in a directory.
Get-ChildItem C:\
What it does:
Equivalent to dir or ls.
π‘ Common alias:
ls
---
New-Item
Creates new files, folders, or registry entries.
New-Item -Path "C:\NewFolder" -ItemType Directory
What it does:
Creates a new directory called NewFolder.
---
Copy-Item
Copies files or folders.
Copy-Item -Path "C:\file.txt" -Destination "D:\file.txt"
---
Move-Item
Moves or renames items.
Move-Item -Path "C:\file.txt" -Destination "D:\file.txt"
---
Remove-Item
Deletes files or folders.
Remove-Item -Path "C:\file.txt"
β οΈ Use with caution:
Remove-Item -Path "C:\Folder" -Recurse -WhatIf
---
π Reading & Writing Files
Get-Content
Reads the contents of a file.
Get-Content -Path "C:\file.txt"
π‘ Useful for logs:
Get-Content -Path "log.txt" -Tail 10
---
Set-Content
Overwrites content in a file.
Set-Content -Path "C:\file.txt" -Value "Hello, World!"
---
π§ Remote Command Execution
Invoke-Command
Runs commands on remote computers.
Invoke-Command -ComputerName Server01 -ScriptBlock { Get-Process }
What it does:
Executes commands remotely using PowerShell Remoting (WinRM).
---
π§ Key PowerShell Concepts (Important!)
Objects, Not Text
PowerShell outputs objects, allowing you to filter and manipulate data easily.
Get-Process | Select-Object Name, CPU
---
The Pipeline (|)
Passes objects from one command to another.
Get-Service | Where-Object Status -eq "Stopped"
---
β
Summary
These cmdlets form the foundation of PowerShell and allow you to:
Navigate and manage the file system
Control processes and services
Read and write files
Execute commands locally and remotely
Build powerful automation scripts
PowerShell scales from simple one-liners to enterprise-grade automation, making it an essential skill for IT support, system administrators, and DevOps engineers.
---
If you want, I can also:
Add real-world IT support examples
Turn this into a PowerShell cheatsheet
Expand it into a learning roadmap
Add advanced cmdlets (AD, Intune, M365, Azure)
Just say the word.