• 【191】◀▶ Powershell 命令集 Cmdlets


     Powershell 命令集 cmdlets

    cmdlets是Powershell的内部命令,cmdlet的类型名为System.Management.Automation.CmdletInfo,包含下列属性和方法:

    Name MemberType Definition
    Equals Method bool Equals(System.Object obj)
    GetHashCode Method int GetHashCode()
    GetType Method type GetType()
    ToString Method string ToString()
    CommandType Property System.Management.Automation.CommandTypes CommandType {get;}
    DefaultParameterSet Property System.String DefaultParameterSet {get;}
    Definition Property System.String Definition {get;}
    HelpFile Property System.String HelpFile {get;}
    ImplementingType Property System.Type ImplementingType {get;}
    Module Property System.Management.Automation.PSModuleInfo Module {get;}
    ModuleName Property System.String ModuleName {get;}
    Name Property System.String Name {get;}
    Noun Property System.String Noun {get;}
    OutputType Property System.Collections.ObjectModel.ReadOnlyCollection`1[[System.Management.Automation.PSTypeName, System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]] OutputType {get;}
    Parameters Property System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Management.Automation.ParameterMetadata, System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]] Parameters {get;}
    ParameterSets Property System.Collections.ObjectModel.ReadOnlyCollection`1[[System.Management.Automation.CommandParameterSetInfo, System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]] ParameterSets {get;}
    PSSnapIn Property System.Management.Automation.PSSnapInInfo PSSnapIn {get;}
    Verb Property System.String Verb {get;}
    Visibility Property System.Management.Automation.SessionStateEntryVisibility Visibility {get;set;}
    DLL ScriptProperty System.Object DLL {get=$this.ImplementingType.Assembly.Location;}
    HelpUri ScriptProperty System.Object HelpUri {get=try
    {
    # ok to cast CommandTypes enum to HelpCategory because string/indentifier for
    # cmdlet,function,filter,alias,externalscript is identical.
    # it is ok to fail for other enum values (i.e. for Application)
    $helpObject = get-help -Name ($this.Name) -Category ([string]($this.CommandType)) -ErrorAction SilentlyContinue# return first non-null uri (and try not to hit any strict mode things)
    if ($helpObject -eq $null) { return $null }
    if ($helpObject.psobject.properties[‘relatedLinks’] -eq $null) { return $null }
    if ($helpObject.relatedLinks.psobject.properties[‘navigationLink’] -eq $null) { return $null }
    $helpUri = [string]$( $helpObject.relatedLinks.navigationLink | %{ if ($_.psobject.properties[‘uri’] -ne $null) { $_.uri } } | ?{ $_ } | select -first 1 )
    return $helpUri
    }
    catch {};}

    下面是全部的 Cmdlets 命令

    每个命令有一个动词和名词组成,命令的作用一目了然。

    Name ModuleName Help
    Add-Computer Microsoft.PowerShell.Management help
    Add-Content Microsoft.PowerShell.Management help
    (别名:ac)在文件后面追加内容。

    -Path:路径

    -Value:添加的字符串

    -Include:包括指定的文件

    -Exclude:不包括的文件

    Add-History Microsoft.PowerShell.Core help
    Add-Member Microsoft.PowerShell.Utility help
    向 Windows PowerShell 对象的实例中添加用户定义的自定义成员。
    Add-PSSnapin Microsoft.PowerShell.Core help
    Add-Type Microsoft.PowerShell.Utility help
    Checkpoint-Computer Microsoft.PowerShell.Management help
    Clear-Content Microsoft.PowerShell.Management help
    (别名:clc)清空文件的内容。
    -Confirm:在运行 cmdlet 前提示你进行确认。
    Clear-EventLog Microsoft.PowerShell.Management help
    Clear-History Microsoft.PowerShell.Core help
    (别名:clhy)删除命令历史记录中的条目。

    -CommandLine <string[]>:删除具有指定文本字符串的命令。如果输入了多个字符串,则 Clear-History 会删除具有其中任意字符串的命令。

    -Count <int>:从历史记录中最旧的条目开始,清除指定数量的历史记录条目。

    -Id <Int32[]>:删除具有指定历史记录 ID 的命令。要查找命令的历史记录 ID,请使用 Get-History。

    -Newest:删除历史记录中最新的条目。默认情况下,Clear-History 删除历史记录中最旧的条目。

    -Confirm:在执行命令之前提示您进行确认。

    Clear-Item Microsoft.PowerShell.Management help
    Clear-ItemProperty Microsoft.PowerShell.Management help
    Clear-Variable Microsoft.PowerShell.Utility help
    (别名:clv)删除变量的值。Clear-Variable cmdlet 将删除变量中存储的数据,但不删除该变量。因此,该变量的值为 NULL(空)。
    Compare-Object Microsoft.PowerShell.Utility help
    (别名:compare、diff)比较两组对象。Compare-Object cmdlet 将两组对象进行比较。一组对象为 Reference 组,而另一组为 Difference 组。比较的结果将指示属性值是只出现在 Reference 组中的对象中(由 <= 符号指示),或是只出现在 Difference 组中的对象中(由 => 符号指示),抑或(在指定了 IncludeEqual 参数的情况下)同时出现在这两个对象中(由 == 符号指示)。
    Complete-Transaction Microsoft.PowerShell.Management help
    Connect-WSMan Microsoft.WSMan.Management help
    ConvertFrom-Csv Microsoft.PowerShell.Utility help
    ConvertFrom-SecureString Microsoft.PowerShell.Security help
    ConvertFrom-StringData Microsoft.PowerShell.Utility help
    Convert-Path Microsoft.PowerShell.Management help
    ConvertTo-Csv Microsoft.PowerShell.Utility help
    ConvertTo-Html Microsoft.PowerShell.Utility help
    将 Microsoft .NET Framework 对象转换为可在 Web 浏览器中显示的 HTML。

    -As <string>:确定将对象设置为表格格式还是列表格式。有效值为 TABLE 和 LIST。默认值为 TABLE。

    -Body <string[]>:指定要在左 <BODY> 标记之后添加的文本。默认情况下,该位置没有文本。

    -CssUri <Uri>:指定层叠样式表 (CSS) 的统一资源标识符 (URI),该 URI 将应用在 HTML 文件中。输出中的样式表链接中将包括该 URI。

    -Fragment:仅生成一个 HTML 表。省略了 HTML、HEAD、TITLE 和 BODY 标记。

    -Head <string[]>:指定 <HEAD> 标记的内容。默认值为“<title>HTML TABLE</title>”。如果使用 Head 参数,则忽略 Title 参数。

    -InputObject <psobject>:指定要用 HTML 表示的对象。请输入包含对象的变量,或者键入可获取对象的命令或表达式。

    -PostContent <string[]>:指定要在右 </TABLE> 标记之后添加的文本。默认情况下,该位置没有文本。

    -PreContent <string[]>:指定要在左 <TABLE> 标记之前添加的文本。默认情况下,该位置没有文本。

    -Title <string>:指定 HTML 文件的标题,即在 <TITLE> 标记之间显示的文本。

    ConvertTo-SecureString Microsoft.PowerShell.Security help
    ConvertTo-Xml Microsoft.PowerShell.Utility help
    Copy-Item Microsoft.PowerShell.Management help
    Copy-ItemProperty Microsoft.PowerShell.Management help
    Debug-Process Microsoft.PowerShell.Management help
    Disable-ComputerRestore Microsoft.PowerShell.Management help
    Disable-PSBreakpoint Microsoft.PowerShell.Utility help
    Disable-PSSessionConfiguration Microsoft.PowerShell.Core help
    Disable-WSManCredSSP Microsoft.WSMan.Management help
    Disconnect-WSMan Microsoft.WSMan.Management help
    Enable-ComputerRestore Microsoft.PowerShell.Management help
    Enable-PSBreakpoint Microsoft.PowerShell.Utility help
    Enable-PSRemoting Microsoft.PowerShell.Core help
    Enable-PSSessionConfiguration Microsoft.PowerShell.Core help
    Enable-WSManCredSSP Microsoft.WSMan.Management help
    Enter-PSSession Microsoft.PowerShell.Core help
    Exit-PSSession Microsoft.PowerShell.Core help
    Export-Alias Microsoft.PowerShell.Utility help
    Export-Clixml Microsoft.PowerShell.Utility help
    Export-Console Microsoft.PowerShell.Core help
    Export-Counter Microsoft.PowerShell.Diagnostics help
    Export-Csv Microsoft.PowerShell.Utility help
    (别名:epcsv)将 Microsoft .NET Framework 对象转换为一系列以逗号分隔的、长度可变的 (CSV) 字符串,并将这些字符串保存到一个 CSV 文件中。
    Export-FormatData Microsoft.PowerShell.Utility help
    Export-ModuleMember Microsoft.PowerShell.Core help
    Export-PSSession Microsoft.PowerShell.Utility help
    ForEach-Object Microsoft.PowerShell.Core help
    (别名:ForEach、%)对输入的对象集合的每个项目进行操作。

    -Process<ScriptBlock[]>:执行对于每个项目都进行的操作(用 "{}" 包在里面)

    -Begin<ScriptBlock>:在执行 Process 之前进行的操作

    -End<ScriptBlock>:在执行 Process 之后进行的操作

    Format-Custom Microsoft.PowerShell.Utility help
    Format-List Microsoft.PowerShell.Utility help
    (别名:fl)将输出的格式设置为属性列表,其中每个属性均各占一行显示。

    -GroupBy <Object>:根据共享属性或值将输出结果分组显示。请输入表达式或输出的属性。

    -Property <Object[]>:指定要在屏幕上显示的对象属性及其显示顺序。允许使用通配符。

    Format-Table Microsoft.PowerShell.Utility help
    (别名:ft)将输出的格式设置为表。

    -AutoSize:根据数据的宽度调整列大小和列数。默认情况下,列大小和列数由视图确定。

    -HideTableHeaders:省略表中的列标题。

    -Wrap:在下一行显示超过列宽的文本。默认情况下,超过列宽的文本将被截断。

    Format-Wide Microsoft.PowerShell.Utility help
    Get-Acl Microsoft.PowerShell.Security help
    Get-Alias Microsoft.PowerShell.Utility help
    (别名:gal)获取当前会话的别名。

    -Definition <string[]>:获取所指定项的别名。

    -Exclude <string[]>:忽略指定项。

    -Name <string[]>:指定要检索的别名。允许使用通配符。

    Get-AuthenticodeSignature Microsoft.PowerShell.Security help
    Get-ChildItem Microsoft.PowerShell.Management help
    (别名:dir、gci、ls)Gets the items and child items in one or more specified locations.

    -Recurse:获取指定路径下的项目以及子路径中的项目

    -Force:强制执行

    Get-Command Microsoft.PowerShell.Core help
    (别名:gcm)获取所有的命令。    
    Get-ComputerRestorePoint Microsoft.PowerShell.Management help
    Get-Content Microsoft.PowerShell.Management help
    (别名:cat、gc、type)Gets the content of the item at the specified location.

    -Path:指定项目的具体路径

    -TotalCount:从文件或项目的开始处获取指定的行数,也可以使用别名 "First"、"Head"
    获取指定行的内容:(Get-Content Cmdlets.txt -TotalCount 5)[-1]

    -Tail:从文件最后开始计算,别名是 "Last"

    Get-Counter Microsoft.PowerShell.Diagnostics help
    Get-Credential Microsoft.PowerShell.Security help
    Get-Culture Microsoft.PowerShell.Utility help
    Get-Date Microsoft.PowerShell.Utility help
    Get-Event Microsoft.PowerShell.Utility help
    Get-EventLog Microsoft.PowerShell.Management help
    Get-EventSubscriber Microsoft.PowerShell.Utility help
    Get-ExecutionPolicy Microsoft.PowerShell.Security help
    Get-FormatData Microsoft.PowerShell.Utility help
    Get-Help Microsoft.PowerShell.Core help
    (别名:help)显示命令的帮助信息。

    -Detailed:参数描述和例子。

    -Examples:例子。

    -Full:全部信息显示。

    -ShowWindow:弹出窗体查看。

    Get-History Microsoft.PowerShell.Core help
    (别名:ghy、h、history)获取在当前会话中输入的命令的列表。

    -Count <int>:显示指定数量的最近历史记录条目。

    -Id <Int64[]>:指定会话历史记录中的命令的 ID 号。Get-History 只获取指定的命令。如果使用 Id 和 Count,则 Get-History 获取最近的命令,一直到 Id 参数所指定的命令。

    Get-Host Microsoft.PowerShell.Utility help
    获取表示当前主机程序的对象。默认情况下,还显示 Windows PowerShell 的版本和区域信息。
    Get-HotFix Microsoft.PowerShell.Management help
    Get-Item Microsoft.PowerShell.Management help
    Get-ItemProperty Microsoft.PowerShell.Management help
    Get-Job Microsoft.PowerShell.Core help
    Get-Location Microsoft.PowerShell.Management help
    Get-Member Microsoft.PowerShell.Utility help
    (别名:gm)获取对象的属性和方法。

    -MemberType <PSMemberTypes>:仅获取具有指定成员类型的成员。默认值为 All。

    -Name <string[]>:指定对象的一个或多个属性或方法的名称。Get-Member 仅获取指定的属性和方法。

    -Static:仅获取对象的静态属性和方法。将在对象的类上定义静态属性和方法,而不是在类的任何特定实例上定义。

    Get-Module Microsoft.PowerShell.Core help
    (别名:gmo)获取已导入或可以导入到当前会话中的模块。
    Get-PfxCertificate Microsoft.PowerShell.Security help
    Get-Process Microsoft.PowerShell.Management help
    (别名:gps、ps)获取本地电脑或者远程电脑正在运行的进程。
    Get-PSBreakpoint Microsoft.PowerShell.Utility help
    Get-PSCallStack Microsoft.PowerShell.Utility help
    Get-PSDrive Microsoft.PowerShell.Management help
    (别名:gdr)获取当前会话中的驱动器
    Get-PSProvider Microsoft.PowerShell.Management help
    Get-PSSession Microsoft.PowerShell.Core help
    Get-PSSessionConfiguration Microsoft.PowerShell.Core help
    Get-PSSnapin Microsoft.PowerShell.Core help
    Get-Random Microsoft.PowerShell.Utility help
    Get-Service Microsoft.PowerShell.Management help
    (别名:gsv)获取本地或者远程计算机的服务。
    Get-TraceSource Microsoft.PowerShell.Utility help
    Get-Transaction Microsoft.PowerShell.Management help
    Get-UICulture Microsoft.PowerShell.Utility help
    Get-Unique Microsoft.PowerShell.Utility help
    (别名:gu)从排序列表返回唯一项目。
    Get-Variable Microsoft.PowerShell.Utility help
    (别名:gv) 获取当前控制台中的变量。
    Get-WinEvent Microsoft.PowerShell.Diagnostics help
    Get-WmiObject Microsoft.PowerShell.Management help
    Get-WSManCredSSP Microsoft.WSMan.Management help
    Get-WSManInstance Microsoft.WSMan.Management help
    Group-Object Microsoft.PowerShell.Utility help

    (别名:group)指定的属性包含相同值的组对象。Group-Object cmdlet 基于指定属性的值以组的形式显示对象。Group-Object 返回一个表,其中每个属性值对应一行,同时一个列显示具有该值的项目数。

    -Property:指定用于分组的属性。对象将基于指定属性的值排列到组中。

    -NoElement:从结果中忽略某个组的成员。将数组中相同的要素组合在一起。

    Import-Alias Microsoft.PowerShell.Utility help
    Import-Clixml Microsoft.PowerShell.Utility help
    Import-Counter Microsoft.PowerShell.Diagnostics help
    Import-Csv Microsoft.PowerShell.Utility help
    (别名:ipcsv)将逗号分隔值 (CSV) 文件中的对象属性转换为原始对象的 CSV 版本。
    Import-LocalizedData Microsoft.PowerShell.Utility help
    Import-Module Microsoft.PowerShell.Core help
    Import-PSSession Microsoft.PowerShell.Utility help
    Invoke-Command Microsoft.PowerShell.Core help
    Invoke-Expression Microsoft.PowerShell.Utility help
    (别名:iex)在本地计算机上运行命令或表达式。
    -Command <string>:指定要运行的命令或表达式。键入该命令或表达式,或输入包含该命或表达式的变量。 Command 参数是必需的。
    Invoke-History Microsoft.PowerShell.Core help
    (别名:ihy、r)从会话历史记录中运行命令。
    Invoke-Item Microsoft.PowerShell.Management help
    (别名:ii)对指定项执行默认操作。(打开文件或者文件夹)
    打开当前的工作空间:“ii .”。
    Invoke-WmiMethod Microsoft.PowerShell.Management help
    Invoke-WSManAction Microsoft.WSMan.Management help
    Join-Path Microsoft.PowerShell.Management help
    将路径和子路径合并到单个路径中。提供程序将提供路径分隔符。
    参考:Join-Path 帮助信息

    -Path<String[]>:主路径,可以是数组形式。

    -ChildPath<String>:子路径。

    -resolve:指定连接后的路径所引用的对象.

    Limit-EventLog Microsoft.PowerShell.Management help
    Measure-Command Microsoft.PowerShell.Utility help
    Measure-Object Microsoft.PowerShell.Utility help
    (别名:measure)计算对象的数字属性以及字符串对象(如文本文件)中的字符数、单词数和行数。它可以对对象计数并计算数字值的最小值、最大值、总和及平均值。对于文本对象,它可以计数并计算行数、单词数和字符数。

    -Average:显示指定属性的平均值。

    -Character:计算输入对象中的字符数。

    -IgnoreWhiteSpace:在单词计数和字符计数时忽略空白。默认情况下,不忽略空白。

    -InputObject <psobject>:指定要度量的对象。输入一个包含对象的变量,或键入可获取对象的命令或表达式。

    -Line:计算输入对象中的行数。

    -Maximum:显示指定属性的最大值。

    -Minimum:显示指定属性的最小值。

    -Property <string[]>:指定要度量的一个或多个数字属性。默认值是对象的 Count (Length) 属性。

    -Sum:显示指定属性的值的总和。

    -Word:计算输入对象中的单词数。

    Move-Item Microsoft.PowerShell.Management help
    Move-ItemProperty Microsoft.PowerShell.Management help
    New-Alias Microsoft.PowerShell.Utility help
    New-Event Microsoft.PowerShell.Utility help
    New-EventLog Microsoft.PowerShell.Management help
    New-Item Microsoft.PowerShell.Management help
    (别名:ni)创建新项。

    -Force [<SwitchParameter>]:允许 cmdlet 创建项以覆盖现有只读项。

    -ItemType <String>:指定提供程序指定的新项的类型。(file 或者 directory,也可以直接使用 mkdir)

    -Name <String>:指定新项的名称。

    -Path <String[]>:指定到新项位置的路径。允许使用通配符。

    -Value <Object>:指定新项的值。

    -Confirm [<SwitchParameter>]:运行 cmdlet 之前提示你进行确认。

    New-ItemProperty Microsoft.PowerShell.Management help
    New-Module Microsoft.PowerShell.Core help
    New-ModuleManifest Microsoft.PowerShell.Core help
    New-Object Microsoft.PowerShell.Utility help
    创建 Microsoft .NET Framework 或 COM 对象的实例。
    New-PSDrive Microsoft.PowerShell.Management help
    New-PSSession Microsoft.PowerShell.Core help
    New-PSSessionOption Microsoft.PowerShell.Core help
    New-Service Microsoft.PowerShell.Management help
    New-TimeSpan Microsoft.PowerShell.Utility help
    New-Variable Microsoft.PowerShell.Utility help
    (别名:nv)创建新变量。

    -Description <string>:指定变量的说明。

    -Name <string>:指定新变量的名称。

    -Value <Object>:指定变量的初始值。

    -Force:允许您创建名称与现有只读变量相同的新变量。默认情况下,可以覆盖某个变量,除非该变量的选项值为“ReadOnly”或“Constant”。

    -Confirm:在执行命令之前提示您进行确认。

    -Option <ScopedItemOptions>:设置新变量的 Options 属性的值。
    有效值包括:
        -- None:不设置任何选项。(“None”为默认值。)
        -- ReadOnly:除非使用 Force 参数,否则无法更改变量的值。您可以使用 Remove-Variable 来删除该变量。
        -- Constant:无法删除变量,也无法更改其属性。“Constant”仅在您创建别名时才可用。不能将现有变量的选项更改为“Constant”。
        -- Private:变量只在 Scope 参数指定的作用域内可用。它由子作用域继承。(此值与 Visibility 参数的“Private”值无关。)
        -- AllScope:变量将复制到创建的所有新作用域中。

    New-WebServiceProxy Microsoft.PowerShell.Management help
    New-WSManInstance Microsoft.WSMan.Management help
    New-WSManSessionOption Microsoft.WSMan.Management help
    Out-Default Microsoft.PowerShell.Utility help
    Out-File Microsoft.PowerShell.Utility help
    将输出发送到文件。如果需要使用它的参数,可以使用此 cmdlet 而不是重定向运算符 (>)。

    -Append:将输出添加到现有文件的末尾,而不替换文件内容。

    -FilePath <string>:指定输出文件的路径。

    -Force:允许该 cmdlet 覆盖现有只读文件。

    -InputObject <psobject>:指定要写入文件的对象。请输入包含对象的变量,或者键入可获取对象的命令或表达式。

    -NoClobber:将不会覆盖现有文件(替换其内容)。默认情况下,如果指定的路径中存在同名文件,则 Out-File 将覆盖该文件,而不会发出警告。如果同时使用了 Append 和 NoClobber,则输出内容将追加到现有文件中。

    -Width <int>:指定输出中每一行的字符数。将截断任何额外字符,不换行。如果省略此参数,则由主机特征确定宽度。Windows PowerShell 控制台的默认值是 80(字符)。

    -Confirm:在执行命令之前提示您进行确认。

    Out-GridView Microsoft.PowerShell.Utility help
    Out-Host Microsoft.PowerShell.Utility help
    将输出发送到命令行。    
    Out-Null Microsoft.PowerShell.Utility help
    Out-Printer Microsoft.PowerShell.Utility help
    Out-String Microsoft.PowerShell.Utility help
    将对象作为一列字符串发送到主机。
    Pop-Location Microsoft.PowerShell.Management help
    (别名:popd)将当前位置更改为最近推入到堆栈中的位置。
    Push-Location Microsoft.PowerShell.Management help
    (别名:pushd)将当前位置添加到位置堆栈的顶部。
    Read-Host Microsoft.PowerShell.Utility help
    从控制台读取一行输入。

    -AsSecureString:显示星号 (*) 来替代用户作为输入键入的字符。

    -Prompt <Object>:指定提示的文本。键入一个字符串。如果该字符串包括空格,请将其括在引号中。

    Receive-Job Microsoft.PowerShell.Core help
    Register-EngineEvent Microsoft.PowerShell.Utility help
    Register-ObjectEvent Microsoft.PowerShell.Utility help
    Register-PSSessionConfiguration Microsoft.PowerShell.Core help
    Register-WmiEvent Microsoft.PowerShell.Management help
    Remove-Computer Microsoft.PowerShell.Management help
    Remove-Event Microsoft.PowerShell.Utility help
    Remove-EventLog Microsoft.PowerShell.Management help
    Remove-Item Microsoft.PowerShell.Management help
    (别名:del、erase、rd、ri、rm、rmdir)删除指定项。

    -Exclude <String[]>:忽略指定项。此参数值使 Path 参数有效。请输入路径元素或模式,例如“*.txt”。允许使用通配符。

    -Filter <String>:以提供程序的格式或语言指定筛选器。此参数值使 Path 参数有效。筛选器的语法(包括通配符的使用)取决于提供程序。

    -Force [<SwitchParameter>]:允许该 cmdlet 删除非此不能更改的项,如隐藏文件或只读文件,或者只读别名或变量。

    -Include <String[]>:只删除指定项。此参数值使 Path 参数有效。请输入路径元素或模式,例如“*.txt”。允许使用通配符。

    -LiteralPath <String[]>:指定要删除的项的路径。与 Path 不同,LiteralPath 的值严格按照所键入的形式使用。不会将任何字符解释为通配符。如果路径包括转义符,请将其括在单引号中。单引号会告知 Windows PowerShell 不要将所有字符都解释为转义序列。

    -Path <String[]>:指定要删除的项的路径。允许使用通配符。参数名(“-Path”)为可选项。

    -Recurse [<SwitchParameter>]:删除指定位置及这些位置的所有子项中的项。

    -Confirm [<SwitchParameter>]:运行 cmdlet 之前提示你进行确认。

    Remove-ItemProperty Microsoft.PowerShell.Management help
    Remove-Job Microsoft.PowerShell.Core help
    Remove-Module Microsoft.PowerShell.Core help
    Remove-PSBreakpoint Microsoft.PowerShell.Utility help
    Remove-PSDrive Microsoft.PowerShell.Management help
    Remove-PSSession Microsoft.PowerShell.Core help
    Remove-PSSnapin Microsoft.PowerShell.Core help
    Remove-Variable Microsoft.PowerShell.Utility help
    (别名:rv)删除变量及其值。Remove-Variable cmdlet 从定义变量的作用域(例如,当前会话)中删除变量及其值。
    Remove-WmiObject Microsoft.PowerShell.Management help
    Remove-WSManInstance Microsoft.WSMan.Management help
    Rename-Item Microsoft.PowerShell.Management help
    (别名:ren、rni)重命名 Windows PowerShell 提供程序命名空间中的一个项。

    -Force [<SwitchParameter>]:允许该 cmdlet 重命名非此不能更改的项,如隐藏文件或只读文件,或者只读别名或变量。该 cmdlet 不能更改常量别名或变量。不同提供程序有不同的实现。有关详细信息,请参阅 about_Providers。即使使用 Force 参数,该 cmdlet 也无法覆盖安全限制。

    -LiteralPath <String>:指定要重命名的项的路径。与 Path 参数不同,LiteralPath 的值严格按照所键入的形式使用。不会将任何字符解释为通配符。如果路径包括转义符,请将其括在单引号中。单引号会告知 Windows PowerShell 不要将所有字符都解释为转义序列。

    -NewName <String>:指定项的新名称。请仅输入名称,而不是路径加名称。如果输入的路径不同于 Path 参数中指定的路径,则 Rename-Item 会生成错误。要重命名并移动项,请使用 Move-Item cmdlet。  

    -Path <String>:指定要重命名的项的路径。

    -Confirm [<SwitchParameter>]:运行 cmdlet 之前提示你进行确认。

    Rename-ItemProperty Microsoft.PowerShell.Management help
    Reset-ComputerMachinePassword Microsoft.PowerShell.Management help
    Resolve-Path Microsoft.PowerShell.Management help
    (别名:rvpa)解析路径中的通配符并显示路径内容。

    -LiteralPath <String[]>:指定要解析的路径。LiteralPath 的值严格按照所键入的形式使用。不会将任何字符解释为通配符。如果路径包括转义符,请将其括在单引号中。单引号会告知 Windows PowerShell 不要将所有字符都解释为转义序列。

    -Path <String[]>:指定要解析的 Windows PowerShell 路径。此参数是必需的。还可以通过管道将路径字符串传递给 Resolve-Path。

    -Relative [<SwitchParameter>]:返回相对路径。

    Restart-Computer Microsoft.PowerShell.Management help
    Restart-Service Microsoft.PowerShell.Management help
    Restore-Computer Microsoft.PowerShell.Management help
    Resume-Service Microsoft.PowerShell.Management help
    Select-Object Microsoft.PowerShell.Utility help
    (别名:select)选择一个对象或一组对象的指定属性。它还可以从对象的数组中选择唯一对象,也可以从对象数组的开头或末尾选择指定个数的对象。

    -First <int>:指定要从输入对象的数组的开头选择的对象数。

    -Last <int>:指定要从输入对象的数组的末尾选择的对象数。

    -Unique:指定如果输入对象的子集有相同的属性和值,则只选择该子集的一个成员。

    -Index <Int32[]>:基于对象的索引值从数组中选择对象。以逗号分隔的列表形式输入索引。数组中的索引从 0 开始,0 表示第一个值,(n-1) 表示最后一个值。

    -Skip <int>:跳过(不选择)指定数量的项目。默认情况下,Skip 参数会从数组或对象列表的开头开始计数,但如果命令使用 Last 参数,它会从列表或数组的末尾开始计数。与从 0 开始计数的 Index 参数不同,Skip 参数从 1 开始计数。

    Select-String Microsoft.PowerShell.Utility help
    (别名:sls)查找字符串和文件中的文本。Select-String cmdlet 在输入字符串和文件中搜索文本和文本模式。您可以像在 UNIX 中使用 Grep、在 Windows 中使用 Findstr 一样使用该命令。(可搜索文件中的文本

    -Pattern <string[]>:指定要查找的文本。键入字符串或正则表达式。如果您键入字符串,则使用 SimpleMatch 参数。

    -AllMatches:在每个文本行中搜索多个匹配项。若不使用此参数,Select-String 只会查找每个文本行中的第一个匹配项。当 Select-String 在一个文本行中找到多个匹配项时,它仍然只会为该行发出一个 MatchInfo 对象,但是该对象的 Matches 属性包含所有匹配项。

    -CaseSensitive:使匹配项区分大小写。默认情况下,匹配项不区分大小写。

    -Context <Int32[]>:捕获包含匹配项的行前后的指定行数。这允许您在上下文中查看匹配项。

    -Encoding <string>:指定 Select-String 在搜索文件时应采用的字符编码。默认值为 UTF8。

    -Exclude <string[]>:排除指定项。此参数的值对 Path 参数进行限定。请输入路径元素或模式,例如“*.txt”。允许使用通配符。

    -Include <string[]>:只包括指定项。此参数的值对 Path 参数进行限定。请输入路径元素或模式,例如“*.txt”。允许使用通配符。

    -InputObject <psobject>:指定要搜索的文本。请输入包含文本的变量,或键入可获取文本的命令或表达式。

    -List:只返回每个输入文件中的第一个匹配项。默认情况下,Select-String 会为它找到的每个匹配项返回一个 MatchInfo 对象。

    -NotMatch:查找与指定模式不匹配的文本。

    -Path <string[]>:指定要搜索的文件的路径。允许使用通配符。默认位置为本地目录。
    指定目录中的文件,如“log1.txt”、“*.doc”或“*.*”。如果只指定一个目录,该命令会失败。

    Select-Xml Microsoft.PowerShell.Utility help
    Send-MailMessage Microsoft.PowerShell.Utility help
    Set-Acl Microsoft.PowerShell.Security help
    Set-Alias Microsoft.PowerShell.Utility help
    (别名:sal)在当前 Windows PowerShell 会话中为 cmdlet 或其他命令元素创建或更改别名(替代名称)。
    Set-AuthenticodeSignature Microsoft.PowerShell.Security help
    Set-Content Microsoft.PowerShell.Management help
    (别名:sc)Writes or replaces the content in an item with new content.

    -Path:文件路径

    -Value:添加的字符串

    Set-Date Microsoft.PowerShell.Utility help
    Set-ExecutionPolicy Microsoft.PowerShell.Security help
    Set-Item Microsoft.PowerShell.Management help
    Set-ItemProperty Microsoft.PowerShell.Management help
    (别名:sp)创建或者改变一个项目的属性值。
    Set-Location Microsoft.PowerShell.Management help
    (别名:cd、chdir、sl)将当前工作位置设置为指定的位置。
    Set-PSBreakpoint Microsoft.PowerShell.Utility help
    Set-PSDebug Microsoft.PowerShell.Core help
    Set-PSSessionConfiguration Microsoft.PowerShell.Core help
    Set-Service Microsoft.PowerShell.Management help
    Set-StrictMode Microsoft.PowerShell.Core help
    Set-TraceSource Microsoft.PowerShell.Utility help
    Set-Variable Microsoft.PowerShell.Utility help
    (别名:set、sv)设置变量的值。如果不存在具有所请求名称的变量,则创建该变量。
    Set-WmiInstance Microsoft.PowerShell.Management help
    Set-WSManInstance Microsoft.WSMan.Management help
    Set-WSManQuickConfig Microsoft.WSMan.Management help
    Show-EventLog Microsoft.PowerShell.Management help
    Sort-Object Microsoft.PowerShell.Utility help
    (别名:sort)按属性值对对象进行排序。

    -CaseSensitive:指示排序应区分大小写。默认情况下,排序不区分大小写。

    -Descending:以降序对对象进行排序。默认值为升序。

    -Property:指定排序时要使用的属性。对象将基于这些属性的值进行排序。输入属性的名称。允许使用通配符。

    -Unique:消除重复项,只返回集合的唯一成员。

    Split-Path Microsoft.PowerShell.Management help
    返回指定的路径部分。

    -Qualifier [<SwitchParameter>]:只返回指定路径的限定符。对于 FileSystem 或 Registry 提供程序,限定符是提供程序路径的驱动器,例如,C: 或 HKCU:。

    -Leaf [<SwitchParameter>]:只返回路径中的最后一项或最后一个容器。例如,在路径“C:TestLogsPass1.log”中,该命令仅返回“Pass1.log”。

    Start-Job Microsoft.PowerShell.Core help
    Start-Process Microsoft.PowerShell.Management help
    (别名:saps、start)在本地计算机开始一个或者多个进程。

    -FilePath<String>:要运行进程的路径,可以是 *.txt 或 *.doc 文件等,不特别指定就是当前路径下的。

    -WorkingDirectory<String>:指定工作空间,默认为当前路径。

    -Wait:

    -WindowStyle<ProcessWindowStyle>:窗口打开时候的状态,Normal、Hidden、Minimized 和 Maximized,默认是 Normal。

    -verb:-verb runas,以管理员打开进程

    Start-Service Microsoft.PowerShell.Management help
    Start-Sleep Microsoft.PowerShell.Utility help
    Start-Transaction Microsoft.PowerShell.Management help
    Start-Transcript Microsoft.PowerShell.Host help
    Stop-Computer Microsoft.PowerShell.Management help
    Stop-Job Microsoft.PowerShell.Core help
    Stop-Process Microsoft.PowerShell.Management help
    (别名:kill、spps)结束一个或多个正在运行的进程。

    -Force:没有提示,强制结束进程。

    -Name<String[]>:按照名称进行结束。

    -InputObject<Process[]>:结束指定 Process 对象。

    -Confirm:确认按钮。

    Stop-Service Microsoft.PowerShell.Management help
    Stop-Transcript Microsoft.PowerShell.Host help
    Suspend-Service Microsoft.PowerShell.Management help
    Tee-Object Microsoft.PowerShell.Utility help
    Test-ComputerSecureChannel Microsoft.PowerShell.Management help
    Test-Connection Microsoft.PowerShell.Management help
    Test-ModuleManifest Microsoft.PowerShell.Core help
    Test-Path Microsoft.PowerShell.Management help
    确定路径的所有元素是否存在。如果所有元素都存在,它将返回 TRUE ($true);如果缺少任一元素,则返回 FALSE ($false)。它还指示路径语法是否有效,以及路径是指向容器还是终端(叶)元素。。
    Test-WSMan Microsoft.WSMan.Management help
    Trace-Command Microsoft.PowerShell.Utility help
    Undo-Transaction Microsoft.PowerShell.Management help
    Unregister-Event Microsoft.PowerShell.Utility help
    Unregister-PSSessionConfiguration Microsoft.PowerShell.Core help
    Update-FormatData Microsoft.PowerShell.Utility help
    Update-List Microsoft.PowerShell.Utility help
    Update-TypeData Microsoft.PowerShell.Utility help
    Use-Transaction Microsoft.PowerShell.Management help
    Wait-Event Microsoft.PowerShell.Utility help
    Wait-Job Microsoft.PowerShell.Core help
    Wait-Process Microsoft.PowerShell.Management help
    Where-Object Microsoft.PowerShell.Core help

    (别名:where)Selects objects from a collection based on their property values.

    -EQ:既可以是数字的等于,也可以是字符串的相同

    -LT:既可以是数字的小于,也可以是字符串排在前面的部分

    -LE、-GT、-GE...:与上面类似

    -Contains:包含关系,例如:Get-Process | where ProcessName -contains "Svchost"

    -NotContains:不包含

    -Like:字符串匹配,例如:Get-Process | where ProcessName -like "*host"

    -NotLike:不匹配的字符串,例如:Get-Process | where ProcessName -NotLike "*host"

    -Match:字符串匹配,例如:Get-Process | where ProcessName -match "shell"

    -NotMatch:不匹配字符串,例如:Get-Process | where ProcessName -NotMatch "PowerShell"

    Write-Debug Microsoft.PowerShell.Utility help
    Write-Error Microsoft.PowerShell.Utility help
    Write-EventLog Microsoft.PowerShell.Management help
    Write-Host Microsoft.PowerShell.Utility help
    将自定义的输出内容写入主机。

    -BackgroundColor <ConsoleColor>:指定背景色。没有默认值。

    -ForegroundColor <ConsoleColor>:指定文本颜色。没有默认值。

    -NoNewline:指定在控制台中显示的内容不以换行符结束。

    -Object <Object>:要显示在控制台中的对象。

    -Separator <Object>:在控制台上所显示对象之间输出的字符串。

    Write-Output Microsoft.PowerShell.Utility help
    Write-Progress Microsoft.PowerShell.Utility help
    Write-Verbose Microsoft.PowerShell.Utility help
    Write-Warning Microsoft.PowerShell.Utility help
     

    背景色添加代码:

    ### 将表格,每隔一行换一种颜色,每行有3列,既有背景色又有边框色,每行有两种颜色
    ### 通过下面的循环,将“#ffffff”替换成“#ebeaea”
    
    $a=cat .html.txt
    $flag=0
    
    for($i=0;$i -lt $a.Count;$i++)
    {
        if($a[$i].IndexOf("#ffffff") -ne -1)
        {
            $flag++
            if($flag -le 3)
            {
                $a[$i]=$a[$i].Replace("#ffffff", "#ebeaea")
                echo $a[$i]
            }
            if($flag -eq 6)
            {
                $flag=0
            }
        }
        $a > html_new.txt
    }
    
  • 相关阅读:
    Flink的入门
    Hadoop/Spark相关面试问题总结
    什么事分布式系统
    分布式的本质
    spark的shuffle机制
    Yarn的资源隔离机制
    hadoop和spark相关参数的配置
    分布式常问问题
    转一篇分布式消息队列的文章
    jquery 重要知识点总结
  • 原文地址:https://www.cnblogs.com/alex-bn-lee/p/5056060.html
Copyright © 2020-2023  润新知