我無法理解如何追加或對象更新數據如何在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