powershell - 检查哈希表是否包含值

标签 powershell process hashtable

我使用 PowerShell 执行 SQL 查询以获取计算机进程 ID 并返回以下哈希表:

$processId
5068
6176
7240
7632

现在,我使用:$processId -contains 5068检查此值是否存在于 $processId或不。

我的预期是 true但它返回 false .

我不知道为什么。欢迎大家解答。

结果 $processId |获取成员(member):

最佳答案

在哈希表上,您可以使用 ContainsKey() 检查现有项目。方法。例如:

$processId.ContainsKey(5068)

关于powershell - 检查哈希表是否包含值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49730510/

相关文章:

asp.net - 从Asp.net执行SqlPS脚本

xml - "XML is invalid"当 Get-CimInstance 与 -ComputerName 一起提供时

java - 确定从 Java 程序执行进程的运行时系统

PowerShell 哈希表双键错误 : "a" and "A"

perl - 动态解析 BibTeX 并创建哈希的哈希

Powershell:并行运行多个作业并查看来自后台作业的流式传输结果

c# - Powershell 脚本 SelectSingleNode 不工作

powershell - 使用 Powershell 哈希表键时如何避免错误匹配

java - 在 java 中获取所有 java 运行进程 PID 的热门方法?

macos - Mac 操作系统中的通信问题