PowerShell学习笔记(1)

  • PowerShell V3 �CWindows 8和Server 2012

  • PowerShell V2 �CWindows 7和Server 2008

  • 下载Windows Management Framework 3.0

  • http://www.microsoft.com/en-us/download/details.aspx?id=34595

  • Windows XP和Server 2003可以运行V2

以管理员运行

001IPj7xgy6IfNs52vpdb&690


shell操作:

动词-名词

通配符

  • cls-Clear-Host

  • cd -Set-Location

  • dir, ls -Get-Childitem

  • type, cat -Get-Content

  • Copy, cp-Copy-item

帮助

Update-help -force更新帮助信息(外网)

Save-help存到本地

Get-Alias别名支持通配符

Get-help *services*支持通配符,查找与服务相关命令

Get-help get-services -example示例/-detailed详细/-full所有  

-ShowWindow(以图形模式查看powershell3.0)

添加功能

PowerShell2.0

先Get-windowsFeature *powershell*

再Add-windowsFeature

PowerShell3.0

Install-windowsFeature

管道(用左边获得的信息来执行后面的命令):

Get-process | export-clixml c:\test.xml导出为xml

Get-process | export-csv c:\proc.csv 导出为csv

Get-process | ConvertTo-csv | out-file c:\proc.csv转换并输出为csv

Get-process | convertTo-html  -proprety displayname,status | out-file c:\proc.htm转换为html网页包含显示名和状态输出

对比机器进程使用状态:

001IPj7xgy6IfNveTFx0b&690

确认

Get-service | stop-service -whatif不确定的话看看会发生啥

Get-service | stop-service -confirm确认请求

Get-service *bit* | stop-service -whatif选择某个服务然后尝试会发生什么

模块

Get-module获取当前加载了的模块

get-module -ListAvailable(获取当前可导入的模块)

-Powershell 3.0可以用get-help 查询到未加载模块中的命令

-Powershell 3.0可以自动加载执行命令所需加载的模块

你可能感兴趣的:(windows,脚本,学习笔记,powershell,powershell脚本)