使用Where-Object进行过滤,例如:Where-Object { $_.Name -like "Local*" }。 使用Select-Object选择需要的属性,例如:Select-Object DeviceID, FreeSpace, Size。 4. 示例 powershellCopy Code # 获取操作系统信息Get-WmiObject-ClassWin32_OperatingSystem# 获取网络适配器信息Get-WmiObject-ClassWin32_NetworkAdapter...
示例命令:Get-WMIObject -Class Win32_OperatingSystem -ComputerName "RemoteComputer" 过滤结果:可以使用Where-Object命令来过滤获取的WMI对象,只返回符合条件的对象。 示例命令:Get-WMIObject -Class Win32_Processor | Where-Object {$_.Name -like "Intel*"} 腾讯云提供了一系列云计算相关的产品,可以帮助用户在...
$cpuInfo = Get-WmiObject -Class Win32_Processor $cpuUsage = Get-WmiObject -Class Win32_PerfFormattedData_PerfOS_Processor | Where-Object {$_.Name -eq "_Total"} | Select-Object -ExpandProperty PercentProcessorTime Write-Host "CPU信息:" Write-Host "制造商:" $cpuInfo.Manufacturer Write-Host "型...
$strClass="usbhub"Get-WmiObject -List | Where-Object {$_.Name -like "*$strClass*"} | ForEach-Object `-Begin{Write-Host "$strclass wmi listing"; Start-Sleep 3} `-process {Get-WmiObject $_.name} `-End { process 转载 精选 676386173 2015-04-29 16:38:32 577阅读 power...
PowerShell:Get-CimInstance -ClassName Win32_DiskDrive | Select-Object -Property Model 获取操作系统信息: WMIC:wmic os get caption PowerShell:Get-CimInstance -ClassName Win32_OperatingSystem | Select-Object -Property Caption 总结 随着WMIC的弃用,Get-CimInstance和Get-WmiObject成为了在PowerShell中进行WMI查询...
指定要用作筛选器的Where子句。 使用 WMI 查询语言(WQL)的语法。 重要 不要在参数的值中包含Where关键字。 例如,以下命令仅返回DeviceID为“c:”的逻辑磁盘,以及名称为“WinRM”的服务,而不使用Where关键字。 Get-WmiObject Win32_LogicalDisk -filter "DeviceID = 'c:' " ...
Where-Object { $_."PCI\VEN_10DE*"} Should be the same as your first example: Where-Object { $_.PNPDeviceID -like "PCI\VEN_10DE*"} As for how you can approach the code with an if / else statement: if((Get-CimInstance -Class CIM_VideoController).PNPDeviceID -li...
Get-WmiObject Win32_GroupUser –Computer PlaceYourComputerNameHere | <# Now, you have all users #>Where-Object {$_.GroupComponent –like'*"Administrators"'} | <# Now, you have all Administrators #>Where-Object {$_.PartComponent –match".+Domain\=""(.+)"",Name\=(.+)$"} | <# ...
is returned after adding a where-object filter. "Get-EventLog: Attempted to perform an unauthorized operation" - why?? "Get-WmiObject not supported" when using WmiMonitorID class "make sure that the assembly containing this type is loaded" disagnostic "Register this connection's addresses in...
Get-WmiObject -ComputerName DC -Class Win32_OperatingSystem | Select-Object -Property *I can now see a property called Caption that lets me know the version of Windows.PS> (Get-WmiObject -ComputerName DC -Class Win32_OperatingSystem | Select-Object -Property *).Caption Microsoft Windows ...