Page 1 of 1 1
Topic Options
#209685 - 2014-11-27 01:17 PM WMI variable - How to export to text file
Krynhells Offline
Just in Town

Registered: 2014-11-27
Posts: 1
Loc: US
I have the following script that works, however, need to export the value of the variable "$objItem.State" but I can not. The result appears on the screen but is not exported. Can anyone help?


; Query and display running processes
$objWMIService = GetObject( "winmgmts://./root/cimv2" )
; Display error number and description if applicable
If $Err.Number
ShowErr()
EndIf

; Collect information on services
$colItems = $objWMIService.ExecQuery( "Select * from Win32_Service Where Name='AMPAgent'", , 48 )

; Display results
For Each $objItem in $colItems
? "Name: " + $objItem.Name
? "DisplayName: " + $objItem.DisplayName
? "PathName: " + $objItem.PathName
? "StartMode: " + $objItem.StartMode
? "State: " + $objItem.State
? "StartName: " + $objItem.StartName
?
Next

If RedirectOutput("\\server\folder$\KACE\@wksta.txt")=0

;
; Create file
;

@wksta + "|" + @userid + "|" + @fullname + "|" + @ipaddress0 + "|" +@PRODUCTTYPE + "|" + $objItem.State + "|" ?




Edited by Krynhells (2014-11-27 01:49 PM)

Top
#209686 - 2014-11-27 07:22 PM Re: WMI variable - How to export to text file [Re: Krynhells]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
It isn't inside the loop. $objitem isn't object outside that loop
_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (mole) and 2107 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.028 seconds in which 0.012 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org