使用管道或其他类型的内联表示法,我希望“选择”哈希表中的某些值,直到结果,同时更改或设置其他值。
哈希表
我从哈希表开始(坦率地说,哈希表被用作对象),如下所示:
>$hash
Name Value
---- -----
System server-1
Job Microsoft.PowerShell.Commands.PSWmiJob
Result
是否有一种方法可以使用(或类似的东西)来设置某些属性的值并传递其他属性?最后我想说的是:
>$hash
Name
想象一下下面的散列:
$h=@{}
$h.Add(1,'a')
$h.Add(2,'b')
$h.Add(3,'c')
$h.Add(4,'d')
$h.Add(5,'a')
$h.Add(6,'c')
什么查询会返回两个重复的值'a‘和'c’?
基本上,我正在寻找以下SQL查询的powershell等效项(假设表h(c1,c2):
select c1
from h
group by c1
having count(*) > 1
我编写了一个PowerShell函数来创建一个自定义对象并将其存储到一个哈希表中。我面临的问题是检索那个对象。我需要检索该对象,因为它包含一个数组,我需要遍历该数组并将其写入文本文件。
function removeItem {
<#Madatory Parameters for function, it takes the path to the files/folders
to clean up and path to the hashtable.#>
Param([Parameter(Mandatory=$True)]
[string]
目前,我正在研究PowerShell中的哈希表,并了解到变量可以用作键和值。到目前为止,我已经创建了一个哈希表,并希望了解如何在另一个哈希表中嵌套该哈希表。下面是我正在做的事情的信息:
我创建了一个名为$avatar的哈希表。其中包括键"Episode 1"、"Episode 2"、"Episode 3"等,以及每集的名称作为值。
$avatar = [ordered]@{
"Episode 1" = "The Boy in the Iceberg";
"Episode 2"
我有一个脚本,接受最多3个参数-用户名,密码和发行版。
这个脚本需要作为管理员运行,因为它检查某些东西是启用的,并且只能作为管理员执行。
# the command line is:
# linux-docker <username> <password> <distro>
# if no distro is specified then Debian is used.
param ([Parameter(Mandatory)]$username, [Parameter(Mandatory)]$password, $distro='Debian