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.
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
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)
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)
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
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-
- Started with HP SmartStart version 8.2 and went through a normal OS load
- Logged in and downloaded SP2 from Windows update.
- Restarted
- It was at this time that windows update was broken.
Round 2-
- Started with HP SmartStart version 8.3 (downloaded from HP support) and went through a normal OS load
- Manually downloaded SP2 from MS and transferred that to the server when it was ready
- Applied SP2, and restarted
- Windows update website worked fine then, so I began the download of the other 80 some updates
- Half way through the installation of the updates, something went wrong and it stopped unexpectedly.
- Restarted, and Windows updates would not work
Round 3-
- Became skeptical of HP SmartStart, so I just used the OS installation media to install
- Applied the downloaded version of SP2 and restarted
- 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.
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”