Code snippets : Handy wmic commands
Some handy wmic commands which might be helpful when automating OS deployment:
wmic bios get serialnumber wmic computersystem get manufacturer wmic computersystem get model
Some handy wmic commands which might be helpful when automating OS deployment:
wmic bios get serialnumber wmic computersystem get manufacturer wmic computersystem get model
From script repository I did use in the past, VBscript which allows to clear EvenLog on Windows machine. I did use that on computers with Windows XP and Windows Server 2003. however, this script will work also on Windows 7 and Windows server 2008.
By default script clears EventLog on computer where script is executed. To clear logs on remote machine just modify variable strComputer and replace dot with name of the target machine.
Script will read all EvenLog files from machine and will go through them removing all events.
And here is script itself :
strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate, (Backup, Security)}!\\" _ & strComputer & "\root\cimv2") Set colLogFiles = objWMIService.ExecQuery _ ("Select * from Win32_NTEventLogFile") For each objLogfile in colLogFiles objLogFile.ClearEventLog() Next
When browsing repository of all scripts I did use in past, I found one which might be interesting. What this script does is:
I had that as small procedure executed automatically with SQL Server Agent. Script is for Microsoft SQL Server and I was running it on SQL Server 2000 and 2005. Here is code for that small procedure:
DECLARE @fname varchar(255) DECLARE @fname_backup varchar(255) DECLARE @fname_archive varchar(255) DECLARE @archive_path varchar(255) DECLARE @dbname varchar(255) DECLARE @archive_cmd varchar(255) DECLARE @put_cmd varchar(255) SET @dbname = 'dbApplication' SET @fname = @dbname + '_' + LTRIM(STR(DAY(GETDATE()))) + '.' + LTRIM(STR(MONTH(GETDATE()))) + '.' + LTRIM(STR(YEAR(GETDATE()))) SET @archive_path = 'F:\Backup\' SET @fname_backup = @archive_path + @fname + '.BAK' SET @fname_archive = @archive_path + @fname + '.RAR' SET @archive_cmd = '"C:\Program Files\WinRAR\WinRAR.EXE" a ' + @fname_archive + ' ' + @fname_backup SET @put_cmd = 'echo put ' + @fname_archive + '>> F:\Backup\ftpcmds' PRINT @fname_backup PRINT @fname_archive BACKUP DATABASE @dbname TO DISK = @fname_backup WITH INIT EXEC xp_cmdshell @archive_cmd EXEC xp_cmdshell 'echo open 192.168.10.101> F:\Backup\ftpcmds' EXEC xp_cmdshell 'echo user dbupload>> F:\Backup\ftpcmds' EXEC xp_cmdshell 'echo password123>> F:\Backup\ftpcmds' EXEC xp_cmdshell 'echo cd DB_Backup>> F:\Backup\ftpcmds' EXEC xp_cmdshell 'echo bin>> F:\Backup\ftpcmds' EXEC xp_cmdshell 'echo ha>> F:\Backup\ftpcmds' EXEC xp_cmdshell @put_cmd EXEC xp_cmdshell 'echo bye>> F:\Backup\ftpcmds' EXEC xp_cmdshell 'ftp -d -i -n -s:F:\BACKUP\ftpcmds'
I hope that will be handy for someone to automate databsae backups and transfers.
In previous articles in the RANCID series I described:
So, we have RANCID collecting configuration from network devices to repository with version control. Only question is how to get access and make use of information collected there.
In this part of RANCID stories I will show how to install and configure WebSVN to access RANCID repository via web browser.
Some time ago I described How to : Install RANCID on openSUSE 11.4 “Celadon”. However, just after installation RANCID will do nothing without proper configuration.
So, in this lab I will show how to:
Systems which will be used to demonstrate how to add device to RANCID and collect configuration: