我无法理解如何追加或对象更新数据如何在Powershell中添加/更新多深度对象?
所以可以说我有看起来像这样下面我要在架构添加到对象的架构在运行此命令
后数据的对象$testdata | Format-Custom -Property * -Depth 6
class PSCustomObject { sessions = [ class PSCustomObject { type = current generated = 2017-08-31T09:02:55.251Z windows = [ class PSCustomObject { id = 770 incognito = False tabs = [ class PSCustomObject { active = True id = 771 incognito = False title = Subscriptions - YouTube url = https://www.youtube.com/feed/subscriptions windowId = 770 } class PSCustomObject { active = False id = 776 incognito = False title = Overly Sarcastic Productions - YouTube url = https://www.youtube.com/user/RedEyesTakeWarning/videos windowId = 770 } ] } class PSCustomObject { id = 773 incognito = False tabs = [ class PSCustomObject { active = False id = 774 incognito = False title = Technology - Google News url = https://news.google.com/news/headlines/section/topic/TECHNOLOGY?ned=us&hl=en windowId = 773 } class PSCustomObject { active = False id = 806 incognito = False title = Microsoft PowerShell Is a Hot Hacker Target, But Its Defenses Are Improving | WIRED url = https://www.wired.com/story/microsoft-powershell-security/ windowId = 773 } ... ] } ] } ] }
所以可以说,我想一个新的选项卡添加到窗户与ID 和新选项卡的冠军将雅虎和网址将https://yahoo.com和ID将
我怎么会只是增加只是新进入的标签,而无需重新创建整个对象?
请退后一步,描述您尝试解决的实际问题,而不是您认为的解决方案。 –
那么通常当你追加说......就像一个数组或哈希,你使用'+ ='或'$ hash.add(something,$ something)',我不知道如何添加一个数据对象特殊的对象...因为我不能去'($ testdata.sessions.windows.Where({$ _。id -eq 770})。tabs)+ = $ newtabobject',因为这似乎不起作用,当我尝试它时,尽管它与其他选项卡对象的设置相同 – Ziabytes
如何创建'$ testdata'对象? – Persistent13