NOOB Q: Does the New-Object -ComObject cmdlet not respect -ErrorAction SilentlyContinue?

I'm trying to test to see if a set of COM interfaces have been registered on the system or not.  In my script I'm running the New-Object command to attempt to instantiate a COM object using the ProgID of each of the COM interfaces but I don't want errors
displayed to the screen when one of the ProgIDs isn't registered on the system.  The New-Object help says it supports the <CommonParameters> but when I attempt to use "-ErrorAction SilentlyContinue" I still get the errors displayed
in the PoSh session.
I'm running the cmdlet below and getting the error output below that.  Is this the correct way to test a set of COM interfaces or is there another option?  If this is the correct way, is there a way to run the command such that it doesn't display
an error for the COM interfaces that aren't registered?
Command:
New-Object -ComObject "myProgID" -ErrorAction SilentlyContinue
Error:
New-Object : Retrieving the COM class factory for component with CLSID {00000000-0000-0000-0000-000000000000} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 REGDB_E_CLASSNOTREG)).
At line:1 char:11
+ $comObj = New-Object -ComObject "Fake_ProgID" -ErrorAction SilentlyContinue
+           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (:) [New-Object], COMException
    + FullyQualifiedErrorId : NoCOMClassIdentified,Microsoft.PowerShell.Commands.NewObjectCommand

yep, use try / catch:
try { New-Object -ComObject "myProgID" -ErrorAction Stop } catch { "not found" }
Sam Boutros, Senior Consultant, Software Logic, KOP, PA http://superwidgets.wordpress.com (Please take a moment to Vote as Helpful and/or Mark as Answer, where applicable) _________________________________________________________________________________
Powershell: Learn it before it's an emergency http://technet.microsoft.com/en-us/scriptcenter/powershell.aspx http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx

