人的一生,没有一味的苦,没有永远的痛;没有迈不过的坎,没有闯不过的关!
-
PowerShell是微软面向对象的一门语言
-
我现在虚拟机、宿主机都是Windows2019的版本,内置了PowerShell5.1
-
两种进入方式:1.类似进入命令行CMD;2.PowerShell的ISE内有提示、《颜色显示
-
PoweShell的注释:
- 单行注释
#注释内容
- 注释块
<# 注释内容 #>
-
PoweShell的if、function块等自动识别开闭,但是可以使用
#region #endregion
-
Power Shell可以识别{}、[]、()
- 放在一半,另一半变亮;
- 快捷键
-
Power Shell内置了代码块。调用
-
右键
-
ctrl+j
-
-
Power Shell的On the line 搜索命令
PowerShell的基本命令
-
除了支持本身命令,还支持其他的如cmd的ping、ipconfig;但是powershell本身有相似对应的命令
ipconfig Get-NetIPAddress
ping test-connection
推荐使用PowerShell 的Cmdlet
-
Cmdlet的组成:
- Command Name Command Paramenters
- Remove-Item -Path C:\TEmp -Force
-
get -command :获取命令的信息
-
注意命令缩写,自己设定命令的缩写(不推荐,要跨平台,其他人误解)
-
查奇怪命令的用法 $? | {}
Get-Alias -Name ?
-
PowerShell的命令参数类型
- 样式 内容 是否要求必写
- [] 否
- 没有标志 开关(输入开不输入关) 是
-
PowerShell的参数集 不能混用
-
参数集 多个参数集不能混用
-
Data 所有数据存储在一个对象里
-
$a=1 $a
-
$a =Get-Service 变为PowerShell的对象
-
$a =Get-Service 特有Start stop
-
$a[0].name
-
New-Variable c -Value 3 定义一个值为3的对象
-
Get-Variable -name c 获取c的值 大小写不敏感;空格敏感
-
Clear-Variable -name c 清空c 的值
- $c 为空
- Get-Variable -name c Value为空
-
Remove-Variable -name c 删除c变量