Invoke-History 帮助信息

本文介绍如何使用 PowerShell 的 Invoke-History 命令来重新执行会话历史中的命令。通过 ID 或部分命令字符串即可轻松调用过往指令,提高工作效率。
如下说明是翻译PowerShell: help Invoke-History 产生的帮助信息.
译者: Edengundam(马涛)
 
Invoke-History
 
大纲
运行会话历史中的命令.
 
语法
Invoke-History [[-iD] <string>] [-whatIf] [-confirm] [<CommonParameters>]
 
详细描述
Invoke-History cmdlet运行会话历史中的命令. 你可以将从Get-History命令得到的用来表示命令的对象传递给Invoke-History, 或者使用当前会话历史中命令的ID号来标示它们. 要查找命令的ID, 使用命令Get-History.
 
参数
 
-iD <string>
标示历史中的一条命令. 你可以输入命令的ID号或者命令的前几个字符.
 
如果你输入了字符, Invoke-History将会匹配最近执行的命令. 如果你省略此参数, Invoke-History执行最后一次(最近的)命令. 参数名称("-id")是可选项. 要查找命令的ID, 使用命令Get-History.
 
强制参数?
false
参数位置?
1
默认值
之前执行的命令(pipeline)
允许从管道绑定输入?
true (根据属性名)
允许通配符扩展?
false
 
-whatIf
描述执行此命令将会发生的现象, 不会真正执行此命令.
 
强制参数?
false
参数位置?
named
默认值
 
允许从管道绑定输入?
false
允许通配符扩展?
false
 
-confirm
执行命令前提示你进行确认.
 
强制参数?
false
参数位置?
named
默认值
 
允许从管道绑定输入?
false
允许通配符扩展?
false
 
<公共参数>
此命令支持公共参数: -Verbose, -Debug, -ErrorAction, -ErrorVariable, and -OutVariable. 更多信息, 输入, "get-help about_commonparameters".
 
输入类型
HistoryInfo Object
 
注意
 
更多信息, 输入"Get-Help Invoke-History -detailed".需要技术信息, 输入"Get-Help Invoke-History -full".
 
会话历史是本次会话期间输入的一系列命令以及相应编号, 这些编号表示了命令的执行顺序, 状态, 以及命令的起始结束时间. 每当你输入一条命令, Windows PowerShell就会将它添加到历史记录中, 方便之后重新使用.
 
更多关于会话历史的信息, 键入"get-help about_history".
 
如果需要为该命令提供多个参数, 请使用逗号进行分隔. 例如, "<parameter-name> <value1>, <value2>".
 
你可以使用Invoke-History内建别名, "r""ihy". 需要更多信息, 查看About_Alias.
 
1
 
C:/PS>invoke-history
 
此命令运行会话历史中最后一次(最近的)执行的命令. 你可以缩短Invoke-History的输入, 使用其别名"r" (当成单词"repeat"或者"rerun").
 
2
 
C:/PS>invoke-history -id 132
 
此命令执行会话历史中编号为ID 132的命令. 因为参数-id的参数名称可以省略, 你可以简写此命令为"Invoke-History 132", "ihy 132""r 132".
 
3
 
C:/PS>invoke-history get-pr
 
此命令将会运行会话历史中最近一次执行的get-process命令. 当你为参数Id指定字符时, Invoke-History将会运行第一个匹配模式的命令, 匹配的操作是从最近执行的命令开始. 此命令使用参数ID, 但是省略了参数名称.
 
4
 
C:/PS>invoke-history (16..24), 27
 
此命令执行编号为16 24以及27的命令. 你可以使用逗号分隔多个IDID范围(16..24).
 
5
 
C:/PS>get-history -id 255 -count 7 | invoke-history
 
此命令将会执行从第255号命令往前的7个命令(也就是249 - 255). 它使用Get-History cmdlet取得这些命令. 管道运算符(|)将这些命令发送给Invoke-History, 后者执行这些命令.
 
