14 September, 2009

Automatic backup of XenServer vm with vm-export

Hi,

I needed to schedule a weekly backup of my VM's in my XenServer.
When I googled it I found a script written by Jeff Riechers, this script was good but did not help me because I did not have enough storage to take a snapshot to each VM.
I had to tweak it and I improved the method of retrieving the uuid (no more temp files...).

The final script reads from a file (named serverlist.txt) the vm name and the host on it resides. This is because I noticed that when I shut down the VM it gets a deferent home server, so I forced it to start on a specific host.

Just schedule it with cscript and your good to go.

Link to the script

03 August, 2009

do a smart .NET 3.5 install...

The main problem (as I see it) with the .NET install, that it is not "smart" enough. I mean run it once or twice it will allways run the same install.
If you want to make sure your clients is .NET "enabled" just use my small startup script (or SCCM).

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

reg query "HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5" /v Version | findstr "v3.5"
if %errorlevel%==0 goto end

"%~dp0dotnetfx35.exe" /q /norestart
exit /B %errorlevel%

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

02 August, 2009

run script only when the user got his desktop

Hi,

I had a problem, I needed to change all the workstations screen resolution at my client network.

I found a cool small tool named ResSwitch, the problem with it that it can only run when a user has it's desktop loaded.

I added the following lines to chack if the user desktop is ready.

====================================
:check_4_explorer
tasklist find "explorer"
if %errorlevel% == 1 goto check_4_explorer

"%~dp0ResSwitch.exe" /WIDTH:1280 /HEIGHT:1024
====================================

28 July, 2009

Cool way to run interactive CMD with SYSTEM Account

Just save it as a CMD file, run it and wait a minute… (dont run it in the 59 minute of the hour)

===========================================
Set sMinutes=%time:~3,2%
set/a sMinutes=%sMinutes%+1

if %sMinutes% LSS 10 (set sMinutes=0%sMinutes%)

echo %time:~0,2%:%sMinutes%
at %time:~0,2%:%sMinutes% /inter cmd.exe
===========================================

19 May, 2009

Smart Ping when restarting

Hi,
You restart a remote server because you installed some new MS updates and you need to know when it's back online.
What we all do?, start pinging the server and continue to do other things.
when we come back after few minutes to the ping window we see that the server is online but we missed to see it's gone offline.
The following script (I called it "Smart Ping") will check the output from the ping action and look for specific word to let you know that the server went down and went up again.

Fill free to change the words it searches as you see fit in your environment.

=======================================
echo off
cls
:dead
title Server [%1] is going to shut down [%time%]...
ping -n 1 -w 300 %1 find "Request timed out."
IF %ERRORLEVEL% == 0 (goto back_alive) ELSE (goto dead)
:back_alive
title Server [%1] is down [%time%]...
ping -n 1 -w 300 %1 find "TTL"
IF %ERRORLEVEL% == 0 (goto end) ELSE (goto back_alive)
:end
title Server [%1] is Back online [%time%]...
pause
=======================================

Enjoy...

10 May, 2009

How to get the DN from an NT name...

Hi,

If you are scripting you may came across the annoying problem of the DN name.
In everyday activity you use the NT name of an object from Active Directory but when you want to start scripting - no... you need the DN.

The following Script will help you convert on the fly the NT name to DN object.

===================================
private function TranslateNTName(ntname)
dim nto
dim result
const ADS_NAME_INITTYPE_SERVER = 2
const ADS_NAME_INITTYPE_GC = 3
const ADS_NAME_TYPE_1779 = 1
const ADS_NAME_TYPE_NT4 = 3
TranslateNTName=""
set nto = CreateObject("NameTranslate")
'on error resume next
nto.Init ADS_NAME_INITTYPE_GC , ""
nto.set ADS_NAME_TYPE_NT4, ntname
TranslateNTName = nto.Get(ADS_NAME_TYPE_1779)
on error goto 0
end function

wscript.echo TranslateNT4Name ("domain\user")
===================================

Enjoy

Get AD group members (including nesting)

I looked for some time now for a command that will give me all the members of a group even if it contains nesting groups.





I'm happy to inform you that the answer was allways under my nose.





The command was: DSGET.





The following syntax worked for me:


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


dsget group CN=Group_Name,OU=Groups,DC=domain,DC=local -members -expand


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





MS Link





You can mix it up with my tip on how to get the DN from an NT name and simplify the command...