AnnoUS Posted November 5, 2017 Share Posted November 5, 2017 Hey, i would like to write a script to get Informations from my Win7 and write it to an csv File, but i dont know a few thinks. Would be really happy if you could help me. Here are my script who doesent work. There i want to have the name, size and free space on the Drive, but it doesnt work. $oWMI = ObjGet('winmgmts:\\' & @ComputerName & '\root\cimv2'); If (IsObj($oWMI)) And (not @error) Then $cItems = $oWMI.ExecQuery('SELECT * FROM Win32_LogicalDisk') For $oItem In $cItems $tDrive = $oItem.Name & '|' & $oItem.Size & '|' & $oItem.FreeSpace Next ConsoleWrite($tDrive) Endif Other point, id like to see when my OS was installed, but i dont now how i can edit the date Format. $oWMI = ObjGet('winmgmts:\\' & @ComputerName & '\root\cimv2'); If (IsObj($oWMI)) And (not @error) Then $cItems = $oWMI.ExecQuery('Select * from Win32_OperatingSystem') For $oItem In $cItems $tOSDate = $oItem.InstallDate Next ConsoleWrite($tOSDate) Endif Next, i want to have all users and there permissions, but this script only tells what users are existing. Local $colUsers, $tUser, $Array[1] = ["user"] $colUsers = ObjGet("WinNT://" & @ComputerName) If IsObj($colUsers) Then $colUsers.Filter = $Array For $objUser In $colUsers $tUser &= $objUser.Name & "|" Next EndIf Also i want to have a list of all installed printers in my system. $oWMI = ObjGet('winmgmts:\\' & @ComputerName & '\root\cimv2'); If (IsObj($oWMI)) And (not @error) Then $cItems = $oWMI.ExecQuery('Select * from Win32_Printer') For $oItem In $cItems $tPrinter = $oItem.Name Next ConsoleWrite($tPrinter) Endif Last i want to have the networkadapters for lan and if excisting wlan and the ip, subnet, gateway and dns. I was get all this informations about the powershell but doesent know how to get it in autoit, thanks. Link to comment Share on other sites More sharing options...
kylomas Posted November 6, 2017 Share Posted November 6, 2017 AnnoUS, This will get you started. There are plenty of examples of the user and network stuff in the forum. You did not specify how you wanted the CSV file formatted so I took my best guess... expandcollapse popup; added fileopen routine ; added file write after each routine ; declared variables used for accumulation ; changed from assignment (=) to concatenation (&=) for accumulation variables ; added date formatting routine Local $hfl = FileOpen(@ScriptDir & '\sysinfo.csv', 2) If $hfl = -1 Then Exit MsgBox(17, 'Error', 'Output file faled to open') $oWMI = ObjGet('winmgmts:\\' & @ComputerName & '\root\cimv2') ; If (IsObj($oWMI)) And (Not @error) Then $cItems = $oWMI.ExecQuery('SELECT * FROM Win32_LogicalDisk') Local $tdrive For $oItem In $cItems $tdrive &= $oItem.Name & ',' & $oItem.Size & ',' & $oItem.FreeSpace & @CRLF Next ConsoleWrite($tdrive) FileWrite($hfl, $tdrive) EndIf $oWMI = ObjGet('winmgmts:\\' & @ComputerName & '\root\cimv2') ; If (IsObj($oWMI)) And (Not @error) Then $cItems = $oWMI.ExecQuery('Select * from Win32_OperatingSystem') Local $tOSDate For $oItem In $cItems $tOSDate &= CNVTDate($oItem.InstallDate) & @CRLF Next ConsoleWrite($tOSDate) FileWrite($hfl, $tOSDate) EndIf $oWMI = ObjGet('winmgmts:\\' & @ComputerName & '\root\cimv2') ; If (IsObj($oWMI)) And (Not @error) Then $cItems = $oWMI.ExecQuery('Select * from Win32_Printer') Local $tprinter For $oItem In $cItems $tprinter &= $oItem.Name & ',' Next ConsoleWrite($tprinter) FileWrite($hfl, $tprinter) EndIf FileClose($hfl) Func CNVTDate($dtmDate) ; reformat date to mm/dd/yyyy hh:mm:ss and zero fill single digit values Return StringRegExpReplace(StringRegExpReplace($dtmDate, '(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2}).*', '$2/$3/$1 $4:$5:$6'), '(?<!\d)(\d/)', '0$1') EndFunc ;==>CNVTDate kylomas AnnoUS 1 Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
iamtheky Posted November 6, 2017 Share Posted November 6, 2017 (edited) You can search for my stuff in powershell if you want to do it that way, but its the same object calls but slower. I still havent cleaned this up, but auditshot has a nice template for gathering info into an excel spreadsheet. (commenting those lines, and _ArrayToString with comma delimeters would be just as well). Edited November 6, 2017 by iamtheky AnnoUS 1 ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) 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