RE: Powershell PSCustomObject

2012-06-05 Thread Joseph L. Casale
That would be affirmative:)

From: Michael B. Smith [mich...@smithcons.com]
Sent: Tuesday, June 05, 2012 5:17 AM
To: NT System Admin Issues
Subject: RE: Powershell PSCustomObject

Not a programmer, huh? :-)

You can do this with filters, but it wouldn't be any easier.
~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to listmana...@lyris.sunbeltsoftware.com
with the body: unsubscribe ntsysadmin



RE: Powershell PSCustomObject

2012-06-05 Thread Michael B. Smith
Not a programmer, huh? :-)

You can do this with filters, but it wouldn't be any easier.

-Original Message-
From: Joseph L. Casale [mailto:jcas...@activenetwerx.com] 
Sent: Monday, June 04, 2012 10:44 PM
To: NT System Admin Issues
Subject: RE: Powershell PSCustomObject

Well this was by no means obvious:

Foreach ($Line in $Config)
{
Foreach ($Entry in $Line.psobject.properties)
{
If ($Entry.Value -eq $null)
{
Return $False
}
}
}

jlc

From: Joseph L. Casale [jcas...@activenetwerx.com]
Sent: Monday, June 04, 2012 7:45 PM
To: NT System Admin Issues
Subject: RE: Powershell PSCustomObject

Sorry Michael,

$Config = Import-Csv -Path somefile.csv

The csv may look like:
"A","B","C","D"
"foo","bar","biz","baz"
"foo","bar","baz"

So I should expect to a see a NoteProperty for A,B,C and D on both lines but 
testing for $Config[0].A through D etc is tedious and if the CSV file is 
expanded the test has to be updated.
This is certainly easier with a hash...

Thanks!
jlc
~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ 
<http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to listmana...@lyris.sunbeltsoftware.com
with the body: unsubscribe ntsysadmin


~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to listmana...@lyris.sunbeltsoftware.com
with the body: unsubscribe ntsysadmin



RE: Powershell PSCustomObject

2012-06-04 Thread Joseph L. Casale
Well this was by no means obvious:

Foreach ($Line in $Config)
{
Foreach ($Entry in $Line.psobject.properties)
{
If ($Entry.Value -eq $null)
{
Return $False
}
}
}

jlc

From: Joseph L. Casale [jcas...@activenetwerx.com]
Sent: Monday, June 04, 2012 7:45 PM
To: NT System Admin Issues
Subject: RE: Powershell PSCustomObject

Sorry Michael,

$Config = Import-Csv -Path somefile.csv

The csv may look like:
"A","B","C","D"
"foo","bar","biz","baz"
"foo","bar","baz"

So I should expect to a see a NoteProperty for A,B,C and D on both lines but 
testing for $Config[0].A through D etc is tedious and if the CSV file is 
expanded the test has to be updated.
This is certainly easier with a hash...

Thanks!
jlc
~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to listmana...@lyris.sunbeltsoftware.com
with the body: unsubscribe ntsysadmin



RE: Powershell PSCustomObject

2012-06-04 Thread Joseph L. Casale
Sorry Michael,

$Config = Import-Csv -Path somefile.csv

The csv may look like:
"A","B","C","D"
"foo","bar","biz","baz"
"foo","bar","baz"

So I should expect to a see a NoteProperty for A,B,C and D on both lines but 
testing for $Config[0].A through D etc is tedious and if the CSV file is 
expanded the test has to be updated.
This is certainly easier with a hash...

Thanks!
jlc

From: Michael B. Smith [mich...@smithcons.com]
Sent: Monday, June 04, 2012 7:24 PM
To: NT System Admin Issues
Subject: RE: Powershell PSCustomObject

Well then perhaps you should provide a more substantive example. :-P
~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to listmana...@lyris.sunbeltsoftware.com
with the body: unsubscribe ntsysadmin



RE: Powershell PSCustomObject

2012-06-04 Thread Michael B. Smith
Well then perhaps you should provide a more substantive example. :-P

-Original Message-
From: Joseph L. Casale [mailto:jcas...@activenetwerx.com] 
Sent: Monday, June 04, 2012 9:03 PM
To: NT System Admin Issues
Subject: RE: Powershell PSCustomObject

Hrm,
I must be doing something wrong then.

If I call out the individual item and test it works:

If ($obj."foo" -eq $null) { "bail" }

I gather the method you show tests if the entire psobject is null, whereas if 
only one of the NoteProperty are empty, it won't fail the test?

Thanks!
jlc

From: Michael B. Smith [mich...@smithcons.com]
Sent: Monday, June 04, 2012 6:09 PM
To: NT System Admin Issues
Subject: RE: Powershell PSCustomObject

$obj |? { $_ -ne $null } | ...
~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ 
<http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to listmana...@lyris.sunbeltsoftware.com
with the body: unsubscribe ntsysadmin


~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to listmana...@lyris.sunbeltsoftware.com
with the body: unsubscribe ntsysadmin



RE: Powershell PSCustomObject

2012-06-04 Thread Joseph L. Casale
Hrm,
I must be doing something wrong then.

If I call out the individual item and test it works:

If ($obj."foo" -eq $null) { "bail" }

I gather the method you show tests if the entire psobject is null, whereas if 
only one of the NoteProperty are empty, it won't fail the test?

Thanks!
jlc

From: Michael B. Smith [mich...@smithcons.com]
Sent: Monday, June 04, 2012 6:09 PM
To: NT System Admin Issues
Subject: RE: Powershell PSCustomObject

$obj |? { $_ -ne $null } | ...
~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to listmana...@lyris.sunbeltsoftware.com
with the body: unsubscribe ntsysadmin



RE: Powershell PSCustomObject

2012-06-04 Thread Michael B. Smith
$obj |? { $_ -ne $null } | ...

-Original Message-
From: Joseph L. Casale [mailto:jcas...@activenetwerx.com] 
Sent: Monday, June 04, 2012 8:04 PM
To: NT System Admin Issues
Subject: Powershell PSCustomObject

How does one iterate through all values in a  PSCustomObject? For example, if 
you import a csv, then iterate through the resulting array, each element is a 
PSCustomObject and you can access each element by name (the header in the csv) 
but how do you blindly iterate them all to test for a null value for example?
Thanks!
jlc
~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ 
  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to listmana...@lyris.sunbeltsoftware.com
with the body: unsubscribe ntsysadmin


~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~   ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to listmana...@lyris.sunbeltsoftware.com
with the body: unsubscribe ntsysadmin