Matt Carey's Blog

Windows 7 God Mode

by Nazarah on Apr.13, 2010, under Windows 7

Create a new folder on the desktop, and give it this name:

GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}

It will give you a neat little console with all the admin stuff in one spot.

Reported to work on Vista, but I have not tested that.

Comments Off more...

Using DATE and TIME variables in CMD files without the illegal file name charectars

by Nazarah on Apr.09, 2010, under Scripts

Ran into this little tidbit that I’d like to remember later while writing a script that does simple MySQL backups. You can use variables in this format to record date and time but leave out the illegal file name charectars.

D:
cd “MySQL Backups”
mysqldump –database xmlfilegen –user=xmlfilegen –password=XMLgen3 –result-file=”%DATE:~10,4%%DATE:~4,2%%DATE:~7,2% %TIME:~0,2% %TIME:~3,2%%.txt”
exit

Comments Off :, , , , more...

Microsoft SQL Server 2005 Express – Backup system databases

by Nazarah on Mar.05, 2010, under Microsoft SQL

– Declare Session Variables
DECLARE @Now datetime
DECLARE @TodayStr varchar(20)
DECLARE @MasterBackupName varchar(100)
DECLARE @ModelBackupName varchar(100)
DECLARE @MSDBBackupName varchar(100)
DECLARE @MasterBackupFile varchar(100)
DECLARE @ModelBackupFile varchar(100)
DECLARE @MSDBBackupFile varchar(100)
DECLARE @SQL varchar(2000)
DECLARE @SQL2 varchar(2000)
DECLARE @SQL3 varchar(2000)
 
–  Set the current date and time
SET @Now = getdate()
 
– Create backup file date and time in DOS format yyyy_hhmmss
Set @TodayStr = convert(varchar, @Now, 112)+ ‘_’+replace(convert(varchar, @Now, 108), ‘:’, ”)
 
– Create a variable holding the total path\filename.ext for the backup
Set @MasterBackupFile = ‘D:\Backups\system\Master_’+ @TodayStr + ‘_FULL.BAK’
Set @ModelBackupFile = ‘D:\Backups\system\Model_’+ @TodayStr + ‘_FULL.BAK’
Set @MSDBBackupFile = ‘D:\Backups\system\MSDB_’+ @TodayStr + ‘_FULL.BAK’
 
– Provide the backup a SQL name and name in media
Set @MasterBackupName = ‘Master full backup for ‘ + @TodayStr
Set @ModelBackupName = ‘Model full backup for ‘ + @TodayStr
Set @MSDBBackupName = ‘MSDB full backup for ‘ + @TodayStr
 
– Generate the Dynamic SQL script variable to be executed
SET @SQL = ‘BACKUP DATABASE [master] TO DISK = ”’ + @MasterBackupFile + ”’ WITH NOFORMAT, NOINIT, NAME = ”’ +@MasterBackupName+”’, SKIP, NOREWIND, NOUNLOAD,  STATS = 10′
Print @SQL
SET @SQL2 = ‘BACKUP DATABASE [model] TO DISK = ”’ + @ModelBackupFile + ”’ WITH NOFORMAT, NOINIT, NAME = ”’ +@ModelBackupName+”’, SKIP, NOREWIND, NOUNLOAD,  STATS = 10′
Print @SQL2
SET @SQL3 = ‘BACKUP DATABASE [msdb] TO DISK = ”’ + @MSDBBackupFile + ”’ WITH NOFORMAT, NOINIT, NAME = ”’ +@MSDBBackupName+”’, SKIP, NOREWIND, NOUNLOAD,  STATS = 10′
Print @SQL3
– Execute the SQL Command
EXEC(@SQL)
EXEC(@SQL2)
EXEC(@SQL3)

Leave a Comment more...

SQL Express Scripts

by Nazarah on Mar.01, 2010, under Microsoft SQL

Run these SQL commands from a CMD file to automate backups

Full DB Backup

– Declare Session Variables
DECLARE @Now datetime
DECLARE @TodayStr varchar(20)
DECLARE @BackupName varchar(100)
DECLARE @BackupFile varchar(100)
DECLARE @SQL varchar(2000)
 
–  Set the current date and time
SET @Now = getdate()
 
– Create backup file date and time in DOS format yyyy_hhmmss
Set @TodayStr = convert(varchar, @Now, 112)+ ‘_’+replace(convert(varchar, @Now, 108), ‘:’, ”)
 
– Create a variable holding the total path\filename.ext for the backup
Set @BackupFile = ‘D:\Backups\prod\CasesDB_’+ @TodayStr + ‘_FULL.BAK’
 
– Provide the backup a SQL name and name in media
Set @BackupName = ‘Cases full backup for ‘ + @TodayStr
 
