19 September, 2010

UnLink GPO script

Hi,

All I wanted is to UnLink a GPO from an OU using a script, not a lot to ask google.
It seems that no one ever need to UnLink a GPO, only delete or link.
So I took the original DeleteGPO.wsf from the GPMC scripts directory and changed it a bit so it would not delete but only unlink the gpo.

Copy the content of the  frame to get the wsf script.



Also published it on my GoogleDocs due to the vbs.

Save it as UnLinkGPO.wsf into "C:\program files\gpmc\scripts" and you have an unlink gpo script.

Enjoy

16 September, 2010

Access server shares under different server name

If you done a file server move you know that as much as you want you cannot be sure if you covered all the places with the old server name.
A simple solution is to change the ip address of the old server after you shut it down to the new one, right?

Well, not that easy, Windows Server has a build in protection against accessing the server with an alias names.

I'm here to tell you that you can bypass that with a small registry key
At the end everything comes to a registry key :)

======================================
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters]
"DisableStrictNameChecking"=dword:00000001

======================================

Enjoy

14 September, 2010

The real place to use IE trusted sites via GPO

Hi,

Trusted sites in IE via GPO is a mess, there are several places to insert this settings and the main problem is that they will not work on all versions.

I have the perfect place to use it and I tested it with ver 6,7 and 8 and it worked.

User Configuration -> Administrative Templates -> Windows Components -> Internet Explorer -> Internet Control Panel -> Security Page: Site to Zone Assignment List

Enjoy.

12 September, 2010

Rename the desktop "My Computer" to pc name

Hi,

Using bginfo to add to the user desktop his workstation name ?
Why not just rename the "My Computer" text to the workstation name and that's it ?

2 ways to do it:
- Using VBS Script
- Using GPP

VBS Script:
===================================
Const MY_COMPUTER = &H11&


Set objNetwork = CreateObject("Wscript.Network")
objComputerName = objNetwork.ComputerName
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(MY_COMPUTER)
Set objFolderItem = objFolder.Self
objFolderItem.Name = objComputerName
===================================

GPP:
Just add a registry chnage on the user level:
===================================
Key:        Software\Microsoft\Windows\CurrentVersion\Explorer\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}
Value Name:     (Default)
Value Data:    %computername%
Type:        REG_SZ
==================================

The registry key by the way is (replace 123 with what you want):
==================================
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}]
@="123"
==================================

Have fun...

07 September, 2010

Utilizing systeminfo to get info on a list of servers or workstation

Hi,

If you have a list of computers (servers or workstations) and need to get some info on them, for example Total Physical Memory you could use my script to get this info.

First put all the computer names in a file and name it servers.txt.
Then decide what property you want to get, the following properties are availble:
Host Name
OS Name:
OS Version
OS Manufacturer
OS Configuration
OS Build Type
Registered Owner
Registered Organization
Product ID
Original Install Date
System Boot Time
System Manufacturer
System Model
System Type
BIOS Version
Windows Directory
System Directory
Boot Device
System Locale
Input Locale
Time Zone
Total Physical Memory
Available Physical Memory
Virtual Memory: Max Size
Virtual Memory: Available
Virtual Memory: In Use
Page File Location(s)
Domain
Logon Server

(will work with only property that the output is 1 line)

The script:
===================================
@echo off
echo.
echo Type the SystemInfo attribute
echo you want to check:

set /P C=
del "%C%.txt"
for /f %%A in (servers.txt) do (
echo Server: %%A >> "%C%.txt"
systeminfo /s \\%%A | find "%C%:" >> "%C%.txt"
echo ------------------------------------------------------------------ >> "%C%.txt"
)
==================================

enjoy

06 September, 2010

SQL Express (MSDE) automatic backup script

Hello all,
You may have instances of SQL Express or in it's previus version MSDE due to small applications or just to save some moeny.
The main problem is to back them up in a central location and get alerts if something goes wrong.

My script is using the following external tools:
1. osql.exe - just install studio express
2. mailit.exe - a command line mailing program, part of NUTS suite.