Similar Messages

  • Why does the new iOS 7.1 not show all your calendar entry's  like 7.0 only shows daily entry's not the list. New software on iPad still shows all calender entry's

    New iOS 7.01 iPhone 5. When you go to check you calendar entry's it does not bring up all the entry's only shows entry's for each day. Why?

    When in month view, swipe up or down to change the month, tap the litle icon "three lines horizontal" next to the search icon, and you have a list view of all events. Clicking the icon twice again, brings up the Day view, and then again tapping twice the list view again....
    Personally I am not very happy with this "advanced" app, and I have installed Week calendar which basically is another interface to the same calendars database.

  • Why does the new version of Firefox not integrate with Norton 360 Identity Safe. Problem for me because I use Norton 360 Identity Safe to manage my passwords and make it more difficult to use password protected website without that add-in.

    I use Norton 360 Identity Safe to manage my passwords and it makes it difficult to use password protected website without that add-in.

    Norton release Firefox 8 compatibility already, instruction are here
    * http://community.norton.com/t5/Norton-360/Firefox-8-Support-for-Norton-Toolbar/td-p/581640

  • With PS 7  create new  Place two objects on the new file  then you may cut copy and paste Cs2  create new  place two object on the new file Cut is not available how does one cut and paste in new file

    With PS 7
    create new
    Place two objects on the new file
    then you may cut copy and paste
    Cs2
    create new
    place two object on the new file
    Cut is not available how does one cut and paste in new file

    If your using File>Place then photoshop cs2 creates what's known as Smart Objects, which photoshop 7 didn't have.
    In photoshop cs2 you can rasterize the smart objects and that should make the Cut function available.
    Select both placed layers, right click on the area to the right of the tumbnail and select Rasterize Layers.
    If in photoshop cs2 you to Help>Photoshop Help and look under Layers>Smart Objects, that should give you a good overview of what smart objects are.

  • Hep with New-Object -ComObject InternetExplorer.Application on Powershell ISE

    Hi All,
    I'm trying to  work on powershell ISE (windows 7) with New-Object -ComObject InternetExplorer.Application. My issue is that I can set a variable like this:
    $iemessage = $ie.Document.Body.InnerText
    Beacuse for some reason will be a null variable, this is the code that I'm using which do not work on ISE, but it works on the normal porwershell console
    $ie = New-Object -ComObject InternetExplorer.Application
    $ie.Navigate("http://www.microsoft.com/technet/scriptcenter/default.mspx")
    $iemessage = $ie.Document.Body.InnerText
    this is the error I get when I use $iemessage | get-member
    Get-Member : No object has been specified to the get-member cmdlet.
    Thanks in advance for any suggestion.

    Hi,
    I have no explanation for why this adjustment works (I don't do much IE automation):
    $ie = New-Object -ComObject InternetExplorer.Application
    $ie.Navigate("http://www.microsoft.com/technet/scriptcenter/default.mspx")
    Start-Sleep -Seconds 1
    $iemessage = $ie.Document.Body.InnerText
    The old adage of 'if you run out of options, just take a nap and see if the problem fixes itself' seems to have worked yet again.
    Don't retire TechNet! -
    (Don't give up yet - 13,085+ strong and growing)

  • Execute powershell command (new-object -comObject ...) in management pack

    Hello everyone
    I have a COM Object that want to use it in my management pack. When I write the powershell command "new-object -comObject ... " to create it outside of MP and in a ps1 file it works without any error. However when I write it in my MP, this
    error is showed in event viewer: "Retrieving the COM class factory for component with CLSID {clsID} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))."
    I have to mention that when I use vb script in my MP and using "CreateObject()", I don't have any problem.
    How can I use "new-object -comObject ... " in my management pack?
    thank you all
    Alireza

    Hi Marthijn,
    Actually I don't have any problem with powershell in my management packs. For example I can use "MOM.ScriptAPI"
    to create $oBag and return it to next module. My problem is only with that custom COM object. Interesting thing is that, it
    works fine when I create it in powershell file outside of MP, but when I create it in my MP, that error occures.
    thank you so much
    Alireza

  • Why does the new operating system not delete the moved files from their original location - it seems like an enormous waste of space, time and effort to clean up every file once you've moved it

    Why does the new operating system not delete the moved files from their original locations - it seems like an enormous waste of space, time and effort to clean up every file once you've moved it - also, when transferring large amounts of files it becomes a very large problem remembering which files were transferred and which not.

    You're going to need to be more specific, as I'm not quite sure I understand what you're talking about.
    If you're referring to copying from an external hard drive or flash drive, and you want to actually move files rather than copy them, you can hold down the option key to force it to do a "move" rather than a "copy." This is not new behavior, though... the Mac OS has worked this way as long as I can recall (and I've been using it since 1984).
    If you're having a problem with trying to move files from one place to another on a single drive causing them to be copied instead, that is likely because of some permissions issue preventing you from actually being able to move them.

  • Hi,,does the new 2011 imac 27 inch U.S version  support any pal signal inputs as video or hdmi through the video recorder device or kanex xd ?

    Hello,,
    I have 1 question please,,,
    does the new 2011 imac 27 inch from USA support or lay any PAL signal ??
    as for example
    I have a friend who lives in the middle east &  has kanex xd & he wants to connect it with the imac 27 inch from Satellite receiver  or PS3 though HDMI cable,, but yet the signal is PAL not NTSC in the middle east,, so will the imac 27 inch play the movie from the satellite in full colour or in blue & says cannot play the movie because its not NTCS ?  because this is U.S version  of imac then he might need an convertor?
    the same as if he want to record any hdmi or analog  device from his video recorder  device,,but the input is pal,,so will it plays normal in the U.S machine or will he find any trouble ???
    so can you pls give me an advice for him
    should he buy the imac from the U.S store or the europe store ??
    N.b : there is no mac store ONLINE in the middle east espicaly in Gulf, thats why he want to buy the imac from the mac store online,,
    and thank you

    Hello,,
    I have 1 question please,,,
    does the new 2011 imac 27 inch from USA support or lay any PAL signal ??
    as for example
    I have a friend who lives in the middle east &  has kanex xd & he wants to connect it with the imac 27 inch from Satellite receiver  or PS3 though HDMI cable,, but yet the signal is PAL not NTSC in the middle east,, so will the imac 27 inch play the movie from the satellite in full colour or in blue & says cannot play the movie because its not NTCS ?  because this is U.S version  of imac then he might need an convertor?
    the same as if he want to record any hdmi or analog  device from his video recorder  device,,but the input is pal,,so will it plays normal in the U.S machine or will he find any trouble ???
    so can you pls give me an advice for him
    should he buy the imac from the U.S store or the europe store ??
    N.b : there is no mac store ONLINE in the middle east espicaly in Gulf, thats why he want to buy the imac from the mac store online,,
    and thank you

  • Does the new airport extreme support backing up via time machine to an external hard drive pluged into the usb port

    Does the new airport extreme support backing up via time machine to an external hard drive pluged into the usb port

    Yes, but you might want to note that the port on the AirPort Extreme is only USB 2.0, and that it runs at about half the speed of the USB 2.0 port on a computer, so things are going to be quite SLOW as far as backups are concerned, or anything else for that matter.

  • Does the new iPad work with adobe flash?

    Does the new Ipad work with a version of adobe flash?  I have read several articles, and I'm just more confused than when I started!  I'm a newer Mac user, and I'm interested in the new iPad, but I don't know if I want it if it doesn't support internet pages that use adobe flash.  Thanks for your help!!

    Adobe eliminated its "mobile Flash" department.  Android, Mobile Windows, IOS, WebOS ... everyone is out of luck.

  • HT1338 I downloaded the latest Mountain Lion to my macbook 2.4 and lost my acrobat 5.0. Also, it will not reinstall. Does the new upgrade not allow Adobe Acrobat 5.0.

    I downloaded the new operating OSX Mountain Lion and now my mackbook 2.4 will no longer read or open Adobe Acrobat 5.0. I tried to re-install and it wouldn't allow it. Does the new operating system totally kill Adobe Acrobat 5.0? Is it possible to make it work and if so, how?

    You will need to wipe your drive because you cannot downgrade over a newer system. So, you'd need to have a complete backup and either your Snow Leopard install disk or a bootable clone made before upgrading to Lion. If you have the disk, insert it while holding down C key to boot off it, choose Utilities (after language selection), choose Disk Utility and choose erase. After that, the installer will automatically reinstall SL and you can use Setup Assistant to move over your files from your backup. (Note: Mail changed in Lion, so you won't be able to import it - you'd have to do it manually).
    If you have a bootable clone, it's even easier: boot with the clone, use Disk Utility to erase the drive and clone your SL system back to your internal drive.
    Depending on which route you'll decide on, we can give more detailed instructions.

  • Why does the new Itunes freeze/do nothing when i click on my Ipod touch icon ?

    Why does the new Itunes freeze when i click on my Ipod touch icon to manage my content? All buttones, video, tv, info, music, they all do nothing. i was only able to sync by bringing up the old sidebar. Is this a software glitch, or am i missing a step? I just spent two days reorganizing and labeling all my music for the new itunes, and had to restore my ipod so i could upload my new library. i know what is supposed to come up when you click on the music or info tabs, but nothing happens, only the eject button works. whats going on?

    The screen is telling you to connect the iPod to your computer with iTunes with the USB connector.  iTunes should open and give you instructions as to what to do.  Whatyou need to need to do is to restore the iPod via iTunes.

  • What does the new in Pointbase JDBC Url mean?

    what does the new in the URL mean? It is out of ServiceBus config:
    jdbc:pointbase:server://localhost:9193/weblogic_eval;new
    thanks,
    Barossa

    if the database is not exist, it will create one for you.

  • Does the new IPAD3 support the 3G in Egypt?

    does the new IPAD3 support the 3G in Egypt?

    The New iPad supports 3G world-wide wherever there is a local provider of iPad data plans and iPad micro sim cards. Read the specifications. http://www.apple.com/ipad/specs/
    So the question really is, are there 3G providers in Egypt who support the iPad?

  • Does the new ATV3 support DTS?

    Does the new ATV support DTS?

    Hi, sorry for delay in getting back, having checked the info of one of the files it shows the following.
    Apple lossless audio file
    29.2mb
    1253kbps
    44.100khz
    Stereo
    16 bit
    Encoded with itunes 11.1.0.126
    Doesnt mean much to me but hopefully it does to hou.

Maybe you are looking for

  • Striped + Mirrored software RAID no longer mounting

    I have a MacPro 4,1 using the 4 internal bays each with a 1.5GB drive. Drives 1&2 are mirrored, drives 3&4 are mirrored. Those 2 mirrored drives are then striped together for a volume called 'Titanic.' Been working great for years, but just recently

  • Email programs: Mac 2.0.7 verses Eudora for Mac???  which do you prefer

    I can get Eudora for Mac free through school. Is there any advantage to Eudora over the Mac email that came with my Powerbook? Eudora seems to have a few extra features (plus I'm familiar with it. Eudora seems a bit more complicated, but I use email

  • Why does Apple not want me to know where my files are?

    There is one aspect that I find absolutely ridiculous and frustrating on Mac-OS. When I'm in Apple applications, it is impossible to find out where the file I'm working on is. For example, I have multiple files in my system, in different directories,

  • MSI GX620 Display failed?

    Hi All, I was using my laptop earlier today and i have the laptop screen as primary display and an external LCD as secondary. For the last few days i've noticed a kind of whining / squeak coming from the laptop whenever i restart it from sleep mode.

  • Conflicting in magento

    Hi. I am trying to add an animation to a magento site. I have narrowed the issue down to a conflict with a file called prototype.js but this is an essential file for the site. In chrome in the console I am getting the messages: Uncaught TypeError: Ob