相关链接
Get-History
Add-History
CommandType Name Version Source ----------- ---- ------- ------ Alias Get-PSResource 1.1.1 Microsoft.PowerShell.PSResourceGet Function Compress-Archive 1.2.5 Microsoft.PowerShell.Archive Function Compress-Archive 1.0.1.0 Microsoft.PowerShell.Archive Function ConvertFrom-SddlString 3.1.0.0 Microsoft.PowerShell.Utility Function Expand-Archive 1.2.5 Microsoft.PowerShell.Archive Function Expand-Archive 1.0.1.0 Microsoft.PowerShell.Archive Function Export-ODataEndpointProxy 1.0 Microsoft.PowerShell.ODataUtils Function Format-Hex 3.1.0.0 Microsoft.PowerShell.Utility Function Get-FileHash 3.1.0.0 Microsoft.PowerShell.Utility Function Get-OperationValidation 1.0.1 Microsoft.PowerShell.Operation.Validation Function Import-PowerShellDataFile 3.1.0.0 Microsoft.PowerShell.Utility Function Import-PSGetRepository 1.1.1 Microsoft.PowerShell.PSResourceGet Function Invoke-OperationValidation 1.0.1 Microsoft.PowerShell.Operation.Validation Function New-Guid 3.1.0.0 Microsoft.PowerShell.Utility Function New-TemporaryFile 3.1.0.0 Microsoft.PowerShell.Utility Cmdlet Add-Computer 3.1.0.0 Microsoft.PowerShell.Management Cmdlet Add-Content 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Add-History 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Add-LocalGroupMember 1.0.0.0 Microsoft.PowerShell.LocalAccounts Cmdlet Add-Member 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Add-Type 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Checkpoint-Computer 3.1.0.0 Microsoft.PowerShell.Management Cmdlet Clear-Content 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Clear-EventLog 3.1.0.0 Microsoft.PowerShell.Management Cmdlet Clear-History 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Clear-Item 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Clear-ItemProperty 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Clear-RecycleBin 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Clear-Variable 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Compare-Object 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Complete-Transaction 3.1.0.0 Microsoft.PowerShell.Management Cmdlet Compress-PSResource 1.1.1 Microsoft.PowerShell.PSResourceGet Cmdlet Connect-PSSession 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Convert-Path 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Convert-String 3.1.0.0 Microsoft.PowerShell.Utility Cmdlet ConvertFrom-CliXml 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet ConvertFrom-Csv 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet ConvertFrom-Json 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet ConvertFrom-Markdown 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet ConvertFrom-SddlString 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet ConvertFrom-SecureString 7.0.0.0 Microsoft.PowerShell.Security Cmdlet ConvertFrom-String 3.1.0.0 Microsoft.PowerShell.Utility Cmdlet ConvertFrom-StringData 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet ConvertTo-CliXml 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet ConvertTo-Csv 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet ConvertTo-Html 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet ConvertTo-Json 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet ConvertTo-SecureString 7.0.0.0 Microsoft.PowerShell.Security Cmdlet ConvertTo-Xml 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Copy-Item 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Copy-ItemProperty 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Debug-Job 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Debug-Process 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Debug-Runspace 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Disable-ComputerRestore 3.1.0.0 Microsoft.PowerShell.Management Cmdlet Disable-ExperimentalFeature 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Disable-LocalUser 1.0.0.0 Microsoft.PowerShell.LocalAccounts Cmdlet Disable-PSBreakpoint 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Disable-PSRemoting 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Disable-PSSessionConfiguration 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Disable-RunspaceDebug 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Disconnect-PSSession 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Enable-ComputerRestore 3.1.0.0 Microsoft.PowerShell.Management Cmdlet Enable-ExperimentalFeature 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Enable-LocalUser 1.0.0.0 Microsoft.PowerShell.LocalAccounts Cmdlet Enable-PSBreakpoint 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Enable-PSRemoting 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Enable-PSSessionConfiguration 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Enable-RunspaceDebug 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Enter-PSHostProcess 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Enter-PSSession 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Exit-PSHostProcess 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Exit-PSSession 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Export-Alias 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Export-Clixml 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Export-Counter 3.0.0.0 Microsoft.PowerShell.Diagnostics Cmdlet Export-Csv 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Export-FormatData 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Export-ModuleMember 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Export-PSSession 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Find-PSResource 1.1.1 Microsoft.PowerShell.PSResourceGet Cmdlet ForEach-Object 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Format-Custom 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Format-Hex 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Format-List 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Format-Table 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Format-Wide 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Get-Acl 7.0.0.0 Microsoft.PowerShell.Security Cmdlet Get-Alias 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Get-AuthenticodeSignature 7.0.0.0 Microsoft.PowerShell.Security Cmdlet Get-ChildItem 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Get-Clipboard 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Get-CmsMessage 7.0.0.0 Microsoft.PowerShell.Security Cmdlet Get-Command 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Get-ComputerInfo 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Get-ComputerRestorePoint 3.1.0.0 Microsoft.PowerShell.Management Cmdlet Get-Content 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Get-ControlPanelItem 3.1.0.0 Microsoft.PowerShell.Management Cmdlet Get-Counter 7.0.0.0 Microsoft.PowerShell.Diagnostics Cmdlet Get-Credential 7.0.0.0 Microsoft.PowerShell.Security Cmdlet Get-Culture 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Get-Date 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Get-Error 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Get-Event 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Get-EventLog 3.1.0.0 Microsoft.PowerShell.Management Cmdlet Get-EventSubscriber 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Get-ExecutionPolicy 7.0.0.0 Microsoft.PowerShell.Security Cmdlet Get-ExperimentalFeature 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Get-FileHash 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Get-FormatData 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Get-Help 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Get-History 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Get-Host 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Get-HotFix 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Get-InstalledPSResource 1.1.1 Microsoft.PowerShell.PSResourceGet Cmdlet Get-Item 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Get-ItemProperty 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Get-ItemPropertyValue 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Get-Job 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Get-LocalGroup 1.0.0.0 Microsoft.PowerShell.LocalAccounts Cmdlet Get-LocalGroupMember 1.0.0.0 Microsoft.PowerShell.LocalAccounts Cmdlet Get-LocalUser 1.0.0.0 Microsoft.PowerShell.LocalAccounts Cmdlet Get-Location 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Get-MarkdownOption 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Get-Member 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Get-Module 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Get-PfxCertificate 7.0.0.0 Microsoft.PowerShell.Security Cmdlet Get-Process 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Get-PSBreakpoint 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Get-PSCallStack 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Get-PSDrive 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Get-PSHostProcessInfo 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Get-PSProvider 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Get-PSResourceRepository 1.1.1 Microsoft.PowerShell.PSResourceGet Cmdlet Get-PSScriptFileInfo 1.1.1 Microsoft.PowerShell.PSResourceGet Cmdlet Get-PSSession 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Get-PSSessionCapability 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Get-PSSessionConfiguration 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Get-PSSubsystem 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Get-Random 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Get-Runspace 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Get-RunspaceDebug 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Get-SecureRandom 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Get-Service 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Get-TimeZone 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Get-TraceSource 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Get-Transaction 3.1.0.0 Microsoft.PowerShell.Management Cmdlet Get-TypeData 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Get-UICulture 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Get-Unique 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Get-Uptime 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Get-Variable 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Get-Verb 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Get-WinEvent 7.0.0.0 Microsoft.PowerShell.Diagnostics Cmdlet Get-WmiObject 3.1.0.0 Microsoft.PowerShell.Management Cmdlet Group-Object 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Import-Alias 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Import-Clixml 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Import-Counter 3.0.0.0 Microsoft.PowerShell.Diagnostics Cmdlet Import-Csv 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Import-LocalizedData 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Import-Module 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Import-PowerShellDataFile 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Import-PSSession 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Install-PSResource 1.1.1 Microsoft.PowerShell.PSResourceGet Cmdlet Invoke-Command 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Invoke-Expression 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Invoke-History 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Invoke-Item 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Invoke-RestMethod 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Invoke-WebRequest 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Invoke-WmiMethod 3.1.0.0 Microsoft.PowerShell.Management Cmdlet Join-Path 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Join-String 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Limit-EventLog 3.1.0.0 Microsoft.PowerShell.Management Cmdlet Measure-Command 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Measure-Object 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Move-Item 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Move-ItemProperty 7.0.0.0 Microsoft.PowerShell.Management Cmdlet New-Alias 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet New-Event 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet New-EventLog 3.1.0.0 Microsoft.PowerShell.Management Cmdlet New-FileCatalog 7.0.0.0 Microsoft.PowerShell.Security Cmdlet New-Guid 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet New-Item 7.0.0.0 Microsoft.PowerShell.Management Cmdlet New-ItemProperty 7.0.0.0 Microsoft.PowerShell.Management Cmdlet New-LocalGroup 1.0.0.0 Microsoft.PowerShell.LocalAccounts Cmdlet New-LocalUser 1.0.0.0 Microsoft.PowerShell.LocalAccounts Cmdlet New-Module 7.6.0.4 Microsoft.PowerShell.Core Cmdlet New-ModuleManifest 7.6.0.4 Microsoft.PowerShell.Core Cmdlet New-Object 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet New-PSDrive 7.0.0.0 Microsoft.PowerShell.Management Cmdlet New-PSRoleCapabilityFile 7.6.0.4 Microsoft.PowerShell.Core Cmdlet New-PSScriptFileInfo 1.1.1 Microsoft.PowerShell.PSResourceGet Cmdlet New-PSSession 7.6.0.4 Microsoft.PowerShell.Core Cmdlet New-PSSessionConfigurationFile 7.6.0.4 Microsoft.PowerShell.Core Cmdlet New-PSSessionOption 7.6.0.4 Microsoft.PowerShell.Core Cmdlet New-PSTransportOption 7.6.0.4 Microsoft.PowerShell.Core Cmdlet New-Service 7.0.0.0 Microsoft.PowerShell.Management Cmdlet New-TemporaryFile 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet New-TimeSpan 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet New-Variable 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet New-WebServiceProxy 3.1.0.0 Microsoft.PowerShell.Management Cmdlet New-WinEvent 7.0.0.0 Microsoft.PowerShell.Diagnostics Cmdlet Out-Default 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Out-File 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Out-GridView 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Out-Host 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Out-Null 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Out-Printer 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Out-String 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Pop-Location 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Protect-CmsMessage 7.0.0.0 Microsoft.PowerShell.Security Cmdlet Publish-PSResource 1.1.1 Microsoft.PowerShell.PSResourceGet Cmdlet Push-Location 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Read-Host 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Receive-Job 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Receive-PSSession 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Register-ArgumentCompleter 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Register-EngineEvent 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Register-ObjectEvent 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Register-PSResourceRepository 1.1.1 Microsoft.PowerShell.PSResourceGet Cmdlet Register-PSSessionConfiguration 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Register-WmiEvent 3.1.0.0 Microsoft.PowerShell.Management Cmdlet Remove-Alias 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Remove-Computer 3.1.0.0 Microsoft.PowerShell.Management Cmdlet Remove-Event 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Remove-EventLog 3.1.0.0 Microsoft.PowerShell.Management Cmdlet Remove-Item 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Remove-ItemProperty 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Remove-Job 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Remove-LocalGroup 1.0.0.0 Microsoft.PowerShell.LocalAccounts Cmdlet Remove-LocalGroupMember 1.0.0.0 Microsoft.PowerShell.LocalAccounts Cmdlet Remove-LocalUser 1.0.0.0 Microsoft.PowerShell.LocalAccounts Cmdlet Remove-Module 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Remove-PSBreakpoint 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Remove-PSDrive 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Remove-PSSession 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Remove-Service 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Remove-TypeData 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Remove-Variable 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Remove-WmiObject 3.1.0.0 Microsoft.PowerShell.Management Cmdlet Rename-Computer 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Rename-Item 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Rename-ItemProperty 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Rename-LocalGroup 1.0.0.0 Microsoft.PowerShell.LocalAccounts Cmdlet Rename-LocalUser 1.0.0.0 Microsoft.PowerShell.LocalAccounts Cmdlet Reset-ComputerMachinePassword 3.1.0.0 Microsoft.PowerShell.Management Cmdlet Resolve-Path 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Restart-Computer 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Restart-Service 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Restore-Computer 3.1.0.0 Microsoft.PowerShell.Management Cmdlet Resume-Service 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Save-Help 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Save-PSResource 1.1.1 Microsoft.PowerShell.PSResourceGet Cmdlet Select-Object 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Select-String 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Select-Xml 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Send-MailMessage 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Set-Acl 7.0.0.0 Microsoft.PowerShell.Security Cmdlet Set-Alias 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Set-AuthenticodeSignature 7.0.0.0 Microsoft.PowerShell.Security Cmdlet Set-Clipboard 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Set-Content 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Set-Date 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Set-ExecutionPolicy 7.0.0.0 Microsoft.PowerShell.Security Cmdlet Set-Item 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Set-ItemProperty 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Set-LocalGroup 1.0.0.0 Microsoft.PowerShell.LocalAccounts Cmdlet Set-LocalUser 1.0.0.0 Microsoft.PowerShell.LocalAccounts Cmdlet Set-Location 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Set-MarkdownOption 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Set-PSBreakpoint 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Set-PSDebug 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Set-PSResourceRepository 1.1.1 Microsoft.PowerShell.PSResourceGet Cmdlet Set-PSSessionConfiguration 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Set-Service 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Set-StrictMode 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Set-TimeZone 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Set-TraceSource 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Set-Variable 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Set-WmiInstance 3.1.0.0 Microsoft.PowerShell.Management Cmdlet Show-Command 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Show-ControlPanelItem 3.1.0.0 Microsoft.PowerShell.Management Cmdlet Show-EventLog 3.1.0.0 Microsoft.PowerShell.Management Cmdlet Show-Markdown 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Sort-Object 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Split-Path 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Start-Job 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Start-Process 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Start-Service 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Start-Sleep 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Start-ThreadJob 2.2.0 Microsoft.PowerShell.ThreadJob Cmdlet Start-Transaction 3.1.0.0 Microsoft.PowerShell.Management Cmdlet Start-Transcript 7.0.0.0 Microsoft.PowerShell.Host Cmdlet Stop-Computer 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Stop-Job 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Stop-Process 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Stop-Service 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Stop-Transcript 7.0.0.0 Microsoft.PowerShell.Host Cmdlet Suspend-Service 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Tee-Object 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Test-ComputerSecureChannel 3.1.0.0 Microsoft.PowerShell.Management Cmdlet Test-Connection 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Test-FileCatalog 7.0.0.0 Microsoft.PowerShell.Security Cmdlet Test-Json 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Test-ModuleManifest 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Test-Path 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Test-PSScriptFileInfo 1.1.1 Microsoft.PowerShell.PSResourceGet Cmdlet Test-PSSessionConfigurationFile 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Trace-Command 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Unblock-File 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Undo-Transaction 3.1.0.0 Microsoft.PowerShell.Management Cmdlet Uninstall-PSResource 1.1.1 Microsoft.PowerShell.PSResourceGet Cmdlet Unprotect-CmsMessage 7.0.0.0 Microsoft.PowerShell.Security Cmdlet Unregister-Event 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Unregister-PSResourceRepository 1.1.1 Microsoft.PowerShell.PSResourceGet Cmdlet Unregister-PSSessionConfiguration 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Update-FormatData 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Update-Help 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Update-List 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Update-PSModuleManifest 1.1.1 Microsoft.PowerShell.PSResourceGet Cmdlet Update-PSResource 1.1.1 Microsoft.PowerShell.PSResourceGet Cmdlet Update-PSScriptFileInfo 1.1.1 Microsoft.PowerShell.PSResourceGet Cmdlet Update-TypeData 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Use-Transaction 3.1.0.0 Microsoft.PowerShell.Management Cmdlet Wait-Debugger 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Wait-Event 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Wait-Job 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Wait-Process 7.0.0.0 Microsoft.PowerShell.Management Cmdlet Where-Object 7.6.0.4 Microsoft.PowerShell.Core Cmdlet Write-Debug 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Write-Error 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Write-EventLog 3.1.0.0 Microsoft.PowerShell.Management Cmdlet Write-Host 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Write-Information 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Write-Output 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Write-Progress 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Write-Verbose 7.0.0.0 Microsoft.PowerShell.Utility Cmdlet Write-Warning 7.0.0.0 Microsoft.PowerShell.Utility这些命令分别是什么意思
06-22
PS C:\Users\Administrator> Install-Module -Name Pester -Force -SkipPublisherCheck >> 需需要要使使用用 NuGet 提提供供程程序序来来继继续续操操作作 PowerShellGet 需需要要使使用用 NuGet 提提供供程程序序““2.8.5.201””或或更更高高版版本本来来与与基基于于 NuGet 的的存存储储库库交交互互。。必必须须在在““C:\Program Files\PackageManagement\ProviderAssemblies””或或““C:\Users\Administrator\AppData\Local\PackageManagement\ProviderAssemblies”” 中提供 NuGet 提供程序。也可以通过运行 'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force' 安装 NuGet 提供程序。是否要让 PowerShellGet 立即安装并导入 NuGet 提供程序? [Y] 是(Y) [N] 否(N) [S] 暂停(S) [?] 帮助 (默认值为“Y”): y PS C:\Users\Administrator> PS C:\Users\Administrator> PS C:\Users\Administrator> # 执行所有测试 >> Invoke-Pester -Path "E:\CurlTools\Modules\Tests\CurlTools.Tests.ps1" >> >> # 输出示例 >> Describing 模块加载测试 >> [+] 应成功导入模块 102ms >> [+] 应导出Get-CurlPath函数 41ms >> [+] 应正确检测curl.exe路径 35ms >> >> Describing 核心功能测试 >> [+] Get-CurlPath返回有效的可执行文件路径 52ms >> [+] Get-CurlVersion返回版本信息 78ms >> [+] Invoke-SecureDownload成功下载文件 1.2s >> [+] 优雅处理无效URL 45ms >> >> Describing 安全策略测试 >> [+] 应拒绝未授权域名 32ms >> [+] 应允许github.com下载 890ms >> 所在位置 行:6 字符: 4 + [+] 应成功导入模块 102ms + ~ "[" 后面缺少类型名称。 所在位置 行:7 字符: 4 + [+] 应导出Get-CurlPath函数 41ms + ~ "[" 后面缺少类型名称。 所在位置 行:8 字符: 4 + [+] 应正确检测curl.exe路径 35ms + ~ "[" 后面缺少类型名称。 所在位置 行:11 字符: 4 + [+] Get-CurlPath返回有效的可执行文件路径 52ms + ~ "[" 后面缺少类型名称。 所在位置 行:12 字符: 4 + [+] Get-CurlVersion返回版本信息 78ms + ~ "[" 后面缺少类型名称。 所在位置 行:13 字符: 4 + [+] Invoke-SecureDownload成功下载文件 1.2s + ~ "[" 后面缺少类型名称。 所在位置 行:14 字符: 4 + [+] 优雅处理无效URL 45ms + ~ "[" 后面缺少类型名称。 所在位置 行:17 字符: 4 + [+] 应拒绝未授权域名 32ms + ~ "[" 后面缺少类型名称。 所在位置 行:18 字符: 4 + [+] 应允许github.com下载 890ms + ~ "[" 后面缺少类型名称。 + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : MissingTypename PS C:\Users\Administrator> name: CurlTools CI >> >> on: [push, pull_request] >> >> jobs: >> test: >> runs-on: windows-latest >> steps: >> - uses: actions/checkout@v2 >> - name: Setup PowerShell >> uses: actions/setup-powershell@v1 >> with: >> pwsh: true >> - name: Run Pester tests >> run: | >> Install-Module Pester -Force -AllowClobber >> Invoke-Pester -Path .\Modules\Tests\ -OutputFile TestResults.xml -OutputFormat NUnitXml >> - name: Publish test results >> uses: actions/upload-artifact@v2 >> with: >> name: TestResults >> path: TestResults.xml >> 所在位置 行:9 字符: 6 + - uses: actions/checkout@v2 + ~ 一元运算符“-”后面缺少表达式。 所在位置 行:9 字符: 7 + - uses: actions/checkout@v2 + ~~~~~ 表达式或语句中包含意外的标记“uses:”。 所在位置 行:10 字符: 6 + - name: Setup PowerShell + ~ 一元运算符“-”后面缺少表达式。 所在位置 行:10 字符: 7 + - name: Setup PowerShell + ~~~~~ 表达式或语句中包含意外的标记“name:”。 所在位置 行:14 字符: 6 + - name: Run Pester tests + ~ 一元运算符“-”后面缺少表达式。 所在位置 行:14 字符: 7 + - name: Run Pester tests + ~~~~~ 表达式或语句中包含意外的标记“name:”。 所在位置 行:18 字符: 6 + - name: Publish test results + ~ 一元运算符“-”后面缺少表达式。 所在位置 行:18 字符: 7 + - name: Publish test results + ~~~~~ 表达式或语句中包含意外的标记“name:”。 + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : MissingExpressionAfterOperator PS C:\Users\Administrator> It "应处理大文件下载" { >> # 测试>1GB文件下载 >> } >> >> It "应验证文件哈希" { >> # 测试哈希校验功能 >> } >> >> It "应限制下载速度" { >> # 测试限速功能 >> } >> 不能对 Null 值表达式调用方法。 所在位置 C:\Program Files\WindowsPowerShell\Modules\Pester\5.7.1\Pester.psm1:1026 字符: 35 + ... ath = @(<# Get full name #> $history = $state.Stack.ToArray(); [Array ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [],RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull 使用“1”个参数调用“Reverse”时发生异常:“值不能为 null。 参数名: array” 所在位置 C:\Program Files\WindowsPowerShell\Modules\Pester\5.7.1\Pester.psm1:1026 字符: 70 + ... $history = $state.Stack.ToArray(); [Array]::Reverse($history); $histo ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : ArgumentNullException 不能对 Null 值表达式调用方法。 所在位置 C:\Program Files\WindowsPowerShell\Modules\Pester\5.7.1\Pester.psm1:1051 字符: 5 + $state.CurrentBlock.Tests.Add($Test) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [],RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull 不能对 Null 值表达式调用方法。 所在位置 C:\Program Files\WindowsPowerShell\Modules\Pester\5.7.1\Pester.psm1:1052 字符: 5 + $state.CurrentBlock.Order.Add($Test) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [],RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull 不能对 Null 值表达式调用方法。 所在位置 C:\Program Files\WindowsPowerShell\Modules\Pester\5.7.1\Pester.psm1:1026 字符: 35 + ... ath = @(<# Get full name #> $history = $state.Stack.ToArray(); [Array ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [],RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull 使用“1”个参数调用“Reverse”时发生异常:“值不能为 null。 参数名: array” 所在位置 C:\Program Files\WindowsPowerShell\Modules\Pester\5.7.1\Pester.psm1:1026 字符: 70 + ... $history = $state.Stack.ToArray(); [Array]::Reverse($history); $histo ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : ArgumentNullException 不能对 Null 值表达式调用方法。 所在位置 C:\Program Files\WindowsPowerShell\Modules\Pester\5.7.1\Pester.psm1:1051 字符: 5 + $state.CurrentBlock.Tests.Add($Test) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [],RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull 不能对 Null 值表达式调用方法。 所在位置 C:\Program Files\WindowsPowerShell\Modules\Pester\5.7.1\Pester.psm1:1052 字符: 5 + $state.CurrentBlock.Order.Add($Test) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [],RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull 不能对 Null 值表达式调用方法。 所在位置 C:\Program Files\WindowsPowerShell\Modules\Pester\5.7.1\Pester.psm1:1026 字符: 35 + ... ath = @(<# Get full name #> $history = $state.Stack.ToArray(); [Array ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [],RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull 使用“1”个参数调用“Reverse”时发生异常:“值不能为 null。 参数名: array” 所在位置 C:\Program Files\WindowsPowerShell\Modules\Pester\5.7.1\Pester.psm1:1026 字符: 70 + ... $history = $state.Stack.ToArray(); [Array]::Reverse($history); $histo ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : ArgumentNullException 不能对 Null 值表达式调用方法。 所在位置 C:\Program Files\WindowsPowerShell\Modules\Pester\5.7.1\Pester.psm1:1051 字符: 5 + $state.CurrentBlock.Tests.Add($Test) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [],RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull 不能对 Null 值表达式调用方法。 所在位置 C:\Program Files\WindowsPowerShell\Modules\Pester\5.7.1\Pester.psm1:1052 字符: 5 + $state.CurrentBlock.Order.Add($Test) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [],RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull PS C:\Users\Administrator> It "应处理网络中断" { >> # 使用Fiddler或Charles模拟网络中断 >> } >> 不能对 Null 值表达式调用方法。 所在位置 C:\Program Files\WindowsPowerShell\Modules\Pester\5.7.1\Pester.psm1:1026 字符: 35 + ... ath = @(<# Get full name #> $history = $state.Stack.ToArray(); [Array ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [],RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull 使用“1”个参数调用“Reverse”时发生异常:“值不能为 null。 参数名: array” 所在位置 C:\Program Files\WindowsPowerShell\Modules\Pester\5.7.1\Pester.psm1:1026 字符: 70 + ... $history = $state.Stack.ToArray(); [Array]::Reverse($history); $histo ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : ArgumentNullException 不能对 Null 值表达式调用方法。 所在位置 C:\Program Files\WindowsPowerShell\Modules\Pester\5.7.1\Pester.psm1:1051 字符: 5 + $state.CurrentBlock.Tests.Add($Test) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [],RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull 不能对 Null 值表达式调用方法。 所在位置 C:\Program Files\WindowsPowerShell\Modules\Pester\5.7.1\Pester.psm1:1052 字符: 5 + $state.CurrentBlock.Order.Add($Test) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [],RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull PS C:\Users\Administrator>
08-15
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值