@@ -7,6 +7,7 @@ PowerShell 备忘清单
7
7
---
8
8
9
9
### 辅助命令
10
+ <!-- rehype:wrap-class=row-span-2-->
10
11
11
12
** _ PowerShell 的命令遵循动词-名词格式_ ** 一些常见的动词:
12
13
@@ -57,6 +58,7 @@ Get-Process | Get-Member
57
58
```
58
59
59
60
### 对象操作
61
+ <!-- rehype:wrap-class=col-span-2-->
60
62
61
63
** Select-Object:** 选择对象的特定属性或自定义其显示
62
64
@@ -103,6 +105,7 @@ Get-Process | Format-List -Property Name, CPU # fl alias
103
105
```
104
106
105
107
### 文件系统
108
+ <!-- rehype:wrap-class=col-span-2-->
106
109
107
110
``` PowerShell
108
111
New-Item -path file.txt -type 'file' -value 'contents'
@@ -143,14 +146,26 @@ Get-CimInstance -ClassName Win32_VideoController
143
146
144
147
### 命名空间 & 类
145
148
149
+ 列出所有类名
150
+
146
151
``` PowerShell
147
- # 列出所有类名
148
152
Get-CimClass | Select-Object -ExpandProperty CimClassName
149
- # 探索 root\cimv2 命名空间中的各种 WMI 类
153
+ ```
154
+ <!-- rehype:className=wrap-text-->
155
+
156
+ 探索 root\cimv2 命名空间中的各种 WMI 类
157
+
158
+ ``` PowerShell
150
159
Get-CimClass -Namespace root\cimv2
151
- # 探索 root\cimv2 命名空间下的子 WMI 命名空间
160
+ ```
161
+ <!-- rehype:className=wrap-text-->
162
+
163
+ 探索 root\cimv2 命名空间下的子 WMI 命名空间
164
+
165
+ ``` PowerShell
152
166
Get-CimInstance -Namespace root -ClassName __NAMESPACE
153
167
```
168
+ <!-- rehype:className=wrap-text-->
154
169
155
170
### 网络管理
156
171
@@ -169,7 +184,6 @@ Get-NetRoute
169
184
170
185
# 测试远程主机上的端口是否开放
171
186
Test-NetConnection google.com -Port 80
172
-
173
187
```
174
188
175
189
### 用户和组管理
@@ -193,13 +207,18 @@ Add-LocalGroupMember -Group Administrators -Member UserToAdd
193
207
194
208
### 安全性和权限
195
209
210
+ 获取文件/目录的访问控制列表
211
+
196
212
``` PowerShell
197
- # 获取文件/目录的访问控制列表
198
213
Get-Acl C:\Path\To\File.txt
214
+ ```
215
+
216
+ 设置文件/目录的访问控制列表
199
217
200
- # 设置文件/目录的访问控制列表
218
+ ``` PowerShell
201
219
Set-Acl -Path C:\Path\To\File.txt -AclObject $aclObject
202
220
```
221
+ <!-- rehype:className=wrap-text-->
203
222
204
223
### 注册表管理
205
224
0 commit comments