}| Select-Object -ExpandProperty PSChildNameif($Filter) {$ListofObjects| Where-Object {$_-like$Filter} }else{$ListofObjects} } 这个Get-ComObject有两个参数,一个是-Filter过虑,一个是-ListAll显示所有组件
Name Capabilities Drives --- --- --- Registry ShouldProcess, Transactions {HKLM, HKCU} Alias ShouldProcess {Alias} Environment ShouldProcess {Env} FileSystem Filter, ShouldProcess, Credentials {C, A, D} Function ShouldProcess {Function} Variable ShouldProcess {Variable} ActiveDirectory Include...
Cmdlet Clear-Content Clear-Content [-Path] <String[]> [-Filter <Strin... Cmdlet Clear-Item Clear-Item [-Path] <String[]> [-Force] [-Filter ... Cmdlet Clear-ItemProperty Clear-ItemProperty [-Path] <String[]> [-Name] <S... 这里我省略了绝大部分的显示(^^), PowerShell Version 1.0 ...
increasing performance. While it’s not always possible to filter before theWhere-Objectcmdlet, many commands provide filterable parameters. A common parameter used to filter at the beginning of the pipeline is the-Nameparameter.
选取相当于SQL中的SELECT命令。对应的PowerShell命令是Select-Object,可以简写为Select。该命令后面跟上要选取的列名即可。如果是要选取所有的列,也可以使用*表示。 代码语言:javascript 代码运行次数:0 运行 AI代码解释 $data|select Name,VM 选取所有列,那么命令就是: ...
(以GB为单位) Get-WmiObject win32_logicaldisk -Filter "deviceID='c:'" | Select-Object -Property __Server,@{n 'FreeGB ';e={$_.Freespace /1Gb -as [int]}} | Format-Table -AutoSize __SERVER FreeGB --- --- 08DC1 21 其中用于构造显示属性,第一个为__Server,第二个是自定义的FreeGB...
Where-Object 参考 反馈 模块: Microsoft.PowerShell.Core 根据集合的属性值从集合中选择对象。 语法 PowerShell Where-Object[-InputObject <PSObject>] [-Property] <String> [[-Value] <Object>] [-EQ] [<CommonParameters>] PowerShell Where-Object[-InputObject <PSObject>] [-FilterScript] <ScriptBlock...
PowerShell Kopírovat filter Get-ErrorLog ([switch]$Message) { if ($Message) { Out-Host -InputObject $_.Message } else { $_ } } Dá se použít takto:PowerShell Kopírovat Get-WinEvent -LogName System -MaxEvents 100 | Get-ErrorLog -Message Obor funkce...
Get-CimInstance -ClassName Win32_LogicalDisk -Filter "DriveType=3" | Measure-Object -Property FreeSpace,Size -Sum | Select-Object -Property Property,Sum Output 复制 Property Sum --- --- FreeSpace 109839607808 Size 326846914560 获取登录会话信息 可通过 Win32_LogonSession WMI 类获取有关与用户相...
选择这两个参数中的其中一个:具体为当你的过滤条件没有正则表达式时,使用-filter,可以显著提高效率。 注意:你不能使用filters在Dir中,列出确定大小的文件列表。因为Dir的限制条件只在文件和目录的名称级别。如果你想使用其它标准来过滤文件,可以尝试第五章中讲到的Where-Object。 下面的例子会获取你家目录下比较大的...