Using [__ComObject] in PoSH v2

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 7 years and 4 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Using [__ComObject] in PoSH v2

Post by jvierra »

Thank you. I didn't think to try that. Good to know. I am sure others may find this helpful.

Yes V2 and earlier Net/PowerShell does not dynamically load type. My best guess is that MS PS Team decided to always load [System.__ComObject] or they have used it in PS init so it is now always loaded.

You can use [object] instead. That type works for anything and will not alter the underlying object.
This topic is 7 years and 4 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked