PowerShell 命令表(全)
powershell命令大全
rv Alias RemoveVariable rvpa Alias ResolvePath rwmi Alias RemoveWmiObjec t sajb Alias StartJob sal Alias SetAlias saps Alias StartProcess sasv Alias StartService sbp Alias SetPSBreakp oint sc Alias SetContent select Alias SelectObject set Alias SetVariable si Alias Set-Item sl Alias SetLocation
history Alias GetHistory icm Alias InvokeCommand iex Alias InvokeExpressi on ihy Alias InvokeHistory ii Alias InvokeItem ipal Alias ImportAlias ipcsv Alias ImportCsv ipmo Alias ImportModule ipsn Alias ImportPSSessio n ise Alias powershe ll_ise.e xe iwmi Alias InvokeWmiMetho d kill Alias StopProcess
nmo Alias NewModule nsn Alias NewPSSessio n nv Alias NewVariable ogv Alias OutGridView oh Alias Out-Host popd Alias PopLocation ps Alias GetProcess pushd Alias PushLocation pwd Alias GetLocation r Alias InvokeHistory rbp Alias RemovePSBreakp oint rcjb Alias ReceiveJob rd Alias RemoveItem
cmd批处理命令及powershell
cmd批处理命令及powershellPowershell查询IP地址及主机名信息:1.foreach($ipv4 in (ipconfig) -like '*IPv4*') { ($ipv4 -split ' : ')[-1]}2.Get-WMIObject Win32_ComputerSystem |select Name3.$env:COMPUTERNAME4[net.dns]::GetHostAddresses('') | select -ExpandProperty IPAddressToString | select -index 5批处理常⽤命令及⽤法⼤全/thread-39-1-1.html批处理命令获取ip地址:powershell获取ip地址命令:[net.dns]::GetHostAddresses('') | select -ExpandProperty IPAddressToStringPS C:\Users\test001> [net.dns]::GetHostAddresses('') | select -ExpandProperty IPAddressToString | select -index 1 POWERshell命令讲解执⾏powershell脚本/powershell-invoking-files-and-scripts.htmlPowershell拥有⾃⼰的脚本,扩展名为“.ps1”powershell编写和运⾏脚本POWERshell命令讲解Powershell获取软件安装列表cmd获取软件列表python获取软件列表⼀键获取软硬件配置及管理员组bat常⽤命令————————————————————————————————————————————————————定义 set a=224输出 echo %a%显⽰⽂件内容 type a.txt2、添加默认驱动器c:\Users\Administrator>net use l: \\192.168.182.133\share "P@ssw0rd" /user:administrator命令成功完成。
powershell脚本管理命令大全
Name Category Synopsis ---- -------- -------- % Alias ForEach-Object ? Alias Where-Object ac Alias Add-Content asnp Alias Add-PSSnapin cat Alias Get-Content cd Alias Set-Location chdir Alias Set-Location clc Alias Clear-Content clear Alias Clear-Host clhy Alias Clear-History cli Alias Clear-Item clp Alias Clear-ItemProperty cls Alias Clear-Host clv Alias Clear-Variable compare Alias Compare-Object copy Alias Copy-Item cp Alias Copy-Item cpi Alias Copy-Item cpp Alias Copy-ItemProperty cvpa Alias Convert-Path dbp Alias Disable-PSBreakpoint del Alias Remove-Item diff Alias Compare-Object dir Alias Get-ChildItem ebp Alias Enable-PSBreakpoint echo Alias Write-Output epal Alias Export-Alias epcsv Alias Export-Csv epsn Alias Export-PSSession erase Alias Remove-Item etsn Alias Enter-PSSession exsn Alias Exit-PSSession fc Alias Format-Custom fl Alias Format-List foreach Alias ForEach-Object ft Alias Format-Table fw Alias Format-Wide gal Alias Get-Alias gbp Alias Get-PSBreakpoint gc Alias Get-Content gci Alias Get-ChildItem gcm Alias Get-Command gcs Alias Get-PSCallStack gdr Alias Get-PSDrive ghy Alias Get-History gi Alias Get-Item gjb Alias Get-Job gl Alias Get-Location gm Alias Get-Member gmo Alias Get-Module gp Alias Get-ItemPropertygroup Alias Group-Objectgsn Alias Get-PSSession gsnp Alias Get-PSSnapin gsv Alias Get-Service gu Alias Get-Unique gv Alias Get-Variable gwmi Alias Get-WmiObject h Alias Get-History history Alias Get-History icm Alias Invoke-Command iex Alias Invoke-Expression ihy Alias Invoke-History ii Alias Invoke-Item ipal Alias Import-Alias ipcsv Alias Import-Csv ipmo Alias Import-Module ipsn Alias Import-PSSession ise Alias powershell_ise.exe iwmi Alias Invoke-WmiMethod kill Alias Stop-Process lp Alias Out-Printer ls Alias Get-ChildItem man Alias help md Alias mkdir measure Alias Measure-Object mi Alias Move-Item mount Alias New-PSDrive move Alias Move-Item mp Alias Move-ItemProperty mv Alias Move-Item nal Alias New-Alias ndr Alias New-PSDrive ni Alias New-Item nmo Alias New-Module nsn Alias New-PSSession nv Alias New-Variable ogv Alias Out-GridView oh Alias Out-Host popd Alias Pop-Location ps Alias Get-Process pushd Alias Push-Location pwd Alias Get-Location r Alias Invoke-History rbp Alias Remove-PSBreakpoint rcjb Alias Receive-Job rd Alias Remove-Item rdr Alias Remove-PSDrive ren Alias Rename-Item ri Alias Remove-Item rjb Alias Remove-Job rm Alias Remove-Item rmdir Alias Remove-Item rmo Alias Remove-Modulernp Alias Rename-ItemProperty rp Alias Remove-ItemProperty rsn Alias Remove-PSSession rsnp Alias Remove-PSSnapin rv Alias Remove-Variable rvpa Alias Resolve-Path rwmi Alias Remove-WmiObject sajb Alias Start-Job sal Alias Set-Alias saps Alias Start-Process sasv Alias Start-Service sbp Alias Set-PSBreakpoint sc Alias Set-Content select Alias Select-Object set Alias Set-Variable si Alias Set-Item sl Alias Set-Location sleep Alias Start-Sleep sort Alias Sort-Object sp Alias Set-ItemProperty spjb Alias Stop-Job spps Alias Stop-Process spsv Alias Stop-Service start Alias Start-Process sv Alias Set-Variable swmi Alias Set-WmiInstance tee Alias Tee-Object type Alias Get-Content where Alias Where-Object wjb Alias Wait-Job write Alias Write-Output Add-Computer Cmdlet 将本地计算机添加到域或工作组中。
powershell语法手册
powershell语法手册一、简介PowerShell是微软开发的一款强大的命令行脚本和配置环境。
它使用一种基于任务的脚本语言,使得系统管理员能够更高效地管理Windows环境。
PowerShell提供了丰富的命令和功能,使得用户可以自动化许多常见的系统管理任务。
二、基本语法命令结构PowerShell命令的基本结构如下:powershellcommand -Argument $value例如,要获取当前日期,可以使用:powershellGet-Date变量在PowerShell中,变量使用 $ 符号开头。
例如:powershell$variable = "Hello, World!"控制结构If语句:powershellIf ($condition) {# commands}For循环:powershellFor ($i = 0; $i -lt 10; $i++) {# commands}While循环:powershellWhile ($condition) {# commands}函数定义函数的方式如下:powershellFunction functionname {param (param1, param2)# commands}参数 PowerShell命令通常支持参数。
例如,Get-Process 命令可以带一个 -Name 参数来指定要获取的进程的名称。
使用参数的方式如下:powershellGet-Process -Name "notepad"管道管道操作符 | 可以用来将一个命令的输出传递给另一个命令作为输入。
例如:powershellGet-Process | Where-Object { $_.CPU -gt 50 } | Select-Object Name, CPU这个命令会列出CPU使用率超过50%的进程的名称和CPU使用率。
powershell简单命令
powershell简单命令
PowerShell是一种任务自动化和配置管理框架,它提供了一个命令行界面和脚本语言,类似于Unix shell。
以下是一些简单的PowerShell命令:
1. 获取当前目录的内容:
Get-ChildItem.
2. 切换目录:
Set-Location <目录路径>。
3. 显示当前目录的路径:
Get-Location.
4. 显示系统中正在运行的进程:
Get-Process.
5. 显示系统上安装的所有软件:
Get-WmiObject -Class Win32_Product.
6. 显示网络适配器信息:
Get-NetAdapter.
7. 显示系统服务的状态:
Get-Service.
8. 显示环境变量:
Get-ChildItem Env:
以上是一些PowerShell的简单命令,它们可以帮助你执行基本的文件和系统管理任务。
当然,PowerShell还有很多其他功能和命令,可以根据具体需求进行深入学习和使用。
PowerShell命令“Get-Service”的使用方法
PowerShell命令“Get-Service”的使用方法功能Get-Service是 PowerShell 中的一个命令行工具,用于查看和管理 Windows 服务。
它可以显示系统中所有服务的列表,以及每个服务的状态、启动类型和其他相关信息。
用法基本的命令格式如下:Get-Service [-Name] <String[]> [-ComputerName] <String[]> [-DisplayName]<String[]> [-ServiceName] <String[]> [<CommonParameters>]主要参数的作用-Name:指定要查询的服务名称。
-ComputerName:指定要查询的服务所在的主机名或 IP 地址。
-DisplayName:指定要查询的服务的显示名称。
-ServiceName:指定要查询的服务名称的空间分隔列表。
示例1. 获取所有服务的列表:Get-Service2. 获取名为“Network”的服务信息:Get-Service-Name Network3. 获取显示名称为“网络连接”的服务信息:Get-Service-DisplayName "网络连接"4. 获取远程计算机上的服务信息(假设你知道远程计算机的名称或IP地址):Get-Service-ComputerName "RemoteComputer"在使用这些示例时,请确保你正在查询的服务名称和显示名称是正确的。
如果你不确定服务的名称或显示名称,可以先使用Get-Service命令列出所有服务,然后从中找到所需的服务信息。
在操作远程计算机上的服务时,请确保你有足够的权限进行管理。
不正确的操作可能会导致系统不稳定或者服务中断。
PowerShell基本语法及常用命令
PowerShell基本语法及常用命令Powershell常用命令1.Get-Command 得到Powshell所有命令2.Get-Process 获取所有迚程3.Set-Alias 给指定命令重命名如:Set-Alias aaa Get-Command4.Set-ExecutionPolicy remotesigned 设置powershell可直接执行脚本文件一般脚本文件以.ps1结尾执行脚本文件直接输入文件地址即可执行脚本文件中叧写命令即可5.Get-Help get-* 查询以get开头的命令Get-Help *service* Get-Help Get-Command 获取Get-Command命令的基本用法6.Get-Member 获取对象属性如: $var | Get-Memeber 访问$var属性直接$var.ToString()PS中的变量定义不需要定义或声明数据类型在变量前加"$"定义变量的规则-变量可以是数字$123-变量可以是字符串$abc-变量可以是特殊字符${@1b}内置的变量-$pshome-$home-$profile变量赋值: $var=123 $var="aaaaaa"取变量值: $var变量赋值方法:Set-Variable var 100取值方法: Get-Variable var清空值: Clear-Variable var删除变量Remove-Variable var取多个变量如var1 var2 var3地值: Get-Variable var*另一种赋值方法$var1="bbb" $var2="$var $var1" 结果$var2="aaaaaa bbb"$var2='$var $var1' 结果$var2="$var $var1"$date=Get-Date 获取当前时间$date.AddDays(3) 当前时间加3天排序用法Get-Process | Sort-Object ws 根据WS值由小到大排序Get-Process | Sort-Object | fl Get-Process | Sort-Object | Format-List 以列表形式显示数据比较运算符$var="abc"$var -like "*b*" 返回true$var -clike "*b*" 返回true函数使用案例:在一个脚本文件中有如下代码:$var1=10function one{"The Variable is $var1"}function two{$var1=20;one}onetwoone执行结果: The Variable is 10The Variable is 20The Variable is 10此示例表明,在函数中改变变量值并不影响实际值若需改变其值请看如下代码:$var1=10function one{"The Variable is $var1"}function two{$Script:var1=20;one}onetwoone执行结果: The Variable is 10The Variable is 20The Variable is 20 freach使用$var=1..6 #定义数组foreach($i in $var){$n++}Write-Host "there were $n record"if使用If ($a -gt 10){"$a is larger than 10"}ElseIf ($a -eq 10){"$a is exactly 10"}ElseIf ($a -ge 10){"$a is larger than or equal to 10" }Else{"$a is smaller than 10"}-eq 判断是否等于(equal)-lt 判断时候小于(less than)-gt 判断是否大于(greater than)-ge 判断是否大于或等于(greater or equal) -le 判断是否小于或等于(less or equal)-ne 判断是否不等于(no equal)。
powershell tree 指令
powershell tree 指令在PowerShell 中,没有直接提供类似`tree` 命令的内置命令,但你可以使用PowerShell 的一些命令和功能来实现类似的目的。
以下是一些PowerShell 中可以用来显示目录结构的示例:### 1. 使用`Get-ChildItem` 和递归函数```powershellfunction Show-DirectoryTree {param ([string]$path = ".",[int]$indentLevel = 0)$indent = " " * $indentLevel$items = Get-ChildItem $pathforeach ($item in $items) {Write-Host "$indent$item"if ($item.PSIsContainer) {Show-DirectoryTree -path $item.FullName -indentLevel ($indentLevel + 2) }}}# 调用函数显示目录结构Show-DirectoryTree```此函数通过递归地调用自身,使用`Get-ChildItem` 获取目录内容,并显示目录结构。
### 2. 使用`tree` 命令(需要安装)如果你愿意使用外部命令,你可以安装`tree` 工具,并在PowerShell 中调用它。
请确保你已经安装了`tree` 工具,然后使用以下命令:```powershelltree```这将在当前目录下显示目录结构。
请注意,你需要先在系统中安装`tree` 工具。
### 3. 使用`Format-Table` 和递归```powershellfunction Format-DirectoryTree {param ([string]$path = ".",[int]$indentLevel = 0)$indent = " " * $indentLevel$items = Get-ChildItem $pathforeach ($item in $items) {$formattedItem = "$indent$item"if ($item.PSIsContainer) {Write-Host $formattedItemFormat-DirectoryTree -path $item.FullName -indentLevel ($indentLevel + 2) } else {Write-Host $formattedItem}}}# 调用函数显示目录结构Format-DirectoryTree```此函数类似于第一个示例,但使用`Format-Table` 将目录结构格式化输出。
windows powershell基本语法及常用命令
windows powershell基本语法及常用命令摘要:I.引言- 介绍Windows PowerShell- 解释PowerShell的基本语法II.PowerShell基本语法- 命令提示符- 变量- 运算符- 条件语句- 循环语句III.常用命令- 文件和文件夹操作- 网络操作- 系统管理- 帮助和支持IV.高级功能- 脚本编写- 模块管理- 错误处理V.结论- 总结PowerShell的功能和优点- 鼓励读者学习和使用PowerShell正文:Windows PowerShell是一种强大的命令行工具,它提供了许多高级功能,可以帮助用户更高效地管理计算机和执行任务。
PowerShell的基本语法包括命令提示符、变量、运算符、条件语句和循环语句等,这些语法是编写PowerShell脚本的基础。
在PowerShell中,命令提示符是执行命令的地方,它类似于DOS命令提示符。
变量是存储数据的容器,可以使用它们来存储结果和值。
运算符用于执行各种算术和逻辑操作,例如加、减、乘、除和比较操作。
条件语句和循环语句用于控制程序的执行流程,可以根据特定条件执行不同的代码块。
PowerShell还提供了许多常用命令,用于执行各种任务。
例如,文件和文件夹操作命令可以帮助用户管理文件和文件夹,包括创建、删除、重命名和移动文件和文件夹。
网络操作命令可以帮助用户管理网络连接和资源,例如创建、删除和修改网络共享。
系统管理命令可以帮助用户管理计算机的硬件和软件资源,例如查看计算机配置、安装和卸载软件。
帮助和支持命令可以帮助用户查找和使用PowerShell的帮助文档和社区支持。
除了基本语法和常用命令外,PowerShell还提供了许多高级功能,例如脚本编写、模块管理和错误处理。
脚本编写允许用户创建自定义脚本,以执行复杂任务和自动化任务。
模块管理允许用户管理PowerShell模块,这些模块可以提供额外的功能和命令。
PowerShell命令
PowerShell命令[PowerShell]#别名ac = Add-Contentasnp = Add-PSSnapinclc = Clear-Contentcli = Clear-Itemclp = Clear-ItemPropertyclv = Clear-Variablecpi = Copy-Itemcpp = Copy-ItemPropertycvpa = Convert-Pathdiff = Compare-Objectepal = Export-Aliasepcsv = Export-Csvfc = Format-Customfl = Format-Listforeach = ForEach-Object% = ForEach-Objectft = Format-Tablefw = Format-Widegal = Get-Aliasgc = Get-Contentgci = Get-ChildItemgcm = Get-Commandgdr = Get-PSDriveghy = Get-Historygi = Get-Itemgl = Get-Locationgm = Get-Membergp = Get-ItemPropertygps = Get-Processgroup = Group-Objectgsv = Get-Servicegsnp = Get-PSSnapingu = Get-Uniquegv = Get-Variablegwmi = Get-WmiObjectiex = Invoke-Expressionihy = Invoke-Historyii = Invoke-Itemipal = Import-Aliasipcsv = Import-Csvmi = Move-Itemmp = Move-ItemPropertynal = New-Aliasndr = New-PSDriveni = New-Itemnv = New-Variableoh = Out-Hostrdr = Remove-PSDriveri = Remove-Itemrni = Rename-Itemrnp = Rename-ItemPropertyrp = Remove-ItemPropertyrsnp = Remove-PSSnapinrv = Remove-Variablervpa = Resolve-Pathsal = Set-Aliassasv = Start-Servicesc = Set-Contentselect = Select-Objectsi = Set-Itemsl = Set-Location sleep = Start-Sleep sort = Sort-Objectsp = Set-ItemProperty spps = Stop-Process spsv = Stop-Service sv = Set-Variabletee = Tee-Object where = Where-Object ? = Where-Object write = Write-Output cat = Get-Contentcd = Set-Location clear = Clear-Hostcp = Copy-Itemh = Get-History history = Get-History kill = Stop-Processlp = Out-Printerls = Get-ChildItem mount = New-PSDrive mv = Move-Itempopd = Pop-Location ps = Get-Process pushd = Push-Location pwd = Get-Locationr = Invoke-Historyrm = Remove-Item rmdir = Remove-Item echo = Write-Output cls = Clear-Host chdir = Set-Location copy = Copy-Itemdel = Remove-Itemdir = Get-ChildItem erase = Remove-Item move = Move-Itemrd = Remove-Itemren = Rename-Item set = Set-Variable type = Get-Content#PSDrivealiascertenvfunctionhkcuhklmvariable#获取帮助help get*help *processhelp dirhelp dir -fullhelp dir -detailedhelp dir -exampledir -?#转义序列`0 //空值`a //Beep`b //退格`f //换页`n //新⾏`r //回车`t //制表符`v //垂直引号`` // "`"#数字常量1kb // 10241mb1gb1e3 // 10000xFFFF // 65535#编辑脚本,推荐使⽤PrimalScript的最新版本,⾮常强⼤#设置脚本安全策略set-executionpolicy Restricted #默认set-executionpolicy AllSigned #部署set-executionpolicy RemoteSigned #开发set-executionpolicy Unrestricted #不推荐#执⾏脚本必须带路径./myScript.ps1#获取基于⽤户名和密码的凭据对象$cert = get-credential#对脚本签名$cert = Get-PfxCertificate C:\Test\Mysign.pfxSet-AuthenticodeSignature myScript.ps1 -cert $cert#操作系统gwmi win32_operatingsystem#⾃动变量$Args #传递进函数的参数$_ #通过管道传⼊的对象$input #通过管道传⼊的对象集合$$ #前⼀命令⾏的最后⼀个标记$? #上⼀命令的布尔状态$^ #前⼀命令⾏的第⼀个标记$Matches #使⽤ –match 运算符找到的匹配项的哈希表$Error[0] #前⼀次错误$Home #⽤户的主⽬录$Host #引⽤宿主 POWERSHELL 语⾔的应⽤程序$LastExitCode #上⼀程序或脚本的退出代码$PSHome #Windows PowerShell 的安装位置$profile #标准配置⽂件(可能不存在)$StackTrace #Windows PowerShell 捕获的上⼀异常#类型空类型[void]数值类型[byte] typeof(byte)[decimal] typeof(decimal)[double] typeof(double)[float] typeof(float)[int] typeof(int)[long] typeof(long)[single] typeof(float)字符类型[char] typeof(char)[string] typeof(string)布尔类型[bool] typeof(bool)集合类型[array] typeof(System.Array)typeof(System.Object[])[hashtable] typeof(System.Collections.Hashtable) 其它[psobject] typeof(System.Management.Automation.PSObject)[ref] typeof(System.Management.Automation.PSReference)[regex] typeof(System.Text.RegularExpressions.Regex)[scriptblock] typeof(System.Management.Automation.ScriptBlock)[switch] typeof(System.Management.Automation.SwitchParameter)[type] typeof(System.Type)[wmi] typeof(System.Management.ManagementObject)[wmiclass] typeof(System.Management.ManagementClass)[wmisearcher] typeof(System.Management.ManagementObjectSearcher)[xml] typeof(System.Xml.XmlDocument)example:#[void][void] $var #可以阻⽌$var输出#[xml]$var = [xml] "onetwo3"$var.top$var.top.a$var.top.a = "13"#⾃定义函数function writeln([string] $str) { echo $str }function writeln([string] $str) { Begin {echo "Begin"} Process {echo $str} End {echo "End"} } function writeln { param ([string] $str = $(throw "missing parameter")); echo $str } ${function:writeln} = { param ([string] $str = $(throw "missing parameter")); echo $str }#⽂本⽂件读写${C:\test.txt} = "Hello`r`n"${C:\test.txt} += "-----------------"$Line1 = ${C:\test.txt}[0]# $null$var = $null #删除$vardir > $null$null = dir#Invoke$method = "ToUpper""abc".$method.Invoke()#布尔值$true$false#where, select等的⽤法cd c:\dir | where {$_.Name -eq "WINDOWS"} | select Length,Namedir | ? {$_.Name -eq "WINDOWS"}# 列出字符串对象"str"的所有属性与⽅法"str" | gm#强制类型变量[Boolean] $condition = 0[string] $str = "hello"#数组$array = 1,2,3,4,5,6,7,8$array = @(1,2,3,4,5,6,7,8)$array[-1] #最后⼀个元素$array[0..4]$array[-1..-8] #倒序#哈希表$hash = @{"Name"="Icebird"; "Job"="Engineer"}#如何取得⽂本的⾏数(type C:\test.txt | measure-object).Count#从控制台读取⼀⾏输⼊$var = Read-Host#获取环境变量$path = $env:Path#读取注册表$a = (gp "hklm:\\Software\Microsoft\Windows\CurrentVersion").ProductId #⽐较和运算-like "file.doc" -like "file.*"-notlike-contains 1,2,3 -contains 1-notcontains-----------------------------------eq = (忽略⼤⼩写)-ieq = (忽略⼤⼩写)-ceq = (不忽略⼤⼩写)-ne !=-gt >-lt <-ge >=-le <=以上操作符也可⽤于对数组操作:1,2,3,5,3,2 -lt 3-----------------------------------and-or-not! 等价于-not-xor% 模运算* 可⽤于字符串重复: "-" * 80#位操作-band-bor-bnot-bxor#特殊操作$a = "Hat"$a -replace "a","o"$a -is [string]$a = 1 -as [string]$b = @(1..5)"{0:d}" -f (get-date)"{0:yyyy-MM-dd}" -f (get-date)#格式化$a = 123456789.456789$a.ToString("F4")"{0:F4}" -f $a"{0,-20:F4}{1}" -f $a,0"{0,20:F4}" -f $a"{0:x}" -f 100000"{0:X}" -f 100000#正则表达式$regex = [regex]"He"$str = "Hello, Hello"$isMatch = $str -match $regex$isMatch = $regex.ismatch($str)$matches = $regex.matches($str)#双引号与单引号$a = 1;"$a"会输出1'$a'会输出$a# & 与 ..{$var = 1} #看作include&{$var = 1} #看作call&"dir" #意味着函数名之类的可以当作参数传⼊#foreachforeach ($file in dir) { $ }dir | % { $_.Name }#forfor ($i = 1; $i -lt 5; $i++) {echo $i}#while$i = 0while ($i -lt 4) { $i++; $i }#do...while$i = 10do {$i--; $i} while ($i -lt 5)#do...until$i = 10do {$i--; $i} until ($i -lt 5)#if...else[if]$obj = "Hello"if ($obj -is [string]) { "ISSTRING" }if ($obj -is [string]) { "ISSTRING" } else { "ISNOTSTRING" }if ($obj -is [string]) { "ISSTRING" } elseif ($obj -is [int]) { "ISINTEGER" } #switchswitch (1,2,3) { 1 {"a"} 2 {"b"} 3 {"c"} default {"?"} }switch (1) { "a" {"China"} "b" {"Japan"} "c" {"c"} default {"???"} }#switch -regex$var = "abcdefg"switch -regex($var) {"^\w+$" {echo $_" is a word"}"^\d+$" {echo $_" is a number"}"^\s+$" {echo $_" is a space"}default {echo "?"}}#switch -casesensitive#switch -wildcard#switch -extract ?怎么⽤#switch -file ?怎么⽤#抛出错误&捕获异常throw "Error"raised "Exception"trap{write-host "Error: " $_.Exception.Message#$_.TargetObject#$_.CategoryInfo#$_.FullyQualifiedErrorID#$_.ErrorDetails#$_.InvocationInfocontinue#break#return}#输出格式化Format-ListFormat-TableFormat-WideFormat-Customdir | format-table -groupby Modedir | sort Name -descdir | sort Name -desc | select Name,Length,Mode | export-csv C:\dir.csv dir | sort Name -desc | select Name,Length,Mode | export-clixml C:\dir.csv dir | convertto-html#使⽤.NET的对象$webclient = New-Object .WebClient$webclient.Encoding = [System.Text.Encoding]::UTF8$url = ""$data = [string]$webclient.downloadstring($url)#使⽤COM对象$spVoice = new-object -com "SAPI.spvoice"$spVoice.Speak("Hello, I am Icebird.")。
powershell语法
powershell语法PowerShell是一种命令行shell和脚本语言,专为实现系统管理工作而设计。
它是Windows PowerShell的开源实现,并支持Linux和macOS.1. 变量定义和使用PowerShell中的变量定义方式为:$变量名=值。
变量名以$开头。
$Name = "John" #定义字符串变量$Age = 30 #定义数字变量$Job = "IT Manager" #定义字符串变量使用变量时,可以直接使用变量名。
$Message = "My name is $Name, I am $Age years old, and I work as an $Job."Write-Host $Message #输出结果为:My name is John, I am 30 years old, and I work as an IT Manager.2. 注释PowerShell中的注释使用#符号。
在#后,所有内容都会被视为注释,不会被执行。
#这是单行注释$Age = 30 #这是对变量的解释的单行注释3. 输出PowerShell中的Write-Host命令用于将文本输出到控制台。
使用它来输出变量值或字符串等信息。
Write-Host "Hello, World!"4. 输入PowerShell中的Read-Host命令用于接收来自用户的输入。
$Name = Read-Host "What's your name?"5. 条件语句PowerShell中的if语句用于根据条件执行不同的代码块。
if语句的结构是:if (条件) {代码块} 。
如果条件为真,则执行代码块。
$Age = 30if ($Age -gt 18) {Write-Host "You are an adult."} else {Write-Host "You are a minor."}6. 循环语句PowerShell中的循环语句有foreach循环和while循环。
powershell命令集(有中文说明)
Add-Computer 将本地计算机添加到域或工作组Add-Content 将内容附加到指定的项目或文件Add-History 向会话历史记录追加条目Add-Member 向Windows PowerShell 对象的实例中添加用户定义的自定义成员Add-PSSnapin 将一个或多个Windows PowerShell 管理单元添加到当前会话Add-Type 向Windows PowerShell 会话中添加Microsoft .NET Framework 类型(一种类)Checkpoint-Computer 在本地计算机上创建系统还原点Clear-Content 删除项目的内容,但不删除该项目Clear-EventLog 清除本地或远程计算机上指定事件日志中的所有条目Clear-History 删除命令历史记录中的条目。
Clear-Item 将清除的项的内容,但它不会删除该项目Clear-ItemProperty 清除属性的值但不删除该属性Clear-Variable 删除变量的值Compare-Object 比较两组对象Complete-Transaction 提交活动事务Connect-WSMan 连接到远程计算机上的WinRM 服务ConvertFrom-Csv 将逗号分隔值(CSV) 格式的对象属性转换为原始对象的CSV 版本ConvertFrom-SecureString 将安全字符串转换为加密的标准字符串ConvertFrom-StringData 将包含一个或多个键-值对的字符串转换为哈希表Convert-Path 将路径从Windows PowerShell路径转换为Windows PowerShell提供程序路径ConvertTo-CSV 将Microsoft .NET Framework 对象转换为一系列以逗号分隔的(CSV)、长度可变的字符串ConvertTo-Html 将Microsoft .NET Framework 对象转换为可在Web 浏览器中显示的HTMLConvertTo-SecureString 将加密的标准字符串转换为安全字符串。
exchange powershell常用命令
exchange powershell常用命令Exchange PowerShell常用命令Exchange PowerShell是一种强大的工具,它可以帮助管理员对Exchange服务器进行管理和配置。
本文将介绍一些常用的Exchange PowerShell命令,帮助管理员了解如何使用这些命令来管理Exchange 服务器。
1. 连接到Exchange服务器要使用Exchange PowerShell,首先需要连接到Exchange服务器。
可以使用以下命令创建和管理Exchange会话:powershellcred = Get-Credentialsession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri -Authentication KerberosImport-PSSession session这些命令将提示您输入管理员凭据,并连接到指定的Exchange服务器上的PowerShell会话。
2. 获取和管理邮箱管理用户邮箱是管理员的常见任务之一。
以下是一些常用的Exchange PowerShell命令,可以帮助管理员获取和管理用户邮箱:- 获取邮箱列表:powershellGet-Mailbox这个命令将返回所有的邮箱列表,包括用户邮箱和共享邮箱。
- 创建新邮箱:powershellNew-Mailbox -UserPrincipalName user@domain -Alias user-Name "User Mailbox" -SamAccountName user这个命令将创建一个新的用户邮箱。
- 禁用邮箱:powershellDisable-Mailbox -Identity user@domain 这个命令将禁用指定的邮箱。
- 启用邮箱:powershellEnable-Mailbox -Identity user@domain 这个命令将启用指定的禁用邮箱。
powershell域命令
powershell域命令PowerShell是一种任务自动化和配置管理框架,它提供了一种强大的命令行环境,用于管理Windows操作系统上的各种任务和操作。
在PowerShell中,域命令用于管理和操作域(Domain)和域控制器(Domain Controller)。
下面我将从不同角度介绍一些常见的PowerShell域命令。
1. 获取域信息:`Get-ADDomain`,获取当前域的信息,如域名称、域控制器、域功能级别等。
`Get-ADForest`,获取当前森林(Forest)的信息,包括域和域控制器的详细信息。
2. 管理域用户和组:`Get-ADUser`,获取域中的用户信息,如用户名、邮箱、所属组等。
`New-ADUser`,创建新的域用户。
`Get-ADGroup`,获取域中的组信息,如组名、成员等。
`New-ADGroup`,创建新的域组。
3. 管理域控制器:`Get-ADDomainController`,获取域中的域控制器信息,如名称、IP地址、操作系统版本等。
`Install-ADServiceAccount`,安装域服务帐户。
`Uninstall-ADServiceAccount`,卸载域服务帐户。
4. 管理域策略:`Get-GPResultantSetOfPolicy`,获取应用到指定用户或计算机的组策略结果。
`Set-GPInheritance`,修改组策略继承规则。
`Set-GPPermission`,修改组策略对象的访问权限。
5. 管理域信任关系:`Get-ADTrust`,获取域之间的信任关系信息。
`New-ADTrust`,创建新的域信任关系。
`Remove-ADTrust`,移除域信任关系。
这些命令只是PowerShell中用于域管理的一小部分示例,PowerShell提供了丰富的命令和功能,用于进行更复杂和高级的域管理操作。
你可以通过PowerShell的帮助文档或者在互联网上查找更多相关的命令和用法来深入学习和了解。
powershell命令大全
FunctionProvider提供对WindowsPowerShell中所定义函数的访问。
RegistryProvider提供从WindowsPowerShell中对系统注册表项和注册表值的访问。
VariableProvider提供对WindowsPowerShell变量及其值的访问。
ConvertFrom-SecureStringCmdlet将安全字符串转换为加密的标准字符串。
ConvertTo-SecureStringCmdlet将加密的标准字符串转换为安全字符串。它还可以将纯文本转换为安全字符串。此命令与ConvertFrom-Secu...
Format-ListCmdlet将输出的格式设置为属性列表,其中每个属性均各占一行显示。
New-ServiceCmdlet在注册表和服务数据库中为Windows服务创建新项。
Set-ContentCmdlet在项中写入内容或用新内容替换其中的内容。
Set-ItemPropertyCmdlet设置位于指定位置的属性的值。
Get-AclCmdlet获取资源(例如文件或注册表项)的安全描述符。
Export-AliasCmdlet将当前定义的别名的相关信息导出到文件中。
Invoke-ExpressionCmdlet运行以字符串形式提供的WindowsPowerShell表达式。
Get-AliasCmdlet获取当前会话的别名。
Get-CultureCmdlet获取计算机上区域设置的信息。
Format-CustomCmdlet使用自定义视图来设置输出的格式。
Format-TableCmdlet将输出的格式设置为表。
Format-WideCmdlet将对象的格式设置为只能显示每个对象的一个属性的宽表。
power shell del命令参数
power shell del命令参数- `-Force`:强制删除文件或文件夹,即使它们受到其他进程的锁定或具有只读属性。
- `-Recurse`:递归删除指定目录及其子目录中的所有文件和文件夹。
- `-Include`:指定要包含的文件或文件夹模式。
可以使用通配符来匹配多个文件或文件夹。
- `-Exclude`:指定要排除的文件或文件夹模式。
- `- Confirm`:在删除之前要求用户确认操作。
- `-Verbose`:显示详细的操作信息。
- `-WhatIf`:模拟删除操作,但实际上并不执行删除,只是显示将被删除的文件和文件夹。
例如,要删除指定目录中的所有文件和子目录,可以使用以下命令:```powershelldel -Recurse <directory_path>```要删除具有特定扩展名的文件,可以使用以下命令:```powershelldel -Include "*.ext" <directory_path>```其中,`<directory_path>` 是要操作的目录路径,`*.ext` 是要删除的文件的扩展名模式。
需要注意的是,`del` 命令删除的文件或文件夹将无法恢复,因此在使用时要谨慎。
在执行删除操作之前,建议先检查和确认要删除的文件或文件夹,以避免意外删除重要的文件。
此外,PowerShell 还提供了其他与文件和文件夹操作相关的命令,如 `Remove-Item`、`Get-ChildItem` 等,它们提供了更丰富的功能和选项,可以根据具体需求选择使用。
希望以上内容对你有所帮助。
如果你还有其他问题或需要进一步的解释,请随时提问。
PowerShell使用教程
PowerShell使⽤教程1、打开powershell 不说了2、获取帮助: get-help (所有命令都是cmdlet格式,help也不例外)3、查看有哪些命令: get-command (可看到命令类型有:Alias别名、Cmdlet命令、Function函数)4、查看以 get开头的命令: get-command get-*5、查看get-process命令的⽤法: get-help get-process6、⽤get-process查找进程notepad :get-process -name *notepad* (当前,你得先打开⼀个记事本notepad.exe)7、获取stop-process在线帮助: get-help stop-process -Online8、⽤stop-process杀除进程notepad:Stop-Process -Name "notepad"想想还能⼲什么9、下载⽂件$webRequest = [.HttpWebRequest]::Create("/fwlink/?LinkID=149156")$webRequest.Method = "GET";$erAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"$response = $webRequest.GetResponse()$stream = $response.GetResponseStream()$reader = New-Object System.IO.BinaryReader($stream)$bytes = New-Object System.Byte[] $response.ContentLengthfor ($read = 0; $read -ne $bytes.Length; $read += $reader.Read($bytes,$read,$bytes.Length - $read) ){ }[System.IO.File]::WriteAllBytes("c:tempSilverLight.exe",$bytes);将上述代码copy到powershell 后,下载到哪⼉了?执⾏pwd 显⽰c:\users\⽤户名到这个⽬录下找到了tempSilverLight.exe (原来在原代码中c:少了\,但容错能⼒很强,呵呵)10、下载并安装MICROSOFT® REPORT VIEWER 2015 RUNTIME#添加程序集Add-Type -AssemblyName System.IOAdd-Type -AssemblyName pressionAdd-Type -AssemblyName pression.FileSystem#下载地址$DownloadUrl = "https:///download/A/1/2/A129F694-233C-4C7C-860F-F73139CF2E01/ENU/x86/ReportViewer.msi"#下载到Temp⽬录$TempPath = $env:TEMP#下载的⽂件名$FileName = "ReportViewer.msi"#存储的完整⽂件路径$FullPath = "$TempPath\$FileName"#Download$client = New-Object .WebClient"Now is downloading MICROSOFT® REPORT VIEWER 2015 RUNTIME"$client.DownloadFile($DownloadUrl, $FullPath)"Download success"#Installmsiexec.exe /i $FullPath /qr"Press any key to exit"Read-Host11、卸载MICROSOFT® REPORT VIEWER 2015 RUNTIMEmsiexec.exe /x "{3ECE8FC7-7020-4756-A71C-C345D4725B77}" /qr可以指定msi安装包,也可以指定ProductCode,可以访问从注册表以下位置查找ProductCode。
powershell命令教程
powershell命令教程 1启动 powershell23#字符串操作4对象操作"hello".Length567#进程操作8 PS C:\> notepad9 PS C:\> $process=get-process notepad10 PS C:\> $process.Kill()111213#默认对象操作14 PS C:\> 40GB/650MB15 63.01538461538461617#时间操作18 PS C:\> [DateTime]"2009-12-5" - [DateTime]::Now19 Days : -5820 Hours : -1421 Minutes : -5322 Seconds : -5823 Milliseconds : -51024 Ticks : -5064838510531425 TotalDays : -58.620816094113426 TotalHours : -1406.8995862587227 TotalMinutes : -84413.975175523328 TotalSeconds : -5064838.510531429 TotalMilliseconds : -5064838510.53143031#时间对象操作32 PS C:\> $result = [DateTime]"2009-12-5" - [DateTime]::Now33 PS C:\> $result.TotalDays34 -58.6213450248299353637#查询今天星期⼏38 PS C:\Users\vv> $date=Get-Date39 PS C:\Users\vv> $date.DayOfWeek40Monday414243#查找powershell命令中包含单词process的命令44 PS C:\> Get-Command *process*45CommandType Name Definition46 ----------- ---- ----------47 Application api-ms-win-core-processenvir... C:\Windows\system32\api-ms-w...48 Application api-ms-win-core-processthrea... C:\Windows\system32\api-ms-w...49 Cmdlet Debug-Process Debug-Process [-Name] <Strin...50 Cmdlet Get-Process Get-Process [[-Name] <String...51 Application microsoft-windows-kernel-pro... C:\Windows\system32\microsof...52Application qprocess.exe C:\Windows\system32\qprocess...53 Cmdlet Start-Process Start-Process [-FilePath] <S...54 Cmdlet Stop-Process Stop-Process [-Id] <Int32[]>...55 Cmdlet Wait-Process Wait-Process [-Name] <String...565758#检索donet中对象的属性和⽅法59 PS C:\> "aaa" | Get-Member6061 TypeName: System.String6263Name MemberType Definition64 ---- ---------- ----------65Clone Method System.Object Clone()66CompareTo Method int CompareTo(System.Object value), i...67Contains Method bool Contains(string value)68CopyTo Method System.Void CopyTo(int sourceIndex, c...69 EndsWith Method bool EndsWith(string value), bool End...70Equals Method bool Equals(System.Object obj), bool ...71GetEnumerator Method System.CharEnumerator GetEnumerator()72GetHashCode Method int GetHashCode()73GetType Method type GetType()74GetTypeCode Method System.TypeCode GetTypeCode()75IndexOf Method int IndexOf(char value), int IndexOf(...76IndexOfAny Method int IndexOfAny(char[] anyOf), int Ind...77Insert Method string Insert(int startIndex, string ...78IsNormalized Method bool IsNormalized(), bool IsNormalize...79LastIndexOf Method int LastIndexOf(char value), int Last...80LastIndexOfAny Method int LastIndexOfAny(char[] anyOf), int...81...828384#统计所有正在运⾏的进程的句柄数85 PS C:\> $handleCount=086 PS C:\> foreach($process in Get-process) { $handleCount +=$process.Handles }87 PS C:\> $handleCount88 233188990#直接调⽤donet对象,获取⽹页内容91 PS C:\> $webClient = New-Object .WebClient92 PS C:\> $content = $webClient.DownloadString("")93 PS C:\> $content.Substring(0,1000)94 <html><head><meta http-equiv=Content-Type content="text/html;charset=gb2312"><t95 itle>百度⼀下,你就知道 </title><style>body{margin:4px 0}p{margin:0;paddin96 g:0}img{border:0}td,p,#u{font-size:12px}#b,#u,#l td,a{font-family:arial}#kw{fon97 t:16px Verdana;height:1.78em;padding-top:2px}#b{height:30px;padding-top:4px}#b, 98#b a{color:#77c}#u{padding-right:10px;line-height:19px;text-align:right;margin:99 0 0 3px !important;margin:0 0 10px}#sb{height:2em;width:5.6em}#km{height:50px}# 100 l{margin:0 0 5px 38px}#l td{padding-left:107px}p,table{width:650px;border:0}#l101 td,#sb,#km{font-size:14px}#l a,#l b{margin-right:1.14em}a{color:#00c}a:active{c102 olor:#f60}#hp{position:absolute;margin-left:6px}#lg{margin:-26px 0 -44px}#lk{wi103 dth:auto;line-height:18px;vertical-align:top}form{position:relative;z-index:9}<104 /style></head>105 <body><div id=u><a href=/?login&tpl=mn>登录</a></div>< 106 center><img src=/img/baidu_logo.gif width=270 height=129 us 107 emap="#mp" id=lg><br><br><br><br><table cellpadd108109110#获取系统信息111 PS C:\> Get-WmiObject Win32_Bios112113SMBIOSBIOSVersion : 2TKT00AUS114Manufacturer : LENOVO115 Name : Default System BIOS116 SerialNumber : 1111111117 Version : LENOVO - 5000821118119120#导航⽂件系统121 PS C:\> Set-Location c:\122 PS C:\> Get-ChildItem123124125⽬录: C:\126127128Mode LastWriteTime Length Name129 ---- ------------- ------ ----130 d---- 2010/1/7 14:20 bea131 d---- 2010/1/7 14:20 BEA WebLogic E-Business Platform132 d---- 2009/12/7 13:02 dzh133 d---- 2010/1/2 15:48 his134 d---- 2009/7/14 10:37 PerfLogs135 d-r-- 2010/1/25 12:58 Program Files136 d-r-- 2009/12/31 19:11 Users137 d---- 2009/11/7 9:52 usr138 d---- 2010/1/28 3:16 Windows139 -a--- 2009/6/11 5:42 24 autoexec.bat140 -a--- 2009/6/11 5:42 10 config.sys141 -a--- 2009/10/28 13:37 454656 putty.exe142143144#导航注册表145 PS C:\> Set-Location HKCU:\Software\Microsoft\Windows\146 PS HKCU:\Software\Microsoft\Windows\> Get-ChildItem147148149 Hive: HKEY_CURRENT_USER\Software\Microsoft\Windows150151152SKC VC Name Property153 --- -- ---- --------154 33 0 CurrentVersion {}155 0 11 DWM {Composition, CompositionPolicy, Colo...156 3 0 Shell {}157 1 0 ShellNoRoam {}158 2 0 TabletPC {}159 3 12 Windows Error Reporting {ConfigureArchive, DisableArchive, Di...160161162#导航证书163 PS C:\Users\vv> Set-Location cert:\CurrentUser\Root164 PS cert:\CurrentUser\Root> Get-ChildItem165166167⽬录: Microsoft.PowerShell.Security\Certificate::CurrentUser\Root168169170Thumbprint Subject171 ---------- -------172 CDD4EEAE6000AC7F40C3802C171E30148030C072 CN=Microsoft Root Certificate Auth...173 BE36A4562FB2EE05DBB3D32323ADF445084ED656 CN=Thawte Timestamping CA, OU=Thaw... 174 A7217F919843199C958C128449DD52D2723B0A8A CN= Corporation Root CA... 175 A43489159A520F0D93D032CCAF37E7FE20A8B419 CN=Microsoft Root Authority, OU=Mi...176 7F88CD7223F3C813818C994614A89C99FA3B5247 CN=Microsoft Authenticode(tm) Root...177 742C3192E607E424EB4549542BE1BBC53E6174E2 OU=Class 3 Public Primary Certific...178 654E9FADD2032AE1B87D6263AF04FD7FEE38D57C CN=iTruschina CN Root CA-3, OU=Chi... 179 46F168AF009C28C18F452EB85F5E8747892B3C8B CN=iTruschina CN Root CA-2, OU=Chi... 180 245C97DF7514E7CF2DF8BE72AE957B9E04741E85 OU=Copyright (c) 1997 Microsoft Co...181 240A61A2577970625B9F0B81283C4AA4037217B1 CN=iTruschina CN Root CA-1, OU=Chi... 182 18F7C1FCC3090203FD5BAA2F861A754976C8DD25 OU="NO LIABILITY ACCEPTED, (c)97 V (183)184185#显⽰所有进程186PS C:\Users\vv> Get-Process187188Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName189------- ------ ----- ----- ----- ------ -- -----------190 527 28 40784 44864 243 18.94 4956 360SE191 537 29 49144 59340 248 9.09 5276 360SE192 924 20 17580 2504 132 3768 360tray193 160 5 16080 7852 41 2036 audiodg194 318 24 6524 7008 124 188 CCProxy195 56 5 796 288 33 1232 CNAB4RPK196 61 4 1568 6916 63 0.19 5064 conhost197 60 4 1532 3628 63 0.06 5584 conhost198 645 6 2076 1204 72 380 csrss199 649 9 8148 11056 185 440 csrss200......201202203#搜索所有包含Get动词的命令204PS C:\Users\vv> Get-Command -Verb Get205206CommandType Name Definition207----------- ---- ----------208Cmdlet Get-Acl Get-Acl [[-Path] <String[]>]...209Cmdlet Get-Alias Get-Alias [[-Name] <String[]...210Cmdlet Get-AuthenticodeSignature Get-AuthenticodeSignature [-...211Cmdlet Get-ChildItem Get-ChildItem [[-Path] <Stri...212Cmdlet Get-Command Get-Command [[-ArgumentList]...213Cmdlet Get-ComputerRestorePoint Get-ComputerRestorePoint [[-... 214......215216217#帮助218PS C:\Users\vv> Get-Help Get-Verb -Full/-Detailed/-Examples219220221#调⽤powershell脚本222PowerShell "& 'C:\get-report.ps1' arguments"223224225#循环226PS C:\Users\vv> 1..10 | % {"aaa"}227aaa228aaa229aaa230aaa231aaa232aaa233aaa234aaa235aaa236aaa237238239#数据加密(Base64)240PS C:\Users\vv> $bytes=[System.Text.Encoding]::Unicode.GetBytes("aaa") 241PS C:\Users\vv> $encodedString=[Convert]::ToBase64String($bytes)242PS C:\Users\vv> $encodedString243YQBhAGEA244245246#检查命令是否执⾏成功247PS C:\Users\vv> $lastExitCode2480249PS C:\Users\vv> $?250True251252253#性能测试,计算⼀个命令执⾏的时间254PS C:\Users\vv> Measure-Command { Start-Sleep -Milliseconds 337 }255Days : 0256Hours : 0257Minutes : 0258Seconds : 0259Milliseconds : 340260Ticks : 3404713261TotalDays : 3.9406400462963E-06262TotalHours : 9.45753611111111E-05263TotalMinutes : 0.00567452166666667264TotalSeconds : 0.3404713265TotalMilliseconds : 340.4713266267268#foreach 循环269foreach($alias in Get-Alias){270 $alias271}272273274#显⽰为表格275PS C:\Users\vv> Get-Process | Format-Table Name,WS -Auto276277278#复制⽂件279Copy-Item c:\temp\*.txt c:\temp\backup\ -verbose280281282#列出所有已经停⽌的服务283PS C:\Users\vv> Get-Service | Where-Object { $_.Status -eq "Stopped" }284#列出当前位置的所有⼦⽬录285PS C:\Users\vv> Get-ChildItem | Where-Object { $_.PsIsContainer }286287288#循环289PS C:\Users\vv> 1..10 | Foreach-Object { $_ * 2 }290291292#获取正在运⾏的记事本程序的进程列表,然后等待他们退出293PS C:\Users\vv> $notepadProcesses = Get-Process notepad294PS C:\Users\vv> $notepadProcesses | Foreach-Object { $_.WaitForExit() }295296#其它循环关键字297for foreach do while298299300#从管道中选择接收值301PS C:\Users\vv> dir | Select Name302303304#释放变量占⽤的内存空间305$processes = $null306307308#显⽰所有变量309PS C:\> dir variable:\310311PS C:\> dir variable:\s*312313#显⽰⽂件内容314PS C:\> ${c:\autoexec.bat}315316#变量范围317$Global:myVariable1 = value1318$Script:myVariable2 = value2319$Local:myVariable3 = value3320321322#静态⽅法调⽤ donet323PS C:\> [System.Diagnostics.Process]::GetProcessById(0)324325Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName326------- ------ ----- ----- ----- ------ -- -----------327 0 0 0 24 0 0 Idle328329330Get-Process Notepad331#Get-Process 代替 System.Diagnostics.Process332333$process.WaitForExit() #暂停直到结束334335Get-Date 等同于 [System.DateTime]::Now336337#创建对象338PS C:\> $generator = New-Object System.Random339PS C:\> $generator.NextDouble()3400.121309703738107341342PS C:\> (New-Object Net.WebClient).DownloadString("")343344#先加载库⽂件345PS C:\> [Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")346GAC Version Location347--- ------- --------348True v2.0.50727 C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.... 349#创建后保存350PS C:\> $image = New-Object System.Drawing.Bitmap source.gif351PS C:\> $image.Save("source_1.jpg","JPEG")352353354PS C:\> [Reflection.Assembly]::LoadWithPartialName("System.Web")355GAC Version Location356--- ------- --------357True v2.0.50727 C:\Windows\assembly\GAC_32\System.Web\2.0.0.0__b03f5f7...358359PS C:\> [Web.HttpUtility]::UrlEncode("")360http%3a%2f%361362363#缩短类名364PS C:\> $math=[System.Math]365PS C:\> $math::Min(1,10)3661367368#调⽤COM组件369$sapi = New-Object -Com Sapi.SpVoice370$sapi.rate=0371$sapi.Speak("⼀直以为...只要隐着⾝,就没有美⼥认得出我是帅哥!但是...我错了,像我这样拉风的男⼈,就好⽐那暗夜⾥的萤⽕⾍,⽥地⾥的⾦龟⼦,是那样的鲜372373374#获取对象类型375$date = Get-Date376$date.GetType().ToString()377378379#正则表达式匹配380PS C:\Users\vv> "Hello World" -match "Hello"381True382383#条件运算符384PS C:\Users\vv> $data = "Hello World"385($data -like "*llo w*") -and ($data.Length -gt 10)386True387388#逻辑运算关键字389-eq -ne -ge -lt -le -like -notlike -match -notmatch -contains -notcontains -is isnot390391392#条件语句393if elseif else394395$a=20396switch($a)397{398 {$_ -lt 32} {"aaaa";break}399 32 {"bbb";break}400 default {"ccc"}401}402403#循环404#for foreach while do foreach-object405foreach($file in dir){406"File length:"+$file.Length407}408409#暂停或延迟410Read-Host "Press ENTER"411Start-Sleep 2412Start-Sleep -Milliseconds 300413414415#字符串使⽤单引号表⽰原⽣字符串,不⽀持变量扩展或转义字符416$myString = 'Hello World'417418#多⾏字符串419$myString = @"420This is the first line,421This is the second line.422"@423424#多⾏注释425##This is a regular comment426$null=@"427function MyTest{428"aaaaaaaaaaaa"429}430"@431#变量$null告诉PowerShell不必为后续的使⽤⽽继续保留信息了432433#转义字符 ` (不使⽤反斜杠)434PS C:\Users\vv> $myString = "Report for today `n---------"435$myString436Report for today437---------438439#字符串变量440PS C:\Users\vv> $header = "Report for today"441$myString = "$header `n$('-'*$header.Length)"442$myString443444Report for today445----------------446447#格式化输出右对齐8个字符,格式为4为数字,:C表⽰货币形式 -f String.Format() 448PS C:\Users\vv> $formatString = "{0,8:D4} {1:C}`n"449$report = "Quantity Price`n"450$report += "--------------`n"451$report += $formatString -f 50,2.5677452$report += $formatString -f 3,7453$report454Quantity Price455--------------456 0050 ¥2.57457 0003 ¥7.00458459#字符串⽅法460PS C:\Users\vv> "abc".IndexOf("b")4611462463PS C:\Users\vv> "abc".Contains("b")464True465466#$helpContent 得到的是⼀个对像,⽽不是字符串467$helpContent = Get-Help Get-ChildItem468$helpContent -match "location"469False470471$472Get-ChildItem473474#得到字符串使⽤下⾯的⽅式475$helpContent = Get-Help Get-ChildItem | Out-String476$helpContent -match "location"477True478479"Hello World".Replace("World","PowerShell")480Hello PowerShell481482#replace ⾼级⽤法483"Hello World" -replace '(.*) (.*)','$2 $1'484World Hello485486"Hello World".ToUpper()487HELLO WORLD488"Hello World".ToLower()489hello world490491#⾸字符⼤写492$text = "hello"493$newText = $text.Substring(0,1).ToUpper()+$text.Substring(1)494495"Hello World".Trim()496497#从字符串尾部取出字符498"Hello World".TrimEnd('w','d',' ');499500#格式化⽇期501$date = [DateTime]::now502$date.ToString("dd-MM-yyyy")503504#⽇期⽐较505$dueDate = [DateTime] "01/01/2008"506if([DateTime]::Now -gt $dueDate)507{508"Account is now due"509}510511512#字符串合并⽤ append513Measure-Command{514 $output = New-Object Text.StringBuilder515 1..10000 |516 Foreach-Object { $output.Append("Hello World") } 517}518Days : 0519Hours : 0520Minutes : 0521Seconds : 1522Milliseconds : 696523Ticks : 16965372524TotalDays : 1.96358472222222E-05525TotalHours : 0.000471260333333333526TotalMinutes : 0.02827562527TotalSeconds : 1.6965372528TotalMilliseconds : 1696.5372529530Measure-Command{531 $output =""532 1..10000 |533 Foreach-Object { $output+="Hello World" } 534}535Days : 0536Hours : 0537Minutes : 0538Seconds : 5539Milliseconds : 453540Ticks : 54531118541TotalDays : 6.31147199074074E-05542TotalHours : 0.00151475327777778543TotalMinutes : 0.0908851966666667544TotalSeconds : 5.4531118545TotalMilliseconds : 5453.1118546547548#数学计算549$result = [int](3/2)550$result5512552553#截断554$result=3/2555[Math]::Truncate($result)5561557558function trunc($number){559 [Math]::Truncate($number)560}561$result=3/2562trunc $result5631564565[Math]::Abs(-10.6)566[Math]::Pow(123,2)567[Math]::Sqrt(100)568[Math]::Sin([Math]::PI /2)569[Math]::ASin(1)570571#⽴⽅根572function root($number,$root){ [Math]::Exp($([Math]::Log($number)/$root))} 573root 64 35744575576#统计5771..10 | Measure-Object -Average -Sum578579Count : 10580Average : 5.5581Sum : 55582Maximum :583Minimum :584Property :585586Get-ChildItem > output.txt587Get-COntent output.txt | Measure-Object -Character -Word -Line588589 Lines Words Characters Property 590 ----- ----- ---------- --------591 28 117 2638592593#从⽂件列表中取得LastWriteTime的平均值594$times = dir | Foreach-Object { $_.LastWriteTime }595$results = $times | Measure-Object Ticks -Average596New-Object DateTime $results.Average5975982009年12⽉11⽇ 21:27:09599600601#16进制数602$hexNumber = 0x1234603$hexNumber6044660605606#16进制转 2进制607[Convert]::ToString(12341,2)60811000000110101609610#2进制转10进制611[Convert]::ToInt32("11000000110101",2)61212341613614#修改⽂件属性,并查询615$archive = [System.IO.FileAttributes] "Archive"616attrib +a test.txt617Get-ChildItem | Where { $_.Attributes -band $archive } | Select Name618619620#⽂件加密621(Get-Item output.txt).Encrypt()622#⽂件解密623(Get-Item output.txt).Decrypt()624625#设置⽂件属性626(Get-Item output.txt).IsReadOnly627True628(Get-Item output.txt).IsReadOnly = $false629(Get-Item output.txt).IsReadOnly630False631632633#枚举⽂件可能的属性634[Enum]::GetNames([System.IO.FileAttributes])635ReadOnly636Hidden637System638Directory639Archive640Device641Normal642Temporary643SparseFile644ReparsePoint645Compressed646Offline647NotContentIndexed648Encrypted649650651[int] (Get-Item output.txt).Attributes65232653654#⽂件属性的表⽰形式655$attributes = [Enum]::GetValues([System.IO.FileAttributes])656$attributes | Select-Object `657 @{"Name"="Property";"Expression"={ $_ }},658 @{"Name"="Integer";"Expression"={ [int]$_ }},659 @{"Name"="Hexadecimal";"Expression"={ [Convert]::ToString([int] $_,16)}}, 660 @{"Name"="Binary";"Expression"={ [Convert]::ToString([int] $_,2)}} |661 Format-Table -auto662663 Property Integer Hexadecimal Binary664 -------- ------- ----------- ------665 ReadOnly 1 1 1666 Hidden 2 2 10667 System 4 4 100668 Directory 16 10 10000669 Archive 32 20 100000670 Device 64 40 1000000671 Normal 128 80 10000000672 Temporary 256 100 100000000673 SparseFile 512 200 1000000000674 ReparsePoint 1024 400 10000000000675 Compressed 2048 800 100000000000676 Offline 4096 1000 1000000000000677NotContentIndexed 8192 2000 10000000000000678 Encrypted 16384 4000 100000000000000679680681#判断⽂件属性682$encrypted=16384683$attributes = (Get-Item output.txt -force).Attributes684($attributes -band $encrypted) -eq $encrypted685False686687688#读取⽂件内容689$content = Get-Content c:\file.txt690$content = ${c:\file.txt}691$content = [System.IO.File]::ReadAllText("c:\file.txt")692693#搜索⽂件⽂本694Select-String -Simple "aaa" file.txt695Select-String "\(...\) ...-..." phone.txt696697Get-ChildItem -Filter *.txt -Recurse | Select-String pattern698699700#获取被补丁修改的⽂件列表701cd $env:WINDIR702$parseExpression = "(.*): Destination:(.*) \((.*)\)"703$files = dir kb*.log -Exclude *uninst.log704$logContent = $files | Get-Content | Select-String $parseExpression705$logContent706707#移动⽂件,删除⽂件708$filename = [System.IO.Path]::GetTempFileName()709$newname = [System.IO.Path]::ChangeExtension($filename,".cs")710Move-Item $filename $newname711Remove-Item $newname712713714#内容写⼊到⽂件715$filename = "output.txt"716$content = Get-Content $filename717$content = "hellohello"718$content | Set-Content $filename719720721#xml⽂件722$xml = [xml] (Get-Content powershell_blog.xml)723$xml.rss724($xml.rss.channel.item).Count725($xml.rss.channel.item)[0].title726$xml.rss.channel.item | Sort-Object title | Select-Object title727728#XPath查询729#查询所有少于20个字符的标题730$xml = [xml] (Get-Content powershell_blog.xml)731$query = "/rss/chanel/item[string-length(title) < 20]/title"732$xml.SelectNodes($query)733734#修改xml735$filename = (Get-Item phone.xml).FullName736Get-Content $fileName737$phoneBook = [xml](Get-Content $fileName)738$person = $phoneBook.AddressBook.Person[0]739$person.Phone[0]."#text" = "555-1214"740$person.Phone[0].type="mobile"741$newNumber = [xml]'<Phone type="home">555-1215</Phone>'742$newNode = $phoneBook.ImportNode($newNumber.Phone,$true) 743 [void] $person.AppendChild($newNode)744$phoneBook.save($filename)745 Get-Content $filename746747748749#Internet 脚本750#下载⼀个⽂件 (参数错误?)751$source = "/images/0809/logo1.png"752$destination = "c:\logo1.png"753$wc = New-Object .WebClient754$wc.DownloadFile($source,$destination)755756#下载⼀个Web页⾯757$source = "/powershell/rss.xml"758$wc = New-Object .WebClient759$content = $wc.DownloadString($source)760761#输出格式为Html 创建⼀个PowerShell命令的概要762$filename = "c:\PowerShell.html"763$commands = Get-Command | Where { $_.CommandType -ne"Alias" } 764$summary = $commands | Get-Help | Select Name,Synopsis765$summary | ConvertTo-Html | Set-Content $filename766767#脚本块768function MultiplyInpuByTwo769{770process771 {772$_ * 2773 }774}775776 1,2,3 | MultiplyInpuByTwo777 2778 4779 6780781#从脚本块返回数据782function GetDate783{784 Get-Date785}786$tomorrow = (GetDate).AddDays(1)787788789790791792#数组793$myArray = 1,2,"aaa"794$myArray795 1796 2797aaa798799#数组基本操作800$collection = New-Object System.Collections.ArrayList801$collection.Add("Hello")802 [void]$collection.Add("Hello")803 [void]$collection.AddRange{("a","b")}804$collection.RemoveAt(1)805806$myArray = New-Object string[] 10807$myArray[5]="bbb"808809810$myArray = Get-Process811$myArray812813Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName 814 ------- ------ ----- ----- ----- ------ -- -----------815 851 38 69204 101888 338 137.36 5012 360SE816 532 30 42192 42316 271 54.19 5864 360SE817 965 19 17784 2192 132 3768 360tray818 134 5 15516 12864 41 3612 audiodg819 314 21 6796 5228 127 188 CCProxy820 56 5 796 304 33 1232 CNAB4RPK821 61 4 1532 1312 63 0.09 5436 conhost822......823824825$myArray = @(Get-Process Explorer)826$myArray827828Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName 829 ------- ------ ----- ----- ----- ------ -- -----------830 1085 42 52080 98140 300 164.77 2256 explorer831832833834$a = @(835 (1,2,3,4),836 (5,6,7,8)837)838$a[0][1]839 2840841$myArray = 1,2,3842$myArray[1..3 + 0]843 2844 3845 1846847#访问数组中的每⼀个元素848$myArray = 1,2,3849$sum = 0850$myArray | Foreach-Object {$sum+=$_}851$sum852 6853854#访问数组中的每⼀个元素,更脚本化855$myArray = 1,2,3856$sum=0857foreach($element in$myArray){$sum+=$element}858$sum859 6860861#数组列表排序862 Get-ChildItem | Sort-Object -Descending Length | Select Name, Length 863864#检查数组列表是否包含指定的项865"Hello","World"-contains"Hello"866867#合并数组868$array = 1,2869$array += 3,4870871#数组查询872$array = "Item1","Item2","Item3","Item4","Item15"873$array-eq"Item1"#Item1874$array-like"*2*"#Item2875$array-match"Item.."#Item15876$array-ne"Item1"#Item2 Item3 Item4 Item15877$array-notlike"*1*"#Item2 Item3 Item4878$array-notmatch"Item.."#Item1 Item2 Item3 Item4879880881#哈希表 ,哈希表不保存顺序,可⽤ Sort 排序882$myHashtable = @{}883$myHashtable = @{key1="value1";key2=1,2,3}884$myHashtable["NewItem"]=5885foreach($item in$myHashtable.GetEnumerator() | Sort Name)886{887$item.value888}889890891#参数892function Reverse893{894$srgsEnd = $args.Length - 1895$args[$srgsEnd..0]896}897 Reverse 1,2,3,4898899900#⽤户交互901#读取⽤户输⼊⼀⾏902$directory = Read-Host "Enter a directory name:"903$directory904905#读取⽤户输⼊的键906$key = [Console]::ReadKey($true)907$key908909$key = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")910911#环境变量912913#查看914$env:username915916#完整⽅式917 Get-Content Env:\Username918919920#查看所有变量921dir env:922923Name Value924 ---- -----925ALLUSERSPROFILE C:\ProgramData926 ANT_HOME D:\J2EE\apache-ant-1.7.0927APPDATA C:\Users\vv\AppData\Roaming928 CLASSPATH .\;D:\Design\J2EE\jdk1.6.0_10\lib\tools.jar 929CommonProgramFiles C:\Program Files\Common Files 930 COMPUTERNAME VV-PC931ComSpec C:\Windows\system32\cmd.exe932FP_NO_HOST_CHECK NO933HOMEDRIVE C:934HOMEPATH \Users\vv935 JAVA_HOME D:\Design\J2EE\jdk1.6.0_10936......937938#设置环境变量(永久)939$oldPersonalPath = ";d:\tools"940 [Environment]::SetEnvironmentVariable("Path",$oldPersonalPath,"User")941 [Environment]::GetEnvironmentVariable("Path","User") #;d:\tools942943944#阅读 rss945$sapi = New-Object -Com Sapi.SpVoice946$WebClient = New-Object .WebClient947$WebClient.Encoding=[System.Text.Encoding]::UTF8948$rss = [XML]($WebClient.DownloadString("/zixun/rss_fyzx.xml")) 949foreach($item in$rss.rss.channel.Item){950$title = $item.title951#$title = $item.title.InnerText952$content = $item.description953#$content = $item.description.InnerText954#$content = $item.description.InnerText.Replace(" ","")955$title956$sapi.Speak($title+"。
PowerShell:Content相关命令
PowerShell:Content相关命令PowerShell下的Content相关命令如下:Get-Content: 读取文件中的内容Add-Content: 向文件中写入内容Set-Content: 向文件中写入内容或替换文件中已经存在的内容Clear-Content: 删除或清空文件的内容add-content命令,主要是向文件中添加内容•主要参数有两个,-path用来指定路径,-value用来指定要添加的内容,暂时只知道这两个参数。
举例如下•add-content -path *.txt -exclude help* -value "END"•这个命令是向在当前目录的所有txt文件添加"END"这个内容,但是以help开关的txt文件除外,用来排除不符合要求的文件•add-content -Path file1.log, file2.log -Value (get-date) -passthru•这个命令是向fiel1.log和file2.log文件中添加日期,日期对象通过这个命令获取,•add-content -path monthly.txt -value (get-content c:\rec1\weekly.txt)•这个命令是把当前目录的weekly的内容加入到monthly.txt这个文件中,是从末尾开始插入,而不是覆盖. 是获取文件内容的命令,加括号的作用是保证在执行的时候,已经执行完毕•add-content -value (get-content test.log) -path C:\tests\test134\logs\test134.log•这个命令的作用是先获取文件的内容,再把这个内容完全得到一个新文件中,可以不存在,命令会创建这个文件。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
CommandType Name Definition-------------------------Alias%ForEach-ObjectAlias?Where-ObjectFunction A:Set-Location A:Alias ac Add-ContentCmdlet Add-Computer Add-Computer [-DomainName] <... Cmdlet Add-Content Add-Content [-Path] <String[... Cmdlet Add-History Add-History [[-InputObject] ... Cmdlet Add-Member Add-Member [-MemberType] <PS... Cmdlet Add-PSSnapin Add-PSSnapin [-Name] <String... Cmdlet Add-Type Add-Type [-TypeDefinition] <... Alias asnp Add-PSSnapInFunction B:Set-Location B:Function C:Set-Location C:Alias cat Get-ContentAlias cd Set-LocationFunction cd..Set-Location ..Function cd\Set-Location \Alias chdir Set-LocationCmdlet Checkpoint-Computer Checkpoint-Computer [-Descri... Alias clc Clear-ContentAlias clear Clear-HostCmdlet Clear-Content Clear-Content [-Path] <Strin... Cmdlet Clear-EventLog Clear-EventLog [-LogName] <S... Cmdlet Clear-History Clear-History [[-Id] <Int32[... Function Clear-Host$space = New-Object System.M... Cmdlet Clear-Item Clear-Item [-Path] <String[]... Cmdlet Clear-ItemProperty Clear-ItemProperty [-Path] <... Cmdlet Clear-Variable Clear-Variable [-Name] <Stri... Alias clhy Clear-HistoryAlias cli Clear-ItemAlias clp Clear-ItemPropertyAlias cls Clear-HostAlias clv Clear-VariableAlias compare Compare-ObjectCmdlet Compare-Object Compare-Object [-ReferenceOb... Cmdlet Complete-Transaction Complete-Transaction [-Verbo... Cmdlet Connect-WSMan Connect-WSMan [[-ComputerNam... Cmdlet ConvertFrom-Csv ConvertFrom-Csv [-InputObjec... Cmdlet ConvertFrom-SecureString ConvertFrom-SecureString [-S... Cmdlet ConvertFrom-StringData ConvertFrom-StringData [-Str... Cmdlet Convert-Path Convert-Path [-Path] <String... Cmdlet ConvertTo-Csv ConvertTo-Csv [-InputObject]... Cmdlet ConvertTo-Html ConvertTo-Html [[-Property] ... Cmdlet ConvertTo-SecureString ConvertTo-SecureString [-Str... Cmdlet ConvertTo-Xml ConvertTo-Xml [-InputObject]... Alias copy Copy-ItemCmdlet Copy-Item Copy-Item [-Path] <String[]>... Cmdlet Copy-ItemProperty Copy-ItemProperty [-Path] <S... Alias cp Copy-ItemAlias cpi Copy-ItemAlias cpp Copy-ItemPropertyAlias cvpa Convert-PathFunction D:Set-Location D:Alias dbp Disable-PSBreakpointCmdlet Debug-Process Debug-Process [-Name] <Strin... Alias del Remove-ItemAlias diff Compare-ObjectAlias dir Get-ChildItemCmdlet Disable-ComputerRestore Disable-ComputerRestore [-Dr... Cmdlet Disable-PSBreakpoint Disable-PSBreakpoint [-Break... Function Disable-PSRemoting...Cmdlet Disable-PSSessionConfiguration Disable-PSSessionConfigurati... Cmdlet Disable-WSManCredSSP Disable-WSManCredSSP [-Role]... Cmdlet Disconnect-WSMan Disconnect-WSMan [[-Computer... Function E:Set-Location E:Alias ebp Enable-PSBreakpointAlias echo Write-OutputCmdlet Enable-ComputerRestore Enable-ComputerRestore [-Dri... Cmdlet Enable-PSBreakpoint Enable-PSBreakpoint [-Id] <I... Cmdlet Enable-PSRemoting Enable-PSRemoting [-Force] [... Cmdlet Enable-PSSessionConfiguration Enable-PSSessionConfiguratio... Cmdlet Enable-WSManCredSSP Enable-WSManCredSSP [-Role] ... Cmdlet Enter-PSSession Enter-PSSession [-ComputerNa... Alias epal Export-AliasAlias epcsv Export-CsvAlias epsn Export-PSSessionAlias erase Remove-ItemAlias etsn Enter-PSSessionCmdlet Exit-PSSession Exit-PSSession [-Verbose] [-... Cmdlet Export-Alias Export-Alias [-Path] <String... Cmdlet Export-Clixml Export-Clixml [-Path] <Strin... Cmdlet Export-Console Export-Console [[-Path] <Str... Cmdlet Export-Counter Export-Counter [-Path] <Stri... Cmdlet Export-Csv Export-Csv [-Path] <String> ... Cmdlet Export-FormatData Export-FormatData [-InputObj... Cmdlet Export-ModuleMember Export-ModuleMember [[-Funct... Cmdlet Export-PSSession Export-PSSession [-Session] ... Alias exsn Exit-PSSessionFunction F:Set-Location F:Alias fc Format-CustomAlias fl Format-ListAlias foreach ForEach-ObjectCmdlet ForEach-Object ForEach-Object [-Process] <S... Cmdlet Format-Custom Format-Custom [[-Property] <... Cmdlet Format-List Format-List [[-Property] <Ob... Cmdlet Format-Table Format-Table [[-Property] <O... Cmdlet Format-Wide Format-Wide [[-Property] <Ob... Alias ft Format-TableAlias fw Format-WideFunction G:Set-Location G:Alias gal Get-AliasAlias gbp Get-PSBreakpointAlias gc Get-ContentAlias gci Get-ChildItemAlias gcm Get-CommandAlias gcs Get-PSCallStackAlias gdr Get-PSDriveCmdlet Get-Acl Get-Acl [[-Path] <String[]>]... Cmdlet Get-Alias Get-Alias [[-Name] <String[]... Cmdlet Get-AuthenticodeSignature Get-AuthenticodeSignature [-... Cmdlet Get-ChildItem Get-ChildItem [[-Path] <Stri... Cmdlet Get-Command Get-Command [[-ArgumentList]... Cmdlet Get-ComputerRestorePoint Get-ComputerRestorePoint [[-... Cmdlet Get-Content Get-Content [-Path] <String[... Cmdlet Get-Counter Get-Counter [[-Counter] <Str... Cmdlet Get-Credential Get-Credential [-Credential]... Cmdlet Get-Culture Get-Culture [-Verbose] [-Deb... Cmdlet Get-Date Get-Date [[-Date] <DateTime>... Cmdlet Get-Event Get-Event [[-SourceIdentifie... Cmdlet Get-EventLog Get-EventLog [-LogName] <Str... Cmdlet Get-EventSubscriber Get-EventSubscriber [[-Sourc... Cmdlet Get-ExecutionPolicy Get-ExecutionPolicy [[-Scope... Cmdlet Get-FormatData Get-FormatData [[-TypeName] ... Cmdlet Get-Help Get-Help [[-Name] <String>] ... Cmdlet Get-History Get-History [[-Id] <Int64[]>... Cmdlet Get-Host Get-Host [-Verbose] [-Debug]... Cmdlet Get-HotFix Get-HotFix [[-Id] <String[]>... Cmdlet Get-Item Get-Item [-Path] <String[]> ... Cmdlet Get-ItemProperty Get-ItemProperty [-Path] <St... Cmdlet Get-Job Get-Job [[-Id] <Int32[]>] [-... Cmdlet Get-Location Get-Location [-PSProvider <S... Cmdlet Get-Member Get-Member [[-Name] <String[... Cmdlet Get-Module Get-Module [[-Name] <String[... Cmdlet Get-PfxCertificate Get-PfxCertificate [-FilePat... Cmdlet Get-Process Get-Process [[-Name] <String... Cmdlet Get-PSBreakpoint Get-PSBreakpoint [[-Script] ... Cmdlet Get-PSCallStack Get-PSCallStack [-Verbose] [... Cmdlet Get-PSDrive Get-PSDrive [[-Name] <String... Cmdlet Get-PSProvider Get-PSProvider [[-PSProvider... Cmdlet Get-PSSession Get-PSSession [[-ComputerNam... Cmdlet Get-PSSessionConfiguration Get-PSSessionConfiguration [... Cmdlet Get-PSSnapin Get-PSSnapin [[-Name] <Strin... Cmdlet Get-Random Get-Random [[-Maximum] <Obje... Cmdlet Get-Service Get-Service [[-Name] <String... Cmdlet Get-TraceSource Get-TraceSource [[-Name] <St... Cmdlet Get-Transaction Get-Transaction [-Verbose] [... Cmdlet Get-UICulture Get-UICulture [-Verbose] [-D... Cmdlet Get-Unique Get-Unique [-InputObject <PS... Cmdlet Get-Variable Get-Variable [[-Name] <Strin... Function Get-Verb...Cmdlet Get-WinEvent Get-WinEvent [[-LogName] <St... Cmdlet Get-WmiObject Get-WmiObject [-Class] <Stri... Cmdlet Get-WSManCredSSP Get-WSManCredSSP [-Verbose] ... Cmdlet Get-WSManInstance Get-WSManInstance [-Resource... Alias ghy Get-HistoryAlias gi Get-ItemAlias gjb Get-JobAlias gl Get-LocationAlias gm Get-MemberAlias gmo Get-ModuleAlias gp Get-ItemPropertyAlias gps Get-ProcessAlias group Group-ObjectCmdlet Group-Object Group-Object [[-Property] <O... Alias gsn Get-PSSessionAlias gsnp Get-PSSnapInAlias gsv Get-ServiceAlias gu Get-UniqueAlias gv Get-VariableAlias gwmi Get-WmiObjectAlias h Get-HistoryFunction H:Set-Location H:Function help...Alias history Get-HistoryFunction I:Set-Location I:Alias icm Invoke-CommandAlias iex Invoke-ExpressionAlias ihy Invoke-HistoryAlias ii Invoke-ItemCmdlet Import-Alias Import-Alias [-Path] <String... Cmdlet Import-Clixml Import-Clixml [-Path] <Strin... Cmdlet Import-Counter Import-Counter [-Path] <Stri... Cmdlet Import-Csv Import-Csv [-Path] <String[]... Cmdlet Import-LocalizedData Import-LocalizedData [-Bindi... Cmdlet Import-Module Import-Module [-Name] <Strin... Cmdlet Import-PSSession Import-PSSession [-Session] ... Function ImportSystemModules...Cmdlet Invoke-Command Invoke-Command [-ScriptBlock... Cmdlet Invoke-Expression Invoke-Expression [-Command]... Cmdlet Invoke-History Invoke-History [[-Id] <Strin... Cmdlet Invoke-Item Invoke-Item [-Path] <String[... Cmdlet Invoke-WmiMethod Invoke-WmiMethod [-Class] <S... Cmdlet Invoke-WSManAction Invoke-WSManAction [-Resourc... Alias ipal Import-AliasAlias ipcsv Import-CsvAlias ipmo Import-ModuleAlias ipsn Import-PSSessionAlias ise powershell_ise.exeAlias iwmi Invoke-WMIMethodFunction J:Set-Location J:Cmdlet Join-Path Join-Path [-Path] <String[]>... Function K:Set-Location K:Alias kill Stop-ProcessFunction L:Set-Location L:Cmdlet Limit-EventLog Limit-EventLog [-LogName] <S... Alias lp Out-PrinterAlias ls Get-ChildItemFunction M:Set-Location M:Alias man helpAlias md mkdirAlias measure Measure-ObjectCmdlet Measure-Command Measure-Command [-Expression... Cmdlet Measure-Object Measure-Object [[-Property] ... Alias mi Move-ItemFunction mkdir...Function more param([string[]]$paths)... Alias mount New-PSDriveAlias move Move-ItemCmdlet Move-Item Move-Item [-Path] <String[]>... Cmdlet Move-ItemProperty Move-ItemProperty [-Path] <S... Alias mp Move-ItemPropertyAlias mv Move-ItemFunction N:Set-Location N:Alias nal New-AliasAlias ndr New-PSDriveCmdlet New-Alias New-Alias [-Name] <String> [... Cmdlet New-Event New-Event [-SourceIdentifier... Cmdlet New-EventLog New-EventLog [-LogName] <Str... Cmdlet New-Item New-Item [-Path] <String[]> ... Cmdlet New-ItemProperty New-ItemProperty [-Path] <St... Cmdlet New-Module New-Module [-ScriptBlock] <S... Cmdlet New-ModuleManifest New-ModuleManifest [-Path] <... Cmdlet New-Object New-Object [-TypeName] <Stri... Cmdlet New-PSDrive New-PSDrive [-Name] <String>... Cmdlet New-PSSession New-PSSession [[-ComputerNam... Cmdlet New-PSSessionOption New-PSSessionOption [-Maximu... Cmdlet New-Service New-Service [-Name] <String>... Cmdlet New-TimeSpan New-TimeSpan [[-Start] <Date... Cmdlet New-Variable New-Variable [-Name] <String... Cmdlet New-WebServiceProxy New-WebServiceProxy [-Uri] <... Cmdlet New-WSManInstance New-WSManInstance [-Resource... Cmdlet New-WSManSessionOption New-WSManSessionOption [-Pro... Alias ni New-ItemAlias nmo New-ModuleAlias nsn New-PSSessionAlias nv New-VariableFunction O:Set-Location O:Alias ogv Out-GridViewAlias oh Out-HostCmdlet Out-Default Out-Default [-InputObject <P... Cmdlet Out-File Out-File [-FilePath] <String... Cmdlet Out-GridView Out-GridView [-InputObject <... Cmdlet Out-Host Out-Host [-Paging] [-InputOb... Cmdlet Out-Null Out-Null [-InputObject <PSOb... Cmdlet Out-Printer Out-Printer [[-Name] <String... Cmdlet Out-String Out-String [-Stream] [-Width... Function P:Set-Location P:Alias popd Pop-LocationCmdlet Pop-Location Pop-Location [-PassThru] [-S... Function prompt$(if (test-path variable:/PS... Alias ps Get-ProcessAlias pushd Push-LocationCmdlet Push-Location Push-Location [[-Path] <Stri... Alias pwd Get-LocationFunction Q:Set-Location Q:Alias r Invoke-HistoryFunction R:Set-Location R:Alias rbp Remove-PSBreakpointAlias rcjb Receive-JobAlias rd Remove-ItemAlias rdr Remove-PSDriveCmdlet Read-Host Read-Host [[-Prompt] <Object... Cmdlet Receive-Job Receive-Job [-Job] <Job[]> [... Cmdlet Register-EngineEvent Register-EngineEvent [-Sourc... Cmdlet Register-ObjectEvent Register-ObjectEvent [-Input... Cmdlet Register-PSSessionConfiguration Register-PSSessionConfigurat... Cmdlet Register-WmiEvent Register-WmiEvent [-Class] <... Cmdlet Remove-Computer Remove-Computer [[-Credentia... Cmdlet Remove-Event Remove-Event [-SourceIdentif... Cmdlet Remove-EventLog Remove-EventLog [-LogName] <... Cmdlet Remove-Item Remove-Item [-Path] <String[... Cmdlet Remove-ItemProperty Remove-ItemProperty [-Path] ... Cmdlet Remove-Job Remove-Job [-Id] <Int32[]> [... Cmdlet Remove-Module Remove-Module [-Name] <Strin... Cmdlet Remove-PSBreakpoint Remove-PSBreakpoint [-Breakp... Cmdlet Remove-PSDrive Remove-PSDrive [-Name] <Stri... Cmdlet Remove-PSSession Remove-PSSession [-Id] <Int3... Cmdlet Remove-PSSnapin Remove-PSSnapin [-Name] <Str... Cmdlet Remove-Variable Remove-Variable [-Name] <Str... Cmdlet Remove-WmiObject Remove-WmiObject [-Class] <S... Cmdlet Remove-WSManInstance Remove-WSManInstance [-Resou... Alias ren Rename-ItemCmdlet Rename-Item Rename-Item [-Path] <String>... Cmdlet Rename-ItemProperty Rename-ItemProperty [-Path] ... Cmdlet Reset-ComputerMachinePassword Reset-ComputerMachinePasswor... Cmdlet Resolve-Path Resolve-Path [-Path] <String... Cmdlet Restart-Computer Restart-Computer [[-Computer... Cmdlet Restart-Service Restart-Service [-Name] <Str... Cmdlet Restore-Computer Restore-Computer [-RestorePo... Cmdlet Resume-Service Resume-Service [-Name] <Stri... Alias ri Remove-ItemAlias rjb Remove-JobAlias rm Remove-ItemAlias rmdir Remove-ItemAlias rmo Remove-ModuleAlias rni Rename-ItemAlias rnp Rename-ItemPropertyAlias rp Remove-ItemPropertyAlias rsn Remove-PSSessionAlias rsnp Remove-PSSnapinAlias rv Remove-VariableAlias rvpa Resolve-PathAlias rwmi Remove-WMIObjectFunction S:Set-Location S:Alias sajb Start-JobAlias sal Set-AliasAlias saps Start-ProcessAlias sasv Start-ServiceAlias sbp Set-PSBreakpointAlias sc Set-ContentAlias select Select-ObjectCmdlet Select-Object Select-Object [[-Property] <...Cmdlet Select-String Select-String [-Pattern] <St... Cmdlet Select-Xml Select-Xml [-XPath] <String>... Cmdlet Send-MailMessage Send-MailMessage [-To] <Stri... Alias set Set-VariableCmdlet Set-Acl Set-Acl [-Path] <String[]> [... Cmdlet Set-Alias Set-Alias [-Name] <String> [... Cmdlet Set-AuthenticodeSignature Set-AuthenticodeSignature [-... Cmdlet Set-Content Set-Content [-Path] <String[... Cmdlet Set-Date Set-Date [-Date] <DateTime> ... Cmdlet Set-ExecutionPolicy Set-ExecutionPolicy [-Execut... Cmdlet Set-Item Set-Item [-Path] <String[]> ... Cmdlet Set-ItemProperty Set-ItemProperty [-Path] <St... Cmdlet Set-Location Set-Location [[-Path] <Strin... Cmdlet Set-PSBreakpoint Set-PSBreakpoint [-Script] <... Cmdlet Set-PSDebug Set-PSDebug [-Trace <Int32>]... Cmdlet Set-PSSessionConfiguration Set-PSSessionConfiguration [... Cmdlet Set-Service Set-Service [-Name] <String>... Cmdlet Set-StrictMode Set-StrictMode -Version <Ver... Cmdlet Set-TraceSource Set-TraceSource [-Name] <Str... Cmdlet Set-Variable Set-Variable [-Name] <String... Cmdlet Set-WmiInstance Set-WmiInstance [-Class] <St... Cmdlet Set-WSManInstance Set-WSManInstance [-Resource... Cmdlet Set-WSManQuickConfig Set-WSManQuickConfig [-UseSS... Cmdlet Show-EventLog Show-EventLog [[-ComputerNam... Alias si Set-ItemAlias sl Set-LocationAlias sleep Start-SleepAlias sort Sort-ObjectCmdlet Sort-Object Sort-Object [[-Property] <Ob... Alias sp Set-ItemPropertyAlias spjb Stop-JobCmdlet Split-Path Split-Path [-Path] <String[]... Alias spps Stop-ProcessAlias spsv Stop-ServiceAlias start Start-ProcessCmdlet Start-Job Start-Job [-ScriptBlock] <Sc... Cmdlet Start-Process Start-Process [-FilePath] <S... Cmdlet Start-Service Start-Service [-Name] <Strin... Cmdlet Start-Sleep Start-Sleep [-Seconds] <Int3... Cmdlet Start-Transaction Start-Transaction [-Timeout ... Cmdlet Start-Transcript Start-Transcript [[-Path] <S... Cmdlet Stop-Computer Stop-Computer [[-ComputerNam... Cmdlet Stop-Job Stop-Job [-Id] <Int32[]> [-P... Cmdlet Stop-Process Stop-Process [-Id] <Int32[]>... Cmdlet Stop-Service Stop-Service [-Name] <String... Cmdlet Stop-Transcript Stop-Transcript [-Verbose] [... Cmdlet Suspend-Service Suspend-Service [-Name] <Str... Alias sv Set-VariableAlias swmi Set-WMIInstanceFunction T:Set-Location T:Function TabExpansion...Alias tee Tee-ObjectCmdlet Tee-Object Tee-Object [-FilePath] <Stri... Cmdlet Test-ComputerSecureChannel Test-ComputerSecureChannel [...Cmdlet Test-Connection Test-Connection [-ComputerNa... Cmdlet Test-ModuleManifest Test-ModuleManifest [-Path] ... Cmdlet Test-Path Test-Path [-Path] <String[]>... Cmdlet Test-WSMan Test-WSMan [[-ComputerName] ... Cmdlet Trace-Command Trace-Command [-Name] <Strin... Alias type Get-ContentFunction U:Set-Location U:Cmdlet Undo-Transaction Undo-Transaction [-Verbose] ... Cmdlet Unregister-Event Unregister-Event [-SourceIde... Cmdlet Unregister-PSSessionConfigur...Unregister-PSSessionConfigur... Cmdlet Update-FormatData Update-FormatData [[-AppendP... Cmdlet Update-List Update-List [[-Property] <St... Cmdlet Update-TypeData Update-TypeData [[-AppendPat... Cmdlet Use-Transaction Use-Transaction [-Transacted... Function V:Set-Location V:Function W:Set-Location W:Cmdlet Wait-Event Wait-Event [[-SourceIdentifi... Cmdlet Wait-Job Wait-Job [-Id] <Int32[]> [-A... Cmdlet Wait-Process Wait-Process [-Name] <String... Alias where Where-ObjectCmdlet Where-Object Where-Object [-FilterScript]... Alias wjb Wait-JobAlias write Write-OutputCmdlet Write-Debug Write-Debug [-Message] <Stri... Cmdlet Write-Error Write-Error [-Message] <Stri... Cmdlet Write-EventLog Write-EventLog [-LogName] <S... Cmdlet Write-Host Write-Host [[-Object] <Objec... Cmdlet Write-Output Write-Output [-InputObject] ... Cmdlet Write-Progress Write-Progress [-Activity] <... Cmdlet Write-Verbose Write-Verbose [-Message] <St... Cmdlet Write-Warning Write-Warning [-Message] <St... Function X:Set-Location X:Function Y:Set-Location Y:Function Z:Set-Location Z:。