Link to home
Start Free TrialLog in
Avatar of Jason Tenpenny
Jason TenpennyFlag for United States of America

asked on

Get-Object or equivalent command

I'm working with some software and I'm needing to create a new COM object. I have a powershell script that uses "New-Object -ComObject" with all the settings to create this object. My question is how I can determine if this script has already been run. I have seen some articles refer to a Get-Object command, but Windows doesn't recognize that command. Is there any way I can see if I have already created this object on a specific machine?
Avatar of David Sankovsky
David Sankovsky
Flag of Israel image

I don't see a Get-Object CMDLET on technet, but searching CMDLETs that are related to New-Object, I came across this one:
Select-Object. Perhaps it can help your cause.
you could try this :

$test = New-Object Psobject -Property @{  Testprop = "" }
if (($test | gm | select -exp name) -contains 'testprop' ) {"true"}
else { "false" }

Open in new window


reference : https://social.technet.microsoft.com/Forums/windowsserver/en-US/843e2734-d96f-4ce4-96d5-7b5a00b85eb9/check-object-property-existance?forum=winserverpowershell
change it to meet your needs as I don't know your object names.
ASKER CERTIFIED SOLUTION
Avatar of Jason Tenpenny
Jason Tenpenny
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Jason, If any of the question above helped you in the right direction, Please assign points as you see fit,
if you arrived on the solution completely on your own, that's great too, But please don't leave the question open, close it.
I'm glad that you resolved your issue though.
Avatar of Jason Tenpenny

ASKER

I've tried a couple of times to mark my own comment as the answer, but I keep getting an error every time.
I've open a request to a moderator, he should be able to assist.