以下示例按照 Get-Verb 属性对 的结果进行了排序。 PowerShell 复制 Get-Verb | Sort-Object -Property Verb 通过Group 属性,可以了解动词的使用方式。 Output 复制 Verb Group ---- ----- Add Common Approve Lifecycle Assert Lifecycle Backup Dat
$property= @{ Name ='TotalSpaceGB'Expression = { ($_.Used +$_.Free) /1GB } } CmdletName會為該數據行加上標籤。Expression是執行的腳本區塊,其中$_是管道上 物件的值。 以下是作用中的文稿: PowerShell $drives=Get-PSDrive| where Used$drives|Select-Object-PropertyName,$propertyName TotalSpaceGB...
(Get-Service).Count Output 176 如果单个对象和集合上都存在属性,则仅返回集合的属性。 PowerShell PS>$collection= @( [pscustomobject]@{Length ="foo"} [pscustomobject]@{Length ="bar"} )# PowerShell returns the collection's Length.$collection.Length2# Get the length property of each item in...
PS> $p.GetEnumerator() | Sort-Object -Property Value -Descending Name Value --- --- PowerShell System.Diagnostics.Process (pwsh) Notepad System.Diagnostics.Process (Notepad) Hash2 {[b, 2], [c, 3], [a, 1]} WinRM Running 从哈希表创建对象 从PowerShell 3.0 开始,可以从属性和属性值...
Example 1: Get the value of the ProductID property This command gets the value of theProductIDproperty of the\SOFTWARE\Microsoft\Windows NT\CurrentVersionobject in the Windows Registry provider. PowerShell Get-ItemPropertyValue'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion'-NameProductID94253-5000...
cmdlet 的Select-Object参数选择进程名称。 这会向每个ProcessName实例添加一个[System.Diagnostics.ProcessModule],并使用当前进程的processName属性的值填充它。 最后,Format-Listcmdlet 用于显示列表中每个进程的名称和模块。 PowerShell Get-ProcessExplorer |Select-Object-PropertyProcessName-ExpandPropertyModules |Format...
或者,我们可以在 InputObject 参数中嵌入命令。 PowerShell 复制 Format-Table -InputObject (Get-Service) -Property Name, DependentServices 但是,有一个重要区别。 将多个对象通过管道传递给命令时,PowerShell 一次将对象发送到该命令。 使用命令参数时,对象将作为单个数组对象发送。 这种细微差异具有重大后果。
Fix Get-ItemProperty to report non-terminating error for cast exception (#21115) (Thanks @ArmaanMcleod!) Add -PropertyType argument completer for New-ItemProperty (#21117) (Thanks @ArmaanMcleod!) Fix a bug in how Write-Host handles XmlNode object (#24669) (Thanks @brendandburns!) Code Cl...
类型: Object Position: Named 默认值: None 必需: False 接受管道输入: True 接受通配符: False-Certificate指定用于安全 Web 请求的客户端证书。 输入一个包含证书的变量,或可获取该证书的命令或表达式。 若要查找证书,请使用 Get-PfxCertificate 或使用 Certificate (Get-ChildItem) 驱动器中的 Cert: cmdlet。
Fix Get-ItemProperty to report non-terminating error for cast exception (#21115) (Thanks @ArmaanMcleod!) Add -PropertyType argument completer for New-ItemProperty (#21117) (Thanks @ArmaanMcleod!) Fix a bug in how Write-Host handles XmlNode object (#24669) (Thanks @brendandburns!) Code Cl...