内容简介:翻译自:https://stackoverflow.com/questions/36200749/how-do-you-add-more-property-values-to-a-custom-object
如果我这样做
$account = New-Object -TypeName psobject -Property @{User="Jimbo"; Password="1234"}
如何在不覆盖现有帐户的情况下向$account添加其他用户和密码值?
我无法从哈希表中预先填充$account.我不知道运行时的所有用户和密码.
如果要使用$account存储用户pwd凭据,则应将其声明为数组并在需要时添加项目:
$account = @()
$account += New-Object -TypeName psobject -Property @{User="Jimbo"; Password="1234"}
$account += New-Object -TypeName psobject -Property @{User="Jimbo2"; Password="abcd"}
$account += New-Object -TypeName psobject -Property @{User="Jimbo3"; Password="idontusepwds"}
$帐户的输出:
User Password ---- -------- Jimbo 1234 Jimbo2 abcd Jimbo3 idontusepwds
翻译自:https://stackoverflow.com/questions/36200749/how-do-you-add-more-property-values-to-a-custom-object
以上所述就是小编给大家介绍的《powershell – 如何向自定义对象添加更多属性值》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Out of Control
Kevin Kelly / Basic Books / 1995-4-14 / USD 22.95
Out of Control is a summary of what we know about self-sustaining systems, both living ones such as a tropical wetland, or an artificial one, such as a computer simulation of our planet. The last chap......一起来看看 《Out of Control》 这本书的介绍吧!