RC86 Posted August 1, 2017 Share Posted August 1, 2017 Hi! First post - go easy! I'm using the Scriptomatic tool that SvenP created based on the Microsoft tool and I'm just a bit unsure about how to use the output as I wish. expandcollapse popupFunc _getMemory() $logSection = "Memory" $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $Output = "" $Output = $Output & "Computer: " & $strComputer & @CRLF $Output = $Output & "==========================================" & @CRLF $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\ROOT\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_PerfFormattedData_PerfOS_Memory", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems $Output = $Output & "AvailableBytes: " & $objItem.AvailableBytes & @CRLF $Output = $Output & "AvailableKBytes: " & $objItem.AvailableKBytes & @CRLF $Output = $Output & "AvailableMBytes: " & $objItem.AvailableMBytes & @CRLF $Output = $Output & "CacheBytes: " & $objItem.CacheBytes & @CRLF $Output = $Output & "CacheBytesPeak: " & $objItem.CacheBytesPeak & @CRLF $Output = $Output & "CacheFaultsPersec: " & $objItem.CacheFaultsPersec & @CRLF $Output = $Output & "Caption: " & $objItem.Caption & @CRLF $Output = $Output & "CommitLimit: " & $objItem.CommitLimit & @CRLF $Output = $Output & "CommittedBytes: " & $objItem.CommittedBytes & @CRLF $Output = $Output & "DemandZeroFaultsPersec: " & $objItem.DemandZeroFaultsPersec & @CRLF $Output = $Output & "Description: " & $objItem.Description & @CRLF $Output = $Output & "FreeAndZeroPageListBytes: " & $objItem.FreeAndZeroPageListBytes & @CRLF $Output = $Output & "FreeSystemPageTableEntries: " & $objItem.FreeSystemPageTableEntries & @CRLF $Output = $Output & "Frequency_Object: " & $objItem.Frequency_Object & @CRLF $Output = $Output & "Frequency_PerfTime: " & $objItem.Frequency_PerfTime & @CRLF $Output = $Output & "Frequency_Sys100NS: " & $objItem.Frequency_Sys100NS & @CRLF $Output = $Output & "LongTermAverageStandbyCacheLifetimes: " & $objItem.LongTermAverageStandbyCacheLifetimes & @CRLF $Output = $Output & "ModifiedPageListBytes: " & $objItem.ModifiedPageListBytes & @CRLF $Output = $Output & "Name: " & $objItem.Name & @CRLF $Output = $Output & "PageFaultsPersec: " & $objItem.PageFaultsPersec & @CRLF $Output = $Output & "PageReadsPersec: " & $objItem.PageReadsPersec & @CRLF $Output = $Output & "PagesInputPersec: " & $objItem.PagesInputPersec & @CRLF $Output = $Output & "PagesOutputPersec: " & $objItem.PagesOutputPersec & @CRLF $Output = $Output & "PagesPersec: " & $objItem.PagesPersec & @CRLF $Output = $Output & "PageWritesPersec: " & $objItem.PageWritesPersec & @CRLF $Output = $Output & "PercentCommittedBytesInUse: " & $objItem.PercentCommittedBytesInUse & @CRLF $Output = $Output & "PoolNonpagedAllocs: " & $objItem.PoolNonpagedAllocs & @CRLF $Output = $Output & "PoolNonpagedBytes: " & $objItem.PoolNonpagedBytes & @CRLF $Output = $Output & "PoolPagedAllocs: " & $objItem.PoolPagedAllocs & @CRLF $Output = $Output & "PoolPagedBytes: " & $objItem.PoolPagedBytes & @CRLF $Output = $Output & "PoolPagedResidentBytes: " & $objItem.PoolPagedResidentBytes & @CRLF $Output = $Output & "StandbyCacheCoreBytes: " & $objItem.StandbyCacheCoreBytes & @CRLF $Output = $Output & "StandbyCacheNormalPriorityBytes: " & $objItem.StandbyCacheNormalPriorityBytes & @CRLF $Output = $Output & "StandbyCacheReserveBytes: " & $objItem.StandbyCacheReserveBytes & @CRLF $Output = $Output & "SystemCacheResidentBytes: " & $objItem.SystemCacheResidentBytes & @CRLF $Output = $Output & "SystemCodeResidentBytes: " & $objItem.SystemCodeResidentBytes & @CRLF $Output = $Output & "SystemCodeTotalBytes: " & $objItem.SystemCodeTotalBytes & @CRLF $Output = $Output & "SystemDriverResidentBytes: " & $objItem.SystemDriverResidentBytes & @CRLF $Output = $Output & "SystemDriverTotalBytes: " & $objItem.SystemDriverTotalBytes & @CRLF $Output = $Output & "Timestamp_Object: " & $objItem.Timestamp_Object & @CRLF $Output = $Output & "Timestamp_PerfTime: " & $objItem.Timestamp_PerfTime & @CRLF $Output = $Output & "Timestamp_Sys100NS: " & $objItem.Timestamp_Sys100NS & @CRLF $Output = $Output & "TransitionFaultsPersec: " & $objItem.TransitionFaultsPersec & @CRLF $Output = $Output & "TransitionPagesRePurposedPersec: " & $objItem.TransitionPagesRePurposedPersec & @CRLF $Output = $Output & "WriteCopiesPersec: " & $objItem.WriteCopiesPersec & @CRLF ;if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop Next _Log($Output) ;_writeCSV($Output) $Output = "" Else MsgBox(0, "WMI Output", "No WMI Objects Found for class: " & "Win32_PerfFormattedData_PerfOS_Memory") EndIf I'm querying WMI for some performance data and as you can see I can write this info to a log file just fine as a string, but ideally I'd like to be able to see this info in an array. If $colItems is the array how can I see this, I've tried using _ArrayDisplay but no luck. I think I'm missing something or not quite understanding too well. Thanks! Link to comment Share on other sites More sharing options...
water Posted August 1, 2017 Share Posted August 1, 2017 $Output isn't an array, it's a string. You would need to create the array yourself. StringSplit would be my candidate. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
RC86 Posted August 1, 2017 Author Share Posted August 1, 2017 1 minute ago, water said: $Output isn't an array, it's a string. You would need to create the array yourself. StringSplit would be my candidate. Thanks, so you'd get it into a string then from there into an array? I did try initially to get each of the lines into an array but it wasn't particularly dynamic and meant a lot of editing. Ideally I'd like to find out how to query the object like with a count of the items in that object or something but I can't find any way of querying it. Link to comment Share on other sites More sharing options...
water Posted August 1, 2017 Share Posted August 1, 2017 IIRC $colItems.Count returns the number of items in the collection. RC86 1 My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
RC86 Posted August 1, 2017 Author Share Posted August 1, 2017 4 minutes ago, water said: IIRC $colItems.Count returns the number of items in the collection. OK thanks, I'll give it a go - i've read that I can't use $wbemFlagForwardOnly if I want to do anything with the object like count. THanks for your help! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now