What is the easiest way to convert a PSCustomObject
to a Hashtable
? It displays just like one with the splat operator, curly braces and what appear to be key value pairs. When I try to cast it to [Hashtable]
it doesn't work. I also tried .toString()
and the assigned variable says its a string but displays nothing - any ideas?
相关问题
- How to Debug/Register a Permanent WMI Event Which
- How can I do variable substitution in a here-strin
- How to use a default value with parameter sets in
- Does powershell have a method_missing()?
- Invoking Mirth Connect CLI with Powershell script
相关文章
- 在vscode如何用code runner打开独立的控制台窗口,以及设置好调试模式时窗口的编码?
- C#调用PowerShell的问题
- EscapeDataString having differing behaviour betwee
- PowerShell Change owner of files and folders
- Command line escaping single quote for PowerShell
- Is there a simple way to pass specific *named* Pow
- How do I access an element with xpath with a names
- How to 'Grant Permissions' Using Azure Act
This works for PSCustomObjects created by ConvertFrom_Json.
Disclaimer: I barely understand PowerShell so this is probably not as clean as it could be. But it works (for one level only).
Keith already gave you the answer, this is just another way of doing the same with a one-liner:
Shouldn't be too hard. Something like this should do the trick:
my code:
Here's a version that works with nested hashtables / arrays as well (which is useful if you're trying to do this with DSC ConfigurationData):