Where-Object 参考 反馈 模块: Microsoft.PowerShell.Core 根据集合的属性值从集合中选择对象。 语法 PowerShell Where-Object[-InputObject <PSObject>] [-Property] <String> [[-Value] <Object>] [-EQ] [<CommonParameters>] PowerShell Where-Object[-InputObject <PSObject>] [-FilterScript] <ScriptBlock...
Where-Object 篩選這就是 Where-Object 派上用場的地方,因此我們可以根據物件的屬性來篩選和選取我們想要從陣列中取得的內容。PowerShell 複製 PS> $data | Where-Object {$_.FirstName -eq 'Kevin'} FirstName LastName --- --- Kevin Marquette 我們可以...
# 配置磁盘为 RAID 1 $disk1 = Get-PhysicalDisk -CanPool $true | Where-Object { $_.MediaType -eq "HDD" } | Select-Object -First 1 $disk2 = Get-PhysicalDisk -CanPool $true | Where-Object { $_.MediaType -eq "HDD" } | Select-Object -First 1 New-StoragePool -FriendlyName "RAID...
Get-NetConnectionProfile|Where-Object{$_.IsWired-eq$True} 这个命令过滤出所有有线连接,并显示它们的相关信息。 Get-NetConnectionProfile提供了网络连接的各种信息,并且通过Select-Object和Where-Object等命令可以灵活地筛选和展示所需的字段。它对于网络管理、故障排除以及网络配置监控非常有用。
Get-Service|Where-ObjectCanPauseAndContinue-EQ$true|Select-Object-Property* Output Name : LanmanWorkstation RequiredServices : {NSI, MRxSmb20, Bowser} CanPauseAndContinue : True CanShutdown : False CanStop : True DisplayName : Workstation DependentServices : {SessionEnv, Netlogon} MachineName :...
Equals Method bool Equals(System.Object obj), bool Equals(int obj) GetHashCode Method int GetHashCode() GetType Method type GetType() GetTypeCode Method System.TypeCode GetTypeCode() ToString Method string ToString(), string ToString(string format), string ToString(System.IFormatProvider provider.....
3af22fd4-3ade-4c0d-ab67-7c77cf08223aUI:System.Management.Automation.Internal.Host.InternalHostUserInterfaceCurrentCulture:zh-CNCurrentUICulture:zh-CNPrivateData:Microsoft.PowerShell.ConsoleHost+ConsoleColorProxyDebuggerEnabled:TrueIsRunspacePushed:FalseRunspace:System.Management.Automation.Runspaces.LocalRunspace...
PSC:\Users\WeiyiGeek>Get-Help gettype*PSC:\Users\WeiyiGeek>$var=1024;$var.gettype()IsPublic IsSerial Name BaseType---True True Int32 System.ValueType New-Variable 描述:以在定义变量时指定变量的一些其它属性,比如访问权限描述; 变量的选项是一个枚举值包含: “None”...
大多数对象都有属性。 属性是与对象关联的数据。 不同类型的对象具有不同的属性。 例如,表示文件的FileInfo对象具有IsReadOnly属性,如果文件具有只读属性,$False则包含$True;如果该文件没有只读属性,则包含 。 表示文件系统目录的DirectoryInfo对象具有Parent属性,该属性包含父目录的路径。
类型比较运算符(-is 和-isnot)用于确定对象是否是特定类型。 语法: PowerShell 复制 <object> -is <type-reference> <object> -isnot <type-reference> 示例: PowerShell 复制 $a = 1 $b = "1" $a -is [int] # Output: True $a -is $b.GetType() # Output: False $b -isnot [int] ...