The things you need to do before:
1. make sure that the sql instance supports integrated security (http://msdn.microsoft.com/en-us/library/ms188670.aspx)
2. document the server names and instance name
3. create a shared central location for the backup destination (security of the directory should include the computer account that you are backing up with write permissions)
4. create a sql backup script for every DB you want to backup (replace the bold with your data):
==============================
BACKUP DATABASE [DBNAME] TO  DISK = N'\\server\share$\Filename.bak' WITH NOFORMAT, NOINIT, NAME = N'BESMGMT-Full Database Backup', SKIP, NOREWIND, NOUNLOAD,  STATS = 10
GO
==============================


The script:
in this example I backup 3 DB's on 3 deferent servers.
replace the BOLD with your data
==============================
set backupexec=yes
set epo=yes
set bes=yes

osql -S servername\bkupexec -E -i D:\Work\DB_Backup\Scripts\BackupexecDB.sql -o D:\Work\DB_Backup\Logs\backupexec.log

find "BACKUP DATABASE successfully processed" D:\Work\DB_Backup\Logs\backupexec.log
if %errorlevel% NEQ 0 (set Backupexec=no)

osql -S servername\eposerver -E -i D:\Work\DB_Backup\Scripts\ePO.sql -o D:\Work\DB_Backup\Logs\ePO.log

find "BACKUP DATABASE successfully processed" D:\Work\DB_Backup\Logs\ePO.log
if %errorlevel% NEQ 0 (set epo=no)

osql -S servername\besmgmt -E -i D:\Work\DB_Backup\Scripts\BES.sql -o D:\Work\DB_Backup\Logs\BES.log

find "BACKUP DATABASE successfully processed" D:\Work\DB_Backup\Logs\BES.log
if %errorlevel% NEQ 0 (set bes=no)

set body=
if "%backupexec%"=="no" (set body=BackupExec)
if "%epo%"=="no" (set body=%body%, ePO)
if "%bes%"=="no" (set body=%body%, BES)
set att=
if "%backupexec%"=="no" (set att=D:\Work\DB_Backup\Logs\backupexec.log)
if "%epo%"=="no" (set att=%att%,D:\Work\DB_Backup\Logs\ePO.log)
if "%bes%"=="no" (set att=%att%,D:\Work\DB_Backup\Logs\BES.log)
if "%body%"=="" goto end

rem === mailit parameters ===
SET MAILIT_SERVER=mailserver
SET MAILIT_FROM=db_bk@yourdomain.local
SET MAILIT_TO=your-email@yourdomain.local
SET MAILIT_SUBJ=Error in DB Backup (%body%)
SET MAILIT_MSGTEXT=There are errors in DB backup of: %body%
SET MAILIT_ATTACH=%att%
D:\Work\DB_Backup\MAILIT.exe

:end
=============================

Enjoy

05 September, 2010

Delete local hotfix folders script (Windows XP only)

Deploying hotfixes ?
Have Windows XP in your environment ?

Here is a vbs script to delete all hotfix folders, just deploy it via GPP or any other method:
==================================
dim filesys, f
Set objShell=CreateObject("WScript.Shell")
Set objArgs = WScript.Arguments
'FolderName =objArgs(0) 'optional with parameter
Set fso=createobject("scripting.filesystemobject")
Set f = fso.GetSpecialFolder(0)
FolderName = f

Set fld_root = fso.GetFolder(FolderName)
For Each fld_sub In fld_root.SubFolders
  If (InStr(fld_sub.Name,"$")=>1) Then
       if fld_sub.Name ="$hf_mig$" Then
       Else
       'WScript.Echo "Deleting " & Foldername & "\" & fld_sub.Name
       fld_sub.delete
       End If
  End If
 Next
==================================

Enjoy...

02 September, 2010

Simple Script to disable UAC on vista/W7

Hi,


The prompt for approval is annoying? Try this simple script in batch...

(It will restart the PC and you must run it with administrator privileges)

=======================

@echo off

reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_dword /d 0 /f

if %errorlevel%==0 (goto restart)

echo Unable to set the registry key...

pause

goto end


:restart

shutdown -r -f -t 30 /c "UAC Disabled, Restarting..."

quit


:end

=======================


enjoy