您的位置:首页 > 运维架构 > Shell

powershell

2013-11-23 23:57 513 查看
http://technet.microsoft.com/zh-cn/scriptcenter/powershell.aspx

$Host.Version

1..15 | % {Write-Host -ForegroundColor $_ "Hello"}

Get-Process | Stop-Process -WhatIf

Get-Process | Stop-Process -Confirm

Get-EventLog -LogName application -Newest 1

Get-Verb

Get-Variable

Get-Command

Get-Help

Update-Help

Get-Help Get-Process -Examples

Dir,Cls,Md,Rd,Ls,Get-Process,Get-Service,Get-EventLog,Get-Lost?,Get-Help

cat,可以用文本文件作为输入参数

Get-Process notepad | Stop-Process

Get-History(h), r 23再次执行第23条历史指令

重定向:>,>>

读文件:Get-Content(gc,cat,type)

添加内容:Add-Content(ac)

删除文件:Remove-Item(del,erase)

dir | where { $_.Mode -match '^d' }

Get-ChildItem . | where { $_.LastWriteTime -gt [datetime]"3/3/2013" }

New-Item Alias:myalias -Value gps

New-Item function:myfunction -Value{Get-Process -name $input}, "svchost" | myfunction

New-Item env:myenv -Value "myenv", Get-Item Env:\myenv

New-Item variable:myvar -Value "myVar", Get-Item Variable:\myvar

Variable:Clear-Variable,Get-Variable,New-Variable,Remove-Variable,Set-Variable

Alias: Expor-Alias,Get-Alias,Import-Alias,New-Alias,Set-Alias

Get-Command -Noun Variable,Get-Variable $ | Format-List

Get-Command -Noun alias
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: