iamtheky Posted December 30, 2015 Posted December 30, 2015 (edited) Dumps QFE and I massage it into a valid Neo4j Create statement that looks flowchart-esque. And it leaves it on your clipboard ready to be pasted.***Its proably huge so you may want to make two changes in the bottom loop while testingFor $i = 1 to 10 ; ubound($aFinal) - 1 ;<--- And when reducing this number For $c = 2 to ubound($aFinal , 2) - 1 $sOutStr &= "(" & $aFinal[$i][3] & $i & $c & ":" & $aFinal[0][$c] & "{name: '" & $aFinal[$i][$c] & "'})," & @LF If $c = 2 Then $sRelationships &= "(" & $aFinal[$i][3] & $i & $c & ")-[:Is_" & $aFinal[0][$c] & "]->(" & $aFinal[$i][3] & $i & $c + 1 & ")," & @LF If $c = 4 Then $sRelationships &= "(" & $aFinal[$i][3] & $i & $c - 1 & ")-[:Is_" & $aFinal[0][$c] & "]->(" & $aFinal[$i][3] & $i & $c & ")," & @LF If $c = 5 AND $i < 10 ; <----put the same one here expandcollapse popup#include<array.au3> $iPid = run('powershell Get-CimInstance -ClassName Win32_QuickFixEngineering -property * | Format-Table' , @WindowsDir , @SW_HIDE , 0x2) $sOutput = "" While 1 $sOutput &= StdoutRead($iPID) If @error Then ExitLoop EndIf WEnd ;~ msgbox(0, '' , $sOutput) $aOutput = stringsplit($sOutput , @LF , 2) For $i = 0 to ubound($aOutput) - 1 $aOutput[$i] = stringregexpreplace(stringstripws($aOutput[$i] , 3) , "\s\s+" , ",") $aOutput[$i] = stringreplace($aOutput[$i] , "_..." , ",") $aOutput[$i] = stringreplace($aOutput[$i] , "\" , "_") $aOutput[$i] = ",," & $aOutput[$i] Next _ArrayDelete($aOutput , 2) _ArrayDelete($aOutput , 0) ;~ _ArrayDisplay($aOutput) $aLine = stringsplit($aOutput[1] , "," , 2) local $aFinal[0][ubound($aLine)] ;~ _ArrayDisplay($aFinal , "declared final") for $i = 0 to ubound($aOutput) - 1 If $aOutput[$i] = "" Then ContinueLoop If $i = 0 Then $aLine = stringsplit(stringtrimleft($aOutput[$i] , 1) , "," , 2) Else $aLine = stringsplit($aOutput[$i] , "," , 2) EndIf ;~ _ArrayDisplay($aLine) _ArrayTranspose($aLine) ;~ _ArrayDisplay($aLine , "Line Transposed") _ArrayConcatenate($aFinal , $aLine) ;~ _ArrayDisplay($aFinal , "Final with line added") Next ;~ _ArrayDisplay($aFinal) $sOutStr = "" $sRelationships = "" For $i = 1 to ubound($aFinal) - 1 For $c = 2 to ubound($aFinal , 2) - 1 $sOutStr &= "(" & $aFinal[$i][3] & $i & $c & ":" & $aFinal[0][$c] & "{name: '" & $aFinal[$i][$c] & "'})," & @LF If $c = 2 Then $sRelationships &= "(" & $aFinal[$i][3] & $i & $c & ")-[:Is_" & $aFinal[0][$c] & "]->(" & $aFinal[$i][3] & $i & $c + 1 & ")," & @LF If $c = 4 Then $sRelationships &= "(" & $aFinal[$i][3] & $i & $c - 1 & ")-[:Is_" & $aFinal[0][$c] & "]->(" & $aFinal[$i][3] & $i & $c & ")," & @LF If $c = 5 AND $i < ubound($aFinal) - 1 Then $sRelationships &= "(" & $aFinal[$i][3] & $i & $c - 2 & ")-[:Is_Followed_By]->(" & $aFinal[$i + 1][3] & $i + 1 & 3 & ")," & @LF If $c = 5 Then $sRelationships &= "(" & $aFinal[$i][3] & $i & $c - 2 & ")-[:Is_" & $aFinal[0][$c] & "]->(" & $aFinal[$i][3] & $i & $c & ")," & @LF Next Next ClipPut("Create" & @LF & $sOutStr & stringtrimright($sRelationships , 1)) Edited December 30, 2015 by iamtheky ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
iamtheky Posted December 30, 2015 Author Posted December 30, 2015 (edited) Edited January 20, 2016 by iamtheky ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
iamtheky Posted January 2, 2016 Author Posted January 2, 2016 (edited) How to group all "Security Update" items together while maintaining existing relationships expandcollapse popup#include<array.au3> $iPid = run('powershell Get-CimInstance -ClassName Win32_QuickFixEngineering -property * | Format-Table' , @WindowsDir , @SW_HIDE , 0x2) $sOutput = "" While 1 $sOutput &= StdoutRead($iPID) If @error Then ExitLoop EndIf WEnd ;~ msgbox(0, 'string out' , $sOutput) $aOutput = stringsplit($sOutput , @LF , 2) ;~ _ArrayDisplay($aOutput , "just split") For $i = 0 to ubound($aOutput) - 1 $aOutput[$i] = stringregexpreplace(stringstripws($aOutput[$i] , 3) , "\s\s+" , ",") $aOutput[$i] = stringreplace($aOutput[$i] , "_..." , ",") $aOutput[$i] = stringreplace($aOutput[$i] , "\" , "_") $aOutput[$i] = ",," & $aOutput[$i] Next _ArrayDelete($aOutput , 2) _ArrayDelete($aOutput , 0) ;~ _ArrayDisplay($aOutput, "frmt list") $aLine = stringsplit($aOutput[1] , "," , 2) local $aFinal[0][ubound($aLine)] ;~ _ArrayDisplay($aFinal , "declared final") for $i = 0 to ubound($aOutput) - 1 If $aOutput[$i] = "" Then ContinueLoop If $i = 0 Then $aLine = stringsplit(stringtrimleft($aOutput[$i] , 1) , "," , 2) Else $aLine = stringsplit($aOutput[$i] , "," , 2) EndIf ;~ _ArrayDisplay($aLine) _ArrayTranspose($aLine) ;~ _ArrayDisplay($aLine , "Line Transposed") _ArrayConcatenate($aFinal , $aLine) ;~ _ArrayDisplay($aFinal , "Final with line added") Next ;~ _ArrayDisplay($aFinal) $sOutStr = "" $sRelationships = "" $SecUpdateFlag = 0 For $i = 1 to 10 ; ubound($aFinal) - 1 For $c = 2 to ubound($aFinal , 2) - 1 If $c = 2 And stringstripws($aFinal[$i][$c] , 3) = "Security Update" And $SecUpdateFlag = 0 Then $sOutStr &= "(" & $aFinal[$i][3] & $i & $c & ":" & $aFinal[0][$c] & "{name: '" & $aFinal[$i][$c] & "'})," & @LF $sSecUpdate = $aFinal[$i][3] & $i & $c $SecUpdateFlag = 1 $sRelationships &= "(" & $sSecUpdate & ")-[:Is_" & $aFinal[0][$c] & "]->(" & $aFinal[$i][3] & $i & $c + 1 & ")," & @LF ElseIf $c = 2 And stringstripws($aFinal[$i][$c] , 3) And $SecUpdateFlag = 1 Then $sRelationships &= "(" & $sSecUpdate & ")-[:Is_" & $aFinal[0][$c] & "]->(" & $aFinal[$i][3] & $i & $c + 1 & ")," & @LF ElseIf $c = 2 And stringstripws($aFinal[$i][$c] , 3) <> "Security Update" Then $sOutStr &= "(" & $aFinal[$i][3] & $i & $c & ":" & $aFinal[0][$c] & "{name: '" & $aFinal[$i][$c] & "'})," & @LF $sRelationships &= "(" & $aFinal[$i][3] & $i & $c & ")-[:Is_" & $aFinal[0][$c] & "]->(" & $aFinal[$i][3] & $i & $c + 1 & ")," & @LF Else $sOutStr &= "(" & $aFinal[$i][3] & $i & $c & ":" & $aFinal[0][$c] & "{name: '" & $aFinal[$i][$c] & "'})," & @LF If $c = 4 Then $sRelationships &= "(" & $aFinal[$i][3] & $i & $c - 1 & ")-[:Is_" & $aFinal[0][$c] & "]->(" & $aFinal[$i][3] & $i & $c & ")," & @LF If $c = 5 AND $i < 10 Then $sRelationships &= "(" & $aFinal[$i][3] & $i & $c - 2 & ")-[:Is_Followed_By]->(" & $aFinal[$i + 1][3] & $i + 1 & 3 & ")," & @LF If $c = 5 Then $sRelationships &= "(" & $aFinal[$i][3] & $i & $c - 2 & ")-[:Is_" & $aFinal[0][$c] & "]->(" & $aFinal[$i][3] & $i & $c & ")," & @LF EndIf Next Next ClipPut("Create" & @LF & $sOutStr & stringtrimright($sRelationships , 1)) ;~ ConsoleWrite("Create" & @LF & $sOutStr & stringtrimright($sRelationships , 1)) Edited January 4, 2016 by iamtheky image removal ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
iamtheky Posted January 11, 2016 Author Posted January 11, 2016 (edited) still playing with this one, output of win32_addremoveprograms to a Cypher statement that organizes nodes by publisher. Also makes the manipulating of the powershell out a little more manageable. expandcollapse popup#include<array.au3> $iPid = run('powershell Get-WmiObject -class win32reg_addremoveprograms | select ProdID,DisplayName,Publisher' , @WindowsDir , @SW_HIDE , 0x2) $sOutput = "" While 1 $sOutput &= StdoutRead($iPID) If @error Then ExitLoop EndIf WEnd ;~ msgbox(0, 'string out' , $sOutput) $aOutput = stringsplit($sOutput , @LF , 2) ;~ _ArrayDisplay($aOutput , "just split") For $i = ubound($aOutput) - 1 to 0 step -1 $aOutput[$i] = stringregexpreplace(stringstripws($aOutput[$i] , 3) , "\s\s+" , ",") $aOutput[$i] = stringreplace($aOutput[$i] , "... " , ",") $aOutput[$i] = stringreplace($aOutput[$i] , "\" , "_") $aOutput[$i] = stringreplace($aOutput[$i] , "-" , "_") $aOutput[$i] = stringreplace($aOutput[$i] , " " , "_") $aOutput[$i] = stringreplace($aOutput[$i] , "." , "_") $aOutput[$i] = stringreplace($aOutput[$i] , "(" , "_") $aOutput[$i] = stringreplace($aOutput[$i] , ")" , "_") $aOutput[$i] = stringreplace($aOutput[$i] , "{" , "_") $aOutput[$i] = stringreplace($aOutput[$i] , "}" , "_") $aOutput[$i] = stringreplace($aOutput[$i] , "+" , "plus") $aOutput[$i] = stringreplace($aOutput[$i] , "7_zip" , "_7_zip") Next _ArrayDelete($aOutput , 0) _ArrayDelete($aOutput , 0) _ArrayDelete($aOutput , 0) _ArrayDelete($aOutput , ubound($aOutput) - 1) _ArrayDelete($aOutput , ubound($aOutput) - 1) _ArrayDelete($aOutput , ubound($aOutput) - 1) ;~ _ArrayDisplay($aOutput, "frmt list") $aLine = stringsplit($aOutput[1] , "," , 2) local $aFinal[0][ubound($aLine)] ;~ _ArrayDisplay($aFinal , "declared final") for $i = 0 to ubound($aOutput) - 1 $aLine = stringsplit($aOutput[$i] , "," , 2) ;~ _ArrayDisplay($aLine) _ArrayTranspose($aLine) ;~ _ArrayDisplay($aLine , "Line Transposed") _ArrayConcatenate($aFinal , $aLine) ;~ _ArrayDisplay($aFinal , "Final with line added") Next ;~ _ArrayDisplay($aFinal) $sOutStr = "" $sRelationships = "" local $aPubCheck[0] For $i = 1 to ubound($aFinal) - 1 For $c = 0 to ubound($aFinal , 2) - 2 If $c = 0 then $iSearch = _ArraySearch($aPubCheck , stringstripws($aFinal[$i][2] , 8)) If @Error Then _ArrayAdd($aPubCheck , stringstripws($aFinal[$i][2] , 8)) $sPublisher = stringstripws($aFinal[$i][2] , 8) $sOutStr &= "(" & $sPublisher & ":" & $aFinal[$i][2] & "{name: '" & $aFinal[$i][2] & "'})," & @LF Else $sPublisher = $aPubCheck[$iSearch] EndIf $sOutStr &= "(" & $sPublisher & $i & $c & ":" & $aFinal[$i][1] & "{name: '" & $aFinal[$i][1] & "'," & "ProdID: '" & $aFinal[$i][$c] & "'})," & @LF $sRelationships &= "(" & $sPublisher & ")-[:Is_Publisher" & "]->(" & $sPublisher & $i & $c & ")," & @LF EndIf Next Next ClipPut("Create" & @LF & $sOutStr & stringtrimright($sRelationships , 2)) ;~ ConsoleWrite("Create" & @LF & $sOutStr & stringtrimright($sRelationships , 1)) Edited January 11, 2016 by iamtheky ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
iamtheky Posted January 20, 2016 Author Posted January 20, 2016 (edited) added my QFE with secondary sort by the 'security update' description to the graphgist challenge. I had been meaning to explore Git, and Gist seems like an approachable platform for hanging scripts without being cumbersome. the gist: https://gist.github.com/iamtheky/c5b15d03237f4474d000 the graphgist challenge, which also executes the create statement in browser: http://portal.graphgist.org/graph_gists/b655a1f6-8103-4a68-bb1f-1a8cc38ef1c3 Edited January 20, 2016 by iamtheky ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
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