Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

Using a WMI string array in Powershell

Closed Thread
 
Thread Tools Display Modes
Old 01-11-2007   #1 (permalink)
GordT.
Guest


 

Using a WMI string array in Powershell

I can successfully retried remote eventlog entries using Get-WMIObject, but I
can't figure out how to parse through the InsertionStrings array (a string
array according to MSDN library at
http://msdn2.microsoft.com/en-us/library/aa394226.aspx)

This command:
get-wmiobjet -computername REMOTEHOST -query "select * from win32_ntlogevent
where logfile = 'Secuirty'" |select-object InsertionStrings | format-table $_

will return:
InsertionStrings
----------------
{NETWORK SERVICE, NT AUTHORITY, (0x0,0x3E4), SeAuditPrivilege...
{NETWORK SERVICE, NT AUTHORITY, (0x0,0x3E4), 5...}
etc.

But, how do I then parse out individual string entries?

I tried piping using: select-object InsertionStrings | format-table $_[1]
to get the second item, but receive the error:
"Cannot index into a null array"

I've tried several other methods as well, but can't seem to figure this one
out, so I'm hoping someone can help me out...

Thanks in advance...

--
GordT. (CISSP, GCIH, GEEK)
Old 01-11-2007   #2 (permalink)
Brandon Shell
Guest


 

Re: Using a WMI string array in Powershell

Im not really sure what your goal is... but you can do this:

$entries = get-wmiobject -computername nybba0bps1 -query "select * from
win32_ntlogevent where logfile = 'Security'" |select-object InsertionStrings
foreach($entry in $entries){
# For Property 1
$entry.InsertionStrings[0]
# For Property 2
$entry.InsertionStrings[1]
# and so on and so on
}

or
$entries = get-wmiobject -computername nybba0bps1 -query "select * from
win32_ntlogevent where logfile = 'Security'" |select-object InsertionStrings
$entries[0].InsertionStrings[0] # for a specific entry

--

Brandon Shell
---------------
Stop by my blog some time
http://mybsinfo.blogspot.com/
----------------------------------

"GordT." <GordT@discussions.microsoft.com> wrote in message
news:7D32B781-F69F-4029-812F-1E7332287034@microsoft.com...
>I can successfully retried remote eventlog entries using Get-WMIObject, but
>I
> can't figure out how to parse through the InsertionStrings array (a string
> array according to MSDN library at
> http://msdn2.microsoft.com/en-us/library/aa394226.aspx)
>
> This command:
> get-wmiobjet -computername REMOTEHOST -query "select * from
> win32_ntlogevent
> where logfile = 'Secuirty'" |select-object InsertionStrings | format-table
> $_
>
> will return:
> InsertionStrings
> ----------------
> {NETWORK SERVICE, NT AUTHORITY, (0x0,0x3E4), SeAuditPrivilege...
> {NETWORK SERVICE, NT AUTHORITY, (0x0,0x3E4), 5...}
> etc.
>
> But, how do I then parse out individual string entries?
>
> I tried piping using: select-object InsertionStrings | format-table $_[1]
> to get the second item, but receive the error:
> "Cannot index into a null array"
>
> I've tried several other methods as well, but can't seem to figure this
> one
> out, so I'm hoping someone can help me out...
>
> Thanks in advance...
>
> --
> GordT. (CISSP, GCIH, GEEK)


Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Read Byte Array into String for Delimiting? coconet .NET General 3 05-24-2008 02:35 AM
Passing a string array as a parameter from one script to another Brillig PowerShell 5 09-27-2007 04:16 AM
convert array of strings to string Hal Rottenberg PowerShell 16 08-30-2007 02:30 PM
Difference between string and array Flomo Togba Kwele PowerShell 6 05-04-2007 12:38 PM
String to Array Singee PowerShell 3 05-31-2006 11:58 AM








Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50