chiners_68 Posted June 4, 2007 Share Posted June 4, 2007 has anyone wrote a script to do this or something that could be modified to do this that they would like to share..? Link to comment Share on other sites More sharing options...
ksmith247 Posted June 4, 2007 Share Posted June 4, 2007 has anyone wrote a script to do this or something that could be modified to do this that they would like to share..?Are you wanting to select a particular machine to shutdown or wanting to target a list of devices? Have you looked at psshutdown from Microsoft? It's free and is pretty simple to use. Support bacteria; it's the only culture most people have.LxP's Learning to Script with AutoIt 3 - Excellent starting placeVolly's Links Page - Links to cool and useful scriptsAutoIt Wrappers - Valuater's AutoIt Wrappers post. Lots of good stuff.Support AutoIt - Make a donation here; I did.[size="2"]#include <Guinness.pint>[/size] Link to comment Share on other sites More sharing options...
chiners_68 Posted June 4, 2007 Author Share Posted June 4, 2007 ive been looking at PSShutdown, it seems to be the prefered tool. I want to use this tool but I want to basically shutdown all the machines on my network (that are not locked) at a specific time say 23:59. I can get a list of machines which are switched on with the "NET view" command but this gives me servers etc which i dont want to shutdown. All my machines are in 2 OU's in Active directory. how can I easly create a txt file for PSShutdown from these OU's or from the NET View command filtering all the servers from the list..? i didnt know if anyone has already do a filter for Active directory to assist PSShutdown. Link to comment Share on other sites More sharing options...
ptrex Posted June 4, 2007 Share Posted June 4, 2007 @all This give you already a good lead. dim $osObj, $osColl const $nLogOff=0 const $nReboot=2 const $nForceLogOff=4 const $nForceReboot=6 const $nPowerDown=8 const $nForcePowerDown=12 $osColl = Objget("winmgmts:{(Shutdown)}").ExecQuery("Select * from Win32_OperatingSystem") For $osObj in $osColl $osObj.Win32Shutdown($nForcePowerDown$) Next Enjoy !! ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
ksmith247 Posted June 4, 2007 Share Posted June 4, 2007 My servers and end user computers have distinctive netbios names. Its pretty easy for me to filter. I also pull lists from SMS collections. If you use SMS that is an option. Sorry, I don't do much with native Microsoft AD tools nor do I do much domain level scripting. However, Script-o-matic from the Microsoft Scripting Guys probably has a script to dump the contents of an OU to a txt file. It just so happens that Script-o-matic has been written in AutoIT. If it doesn't help you today it certainly will come in handy sometime. Support bacteria; it's the only culture most people have.LxP's Learning to Script with AutoIt 3 - Excellent starting placeVolly's Links Page - Links to cool and useful scriptsAutoIt Wrappers - Valuater's AutoIt Wrappers post. Lots of good stuff.Support AutoIt - Make a donation here; I did.[size="2"]#include <Guinness.pint>[/size] Link to comment Share on other sites More sharing options...
chiners_68 Posted June 4, 2007 Author Share Posted June 4, 2007 Petrex, what does tha script do..? Link to comment Share on other sites More sharing options...
chiners_68 Posted June 5, 2007 Author Share Posted June 5, 2007 (edited) Can anyone help me here.I have got this script which pulls all the computer names from within Active directory. how can I change this so it only looks in 2 OU's that i specify & not the domain root? Sorry for my ignarance here, I dont have a clue when it comes to VB.const FileName ="Domain Computers.csv"set cmd = createobject("ADODB.Command")set cn = createobject("ADODB.Connection")set rs = createobject("ADODB.Recordset")cn.open "Provider=ADsDSOObject;"cmd.activeconnection = cnset objRoot = getobject("LDAP://RootDSE")cmd.commandtext = "<LDAP://" & objRoot.get("defaultNamingContext") & ">;(objectCategory=Computer);" & _ "name"'**** Bypass 1000 record limitation ****cmd.properties("page size")=1set rs = cmd.executeset objFSO = createobject("Scripting.FileSystemObject")set objCSV = objFSO.createtextfile(FileName)q = """"while rs.eof <> true and rs.bof <> true objcsv.writeline(q & rs("name") & q) rs.movenextwendobjCSV.Closecn.closewscript.echo "Finished" Edited June 5, 2007 by chiners_68 Link to comment Share on other sites More sharing options...
ptrex Posted June 5, 2007 Share Posted June 5, 2007 @chiners_68 This is the translation so far. expandcollapse popupconst $FileName ="Domain Computers.csv" ; Declare COM Object error handler: Global $oComError = ObjEvent("AutoIt.Error", "_ComErrFunc") $cmd = ObjCreate("ADODB.Command") $cn = ObjCreate("ADODB.Connection") $rs = ObjCreate("ADODB.Recordset") $cn.open ("Provider=ADsDSOObject;") $cmd.activeconnection = $cn $objRoot = ObjGet("LDAP://RootDSE") $cmd.commandtext = "<LDAP://" & $objRoot.get("defaultNamingContext") & ">;(objectCategory=Computer);" & _ "name" ;**** Bypass 1000 record limitation **** $cmd.properties("page size")=1 $rs = $cmd.execute ;$objFSO = ObjCreate("Scripting.FileSystemObject") ;$objCSV = $objFSO.createtextfile($FileName) $q = """" $rs.moveFirst() ;while $rs.eof <> 1 and $rs.bof <> 1 ;$objCSV.writeline($q (& $rs("name") & $q)) Do ConsoleWrite ($rs("name").value & @CRLF) $rs.movenext() until $rs.eof ;wend ;$objCSV.Close() $cn.close() ConsoleWrite ("Finished") Func _ComErrFunc() Local $HexNumber = Hex($oComError.number, 8) MsgBox(16, "AutoIT COM Error Occured!", _ @TAB & "Error Number: " & $HexNumber & @CRLF & _ @TAB & "Line Number: " & $oComError.scriptline & @CRLF & _ @TAB & "Description: " & $oComError.description & @CRLF & _ @TAB & "WinDescription: " & $oComError.windescription) SetError(1); something to check for when this function returns EndFunc ;==>_ComErrFunc regards, ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New 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