您可以在使用Select-Object指定屬性名稱時使用通配符。 在下列範例中,使用Can*做為 Property參數的其中一個值,以傳回以Can開頭的所有屬性。其中包括 CanPauseAndContinue、CanShutdown和CanStop。 PowerShell Get-Service-Namew32time |Select-Object-PropertyStatus, DisplayName, Can* ...
Get-Service-Namew32time |Select-Object-PropertyStatus, DisplayName, Can* 请注意,列出的属性比默认显示的属性多。 Output Status : Running DisplayName : Windows Time CanPauseAndContinue : False CanShutdown : True CanStop : True 方法 方法是可以对对象执行的操作。使用 MemberType参数缩小以仅显示方法Get...
Windows PowerShell 3.0 包含現有 Cmdlet (包括簡化語法) 的新功能,以及下列 Cmdlet 的新參數:Computer Cmdlet、CSV Cmdlet、Get-ChildItem、Get-Command、Get-Content、Get-History、Measure-Object、Security Cmdlet、Select-Object、Select-String、Split-Path、Start-Process、Tee-Object、Test-Connection、Add-Member ...
New-Module-NameMyModule-ScriptBlock{functionReturn-MrOsVersion{Get-CimInstance-ClassNameWin32_OperatingSystem |Select-Object-Property@{label='OperatingSystem';expression={$_.Caption}} }Export-ModuleMember-FunctionReturn-MrOsVersion} |Import-Module ...
Get-Process winlogon | Format-List -Property * 还可以通过管道将本机命令的输出传递给 PowerShell cmdlet。 例如: PowerShell 复制 PS> ipconfig.exe | Select-String -Pattern 'IPv4' IPv4 Address. . . . . . . . . . . : 172.24.80.1 IPv4 Address. . . . . . . . . . . : 192.168...
Add -PropertyType argument completer for New-ItemProperty (#21117) (Thanks @ArmaanMcleod!) Fix a bug in how Write-Host handles XmlNode object (#24669) (Thanks @brendandburns!) Code Cleanup We thank the following contributors! @xtqqczze Seal ClientRemoteSessionDSHandlerImpl (#21218) (Thanks...
Get-Service-Namew32time |Select-Object-PropertyStatus, DisplayName, Can* Output Status : Running DisplayName : Windows Time CanPauseAndContinue : False CanShutdown : True CanStop : True 在上一個範例中,Can*用來做為 Property參數的其中一個值,以傳回以Can開頭的所有屬性。其中包括 CanPauseAndContinu...
Get-WinEvent -Path 'C:\Tracing\TraceLog.etl' -Oldest | Sort-Object -Property TimeCreated -Descending | Select-Object -First 100 Get-WinEvent cmdlet 从存档文件获取日志信息。 Path 参数指定目录和文件名。 Oldest 参数用于按事件写入的顺序输出事件,从最早到最新。 将对象沿管道向下发送到 Sort-Object ...
此命令使用ConvertTo-Json和ConvertFrom-Jsoncmdlet 将cmdlet 中的Get-Date对象转换为 JSON 对象,然后转换为PSCustomObject。 PowerShell Get-Date|Select-Object-Property* |ConvertTo-Json|ConvertFrom-JsonDisplayHint :2DateTime : Monday, January29,20243:10:26PM Date :1/29/202412:00:00AM Day :29DayOfWeek...
Add -PropertyType argument completer for New-ItemProperty (#21117) (Thanks @ArmaanMcleod!) Fix a bug in how Write-Host handles XmlNode object (#24669) (Thanks @brendandburns!) Code Cleanup We thank the following contributors! @xtqqczze Seal ClientRemoteSessionDSHandlerImpl (#21218) (Thanks...