Thursday, October 22, 2009

Batch file command to call other batch file!

hi hi, is a very simple batch file command learn today . just keep for future reference. Just now thinking to run few batch file automatically. So try to write one batch file to make it auto.

script as below :

call batchfile1.bat
call batchfile2.bat

save this batch file as .bat file will do.. the magic keyword is CALL!!

Thursday, October 1, 2009

Use PowerShell ADSI provider to add domain group to Local Admin group

ha ha, as i am not Domain administrator so not using much script to add user. This morning have one task need me to add some security team  to 5 server, so thiking to try about the powershell. so below is the simple script have created : (is not perfect but is working fine :) )
*servers.txt is all your servers name going to add in.

$serverList = 'C:\servers.txt'
$names = get-content $serverList
$Admins = [ADSI] 'WinNT:///'
foreach ($name in $names)
{
Write-Host 'Adding Admins to' $name
#get the local group
$localAdminGroup = [ADSI]("WinNT://$name/Administrators")
#add the global group to the local group
$localAdminGroup.Add($Admins.PSBase.Path)
}


This script have a bug , that is once the group is available at the target server then will stop and give error :). ha ha , either u write the if statement to catch it or just make sure all your server is not exist the name you want to add . ha ha..is simple, but is very fun for me to find out it.