Windows PowerShell基本命令总结(一)
来源:互联网 发布:c语言中文网vip破解 编辑:程序博客网 时间:2024/05/16 19:25
菜鸟在学习Windows PowerShell,把学过的内容总结一下,加深理解,在遗忘的时候快速地回想起来。。。
学习网站:http://www.computerperformance.co.uk/powershell
三个重要的基本命令,可以让我们在迷茫的时候看到点希望:
1) get-command
2) get-help
3) get-member //get properties and methods of any object
基本命令,给出的例子串了几个命令,这样能有直观的理解:
4) add-content
5) get-content
6) compare-object //比较的两文件有先后顺序
例1:比较两个文件内容:
$path1 = "C:/powershell/application/ShopList.txt"
$path2 = "C:/powershell/application/CheckOut.txt"
add-content -path $path1 -value "apples oranges steak"
add-content -path $path2 -value "apples oranges"
$shoplist = get-content $path1 |foreach-object {$_}
$changed = get-content $path2 |foreach-object {$_}
Compare-Object -referenceobject $shoplist -differenceobject $changed
7) get-process
8) format-table
9) format-list
10) out-file
例2:
$Proc = Get-Process | Get-Member -Membertype property
$Proc | Format-Table name | out-file procprop1.txt
Get-Service vss | Format-List
11) get-credential
12) get-date
13) group-object //"group", or alternative "|ft -groupby"
14) get-service
15) export-csv
16) import-csv
例3:
$Cr = Get-Credential -credential Administrator
Get-Service | Group-Object status
$path = "c:/powershell/content/csv.csv"
get-service |export-csv $path
import-csv $path |get-member
循环语句:
17) do-while
18) for
19) foreach
例4:输出小于84的7的倍数
$i=7; do {$i; $i+=7} while($i -lt 84)
for ( $i = 7; $i -lt 84; $i+=7 ) { $i }
foreach ($i in 1,2,3,4,5,6,7,8,9,10,11,12) {$i*7}
- Windows PowerShell基本命令总结(一)
- Windows PowerShell基本命令总结(二)
- Windows PowerShell 命令收集
- windows powershell 命令笔记
- docker 基本命令总结(一)
- Linux基本命令总结一
- Windows PowerShell的常见命令
- 常用的Windows PowerShell 命令
- Windows PowerShell中scp命令
- Windows PowerShell基本语法及常用命令
- Windows PowerShell基本语法及常用命令
- Windows PowerShell 基本语法及常用命令
- Windows PowerShell 2.0 开发之命令别名
- 使用自定义命令扩展 Windows PowerShell
- Windows管理员常用的PowerShell命令
- MySQL基本命令(WINDOWS)
- Linux 基本命令(一)
- Linux基本命令(一)
- elisp 基础
- 设置JPanel或jframe的背景图片
- CentOS上升级Subversion
- xlc -bnoquiet【UNIX晓习笔记】
- ie6,7下js动态加载图片不显示错误
- Windows PowerShell基本命令总结(一)
- Attachements标准功能配置
- 基于C#的接口基础教程之一
- ASP.NET 2.0 GridView的RowCommand事件中取得行索
- Dos 和 DDos 的相关概念问题
- List 容器
- 使用LS2J技术在LotusScript中来调用Java[转]
- oAuth
- 使用 Windows Vista 的凭据提供程序创造自定义的登录体验