linux笔记5-shell01
目录
设置函数
function test-conn {Test-Connection -Count 2 -ComputerName $args}
装函数设置别名
Set-Alias tc test-conn
使用别名并传递参数
tc localhost
定义的变量
$a=10
$=4
计算变量
$result=$a*$b $msg="保存文本"
输出变量
$result $msg
可把一条cmdlet命令赋值给变量
$item=Get-ChildItem
powershell中交换变量值
$vluae1=10
$value2=20
$value1,$value2=$value2,$value1
查看正在使用的变量
ls variable:
查找变量
value
ls variable:"value"
验证变量value1是否存在
Test-Path variable:value1
变量会在退出powershell时自动清除,也可手动删除变量
del variable:value1
5个专用变量管理命令
Clear-Variable
Get-Variable
New-Variable
Remove-Variable

浙公网安备 33010602011771号