– Generate the Dynamic SQL script variable to be executed
SET @SQL = ‘BACKUP DATABASE [Cases] TO DISK = ”’ + @BackupFile + ”’ WITH NOFORMAT, NOINIT, NAME = ”’ +@BackupName+”’, SKIP, NOREWIND, NOUNLOAD,  STATS = 10′
Print @SQL

– Execute the SQL Command
EXEC(@SQL)

Trans Log Backup

– Declare Session Variables
DECLARE @Now datetime
DECLARE @TodayStr varchar(20)
DECLARE @BackupName varchar(100)
DECLARE @BackupFile varchar(100)
DECLARE @SQL varchar(2000)
 
–  Set the current date and time
SET @Now = getdate()
 
– Create backup file date and time in DOS format yyyy_hhmmss
Set @TodayStr = convert(varchar, @Now, 112)+ ‘_’+replace(convert(varchar, @Now, 108), ‘:’, ”)
 
– Create a variable holding the total path\filename.ext for the log backup
Set @BackupFile = ‘D:\Backups\prod\CasesTransLog_’+ @TodayStr + ‘_.BAK’
 
– Provide the backup a SQL name and name in media
Set @BackupName = ‘Cases trans log backup for ‘ + @TodayStr
 
– Generate the Dynamic SQL script variable to be executed
SET @SQL = ‘BACKUP LOG [Cases] TO DISK = ”’ + @BackupFile + ”’ WITH NOFORMAT, NOINIT, NAME = ”’ +@BackupName+”’, SKIP, NOREWIND, NOUNLOAD,  STATS = 10′
Print @SQL

– Execute the SQL Command
EXEC(@SQL)

Leave a Comment more...

Exchange 2007 Powershell Commands

by Nazarah on Mar.01, 2010, under Exchange 2007, Powershell

Set Public folder permissions
Add-PublicFolderClientPermission -Identity “\foldername” -User Username -AccessRights Editor

Leave a Comment :, more...

NSLookup works but ping fails

by Nazarah on Feb.12, 2010, under General

Another random issue I ran accross as I was installing Windows Server 2003 R2 Enterprise Edition 32 bit on an HP DL360 G5 server……Everything was going fine until the instatllion of SP2 decided to break name resolution and made the Windows update website not work. I could browse other sites fine. The scenario:

Round 1-

  1. Started with HP SmartStart version 8.2 and went through a normal OS load
  2. Logged in and downloaded SP2 from Windows update.
  3. Restarted
  4. It was at this time that windows update was broken.

Round 2-

  1. Started with HP SmartStart version 8.3 (downloaded from HP support) and went through a normal OS load
  2. Manually downloaded SP2 from MS and transferred that to the server when it was ready
  3. Applied SP2, and restarted
  4. Windows update website worked fine then, so I began the download of the other 80 some updates
  5. Half way through the installation of the updates, something went wrong and it stopped unexpectedly.
  6. Restarted, and Windows updates would not work

Round 3-

  1. Became skeptical of HP SmartStart, so I just used the OS installation media to install
  2. Applied the downloaded version of SP2 and restarted
  3. Windows update was broken again

After fighting with this for a while, I ran accross some information online with others that have had this same issue. All it took was disabling the DNS Client service on the server, and viola, name resolution was working again. I applied the rest of my updates, restarted and life was good. The DNS client ran automatically on startup and name resolution is still working fine as well.

Leave a Comment :, more...

Enumerate users in an Active Directory group

by Nazarah on Feb.12, 2010, under Active Directory

Here is a little script that I ran accross today to help with dumping the members of an AD group into a text file. Edit as you see fit for your situation. Best to copy and paste it from here. If you manually type it, watch out for the word wrap.

‘Script begins here
Dim objGroup, objUser, objFSO, objFile, strDomain, strGroup, Domain, Group
‘Change DomainName to the name of the domain the group is in
strDomain = Inputbox (“Enter the Domain name”, “Data needed”, “Default domain name”)
‘Change GroupName to the name of the group whose members you want to export
strGroup = InputBox (“Enter the Group name”, “Data needed”, “Default group name”)
Set objFSO = CreateObject(“Scripting.FileSystemObject”)
‘On the next line change the name and path of the file that export data will be written to.
Set objFile = objFSO.CreateTextFile(“C:\utils\” & strGroup & ” – Members.txt”)
Set objGroup = GetObject(“WinNT://” & strDomain & “/” & strGroup & “,group”)
For Each objUser In objGroup.Members
    ‘objFile.WriteLine objUser.Name & ” – ” & objUser.Class
    objFile.WriteLine objUser.Name
Next
objFile.Close
Set objFile = Nothing
Set objFSO = Nothing
Set objUser = Nothing
Set objGroup = Nothing
Wscript.Echo “Done”
Wscript.Echo “Please check the c:\utils\ for your output file”

Leave a Comment : more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...

Archives

All entries, chronologically...