How to check System Boot partition and Boot.ini option using a script

The following knowledgebase will explain the methods you can use to check System Boot Partition of the Operating System and BOOT.ini option on local and remote computer.

To check on local computer:

You can use the following methods:

  1. Connecting to Remote Registry Service
  2. Using a script

The first method is easy but includes a lot of efforts. You can navigate to the following location in registry after connecting to remote registry:

HKLM\System\CurrentcontrolSet\Control

The above registry key includes the following values in right pane:

systembootdevice REG_SZ multi(0)disk(0)rdisk(0)partition(1)

systemstartoptions REG_SZ NOEXECUTE=ALWAYSOFF FASTDETECT

To check on a Remote Computer:

You can use the below script to check the LogPath and Tasks Folder on a remote computer:

@echo off

Srvlist=C:\Temp\Srvlist.txt

Echo Computer Name, System Boot Partition, BOOT.INI Options >> Result.csv

SET Sys_Part=

SET Boot_Option=

For /F “Tokens=*” %%a In (%srvlist%) Do (

Set Comp_name=%%a

Set RegQry=”\\%%a\HKLM\System\CurrentControlSet\Control” /v SystemBootDevice

Set RegQry1=”\\%%a\HKLM\System\CurrentControlSet\Control” /v SystemStartOptions

REG.exe Query %RegQry% > CheckCC.txt

REG.exe Query %RegQry1% > CheckCC1.txt

Find /i “SystemBootDevice” < CheckCC.txt > StringCheck.txt

FOR /f “Tokens=3” %%b in (CheckCC.txt) DO SET Sys_Part=%%b

Find /i “SystemStartOptions” < CheckCC1.txt > StringCheck.txt

FOR /f “Tokens=3” %%b in (CheckCC1.txt) DO SET Boot_Option=%%b

Echo %Comp_name, %Sys_Part%, %Boot_Option% >> Result.csv

)

The above script will check remote computer for two registry entries for System Boot Partition and System Start Options and the results will be saved in a CSV format file.

How To Check Crash Control Settings On Remote Computer

The following knowledgebase will explain the methods you can use to set the Crash Control (Memory dump) on remote computers.

You can use the following methods to check and set the Crash Control settings on remote computer:

  1. Connecting to Remote Registry Service
  2. Using a script

The first method is easy but includes a lot of efforts. You can navigate to the following location in registry after connecting to remote registry:

HKLM\SYSTEM\CurrentControlSet\Control\CrashControl

The above registry includes the following values in right pane:

AutoReboot DWORD 00000001

CrashDumpEnabled DWORD 00000003

DumpFile STRING The dump file name

LogEvent DWORD 00000001

MinidumpDir DWORD The dump file location

Overwrite DWORD 00000001

SendAlert DWORD 00000001

You can use the below script to check the Crash Control settings on a remote computer is enabled or not.

@echo off

Srvlist=C:\Temp\Srvlist.txt

Echo Computer Name, Crash Control Settings Enabled?, Auto Reboot? >> Result.csv

SET Crash_Ctrl=

SET Auto_Rbt=

For /F “Tokens=*” %%a In (%srvlist%) Do (

Set Comp_name=%%a

Set RegQry=”\\%%a\HKLM\SYSTEM\CurrentControlSet\Control\CrashControl”

REG.exe Query %RegQry% > CheckCC.txt

Find /i “CrashDumpEnabled REG_DWORD 0x3” < CheckCC.txt > StringCheck.txt

If %errorlelvel% == 0 (

SET Crash_Ctrl=Enabled

) ELSE (

SET Crash_Ctrl=Disabled

)

Find /i “AutoReboot REG_DWORD 0x1” < CheckCC.txt > StringCheck.txt

If %errorlelvel% == 0 (

SET Auto_Rbt=Enabled

) ELSE (

SET Auto_Rbt=Disabled

)

Echo %Comp_name, %Crash_Ctrl%, %Auto_Rbt% >> Result.csv

)

*** End ***

The above script will check remote computer for two registry entries to check whether Crash Control is enabled or not and the results will be saved in a CSV format file.

How To Check What All Programs Will Run When User Logged On To Computer.

The following knowledgebase will tell you how you can check what all programs will run when user has logged on to the computer.

When user logs on to the computer the Winlogon service will use the following registry entry to run any programs (if specified):

HKLM\Software\Micrsofot\Windows\CurrentVersion\Run

HKLM\Software\Micrsofot\Windows\CurrentVersion\RunOnce

The above two registry entries are used by Winlogon service after user has logged on to the system successfully. The Winlogon service will create a list of programs to run.

Please note that domain policy may override this setting if specified. You can also use Group Policy settings to block any program to run.

You can use the following script to check the programs in Run or RunOnce registry key on remote computer.

*** Start ***

@echo off

Set RegQry=HKLM\Software\Microsoft\Windows\CurrentVersion\Run

Set RegQry1=HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce

REG.exe Query \\remote_computer\%RegQry% > CheckRun.txt

REG.exe Query \\remote_computer\%RegQry1% > CheckRunOnce.txt

Echo Programs on Computer : Remote_Computer >> Programs.txt

For /F “Skip=5 Tokens=*” %%a In (CheckRun.txt) Do (

Echo %%a >> Programs.txt

)

For /F “Skip=5 Tokens=*” %%a In (CheckRunOnce.txt) Do (

Echo %%a >> Programs.txt

)

*** End ***

You can use PSEXEC (a tool from Sysinternals) to run this script remotely and then redirect the output in a Text file.

How To Check If All The Computers Running On Network Are Using Default Windows Shell.

The following knowledgebase explains the method you can use to check if the user or computer is using the Windows default Explorer Shell. The Windows Default Shell is Explorer.exe for computer (it will apply to all the users who have logged on to the computer successfully). The user shell is Userinit.exe (This shell will apply to users who have logged on to the computer successfully).

Windows default Shell and Users Shell reside in the following registry entry:

HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon.

In the right pane you can see the following entries:

Shell REG_SZ Explorer.exe

Userinit REG_SZ C:\WINDOWS\system32\userinit.exe,

You can use the following script to check whether all the computers in your network are using default shell or not:

@echo off

Srvlist=C:\Temp\Srvlist.txt

Echo Computer Name, Windows Default Shell?, User Shell? >> Result.csv

SET Win_Def=

SET Usr_Def=

For /F “Tokens=*” %%a In (%srvlist%) Do (

Set Comp_name=%%a

Set RegQry=”\\%%a\HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon”

REG.exe Query %RegQry% > CheckShell.txt

Find /i “Explorer.exe” < CheckShell.txt > StringCheck.txt

If %errorlelvel% == 0 (

SET Win_Def=Yes

) ELSE (

SET Win_Def=No

)

Find /i “userinit.exe” < CheckShell.txt > StringCheck.txt

If %errorlelvel% == 0 (

SET Usr_Def=Yes

) ELSE (

SET Usr_Def=No

)

Echo %Comp_name, %Win_Def%, %Usr_Def% >> Result.csv

)

*** End ***

The above script will run the Reg.exe command on all the computers specified in ComputerList.txt and will save the result in Result.csv for computers who have Windows Default Shell and user default shell specified in registry.

How to find the DNS Name of a domain

The following knowledgebase will tell you the procedure you can use to retrieve the DNS name of a domain from registry.

The following registry location is the best place to find the DNS name of a domain controller.

HKLM\Software\Microsoft\Windows\CurrentVersion\Group Policy\History.

In the right pane, you will see an entry by name DCName=

The above entry will contain the DNS name of the domain. This DNS name of domain is stored in registry key after Winlogon retrieves the Domain controller by using the DcGetDCName API call.

Checking Operating System Version and Copying Customized MSGINA.dll file.

This script explains how you can use a small script in GPO Login Script to copy a customized MSGINA.dll for logon purpose to operating systems. Windows XP and Windows 2000 MSGINA.dll are different. Windows 2000 MSGINA.dll will not work on Windows XP and vice-versa.
 
  1. This script stores the reports in a central place (\\domain_name.com\netlogon\logon\MSGINAReport.csv. and report is saved as CSV so you can open it in Excel.
  2. MSGINA.dll file is copied as per the Operating System version. If its XP then MSGINA.dll for XP will be copied to client computer. If its Windows 2000 then MSGINA.dll for Windows 2000 will be copied to client computer.
  3. Ver.exe and hostname.exe are used to determine the Operating System version and Computer Name respectively.
 

***Start***

@Echo off
REM Reports will be saved in \\domain.com\netlogon\logon\MSGINAReport.csv

Echo Computer Name, Windows Version, Copied or Not ? >> \\domain.com\netlogon\logon\MSGINAReport.csv

SET Comp_name=
SET Win_Ver=
SET GinaCopied=

Hostname > host.txt
FOR /F “Tokens=1” %%a in (host.txt) DO Set Comp_name=%%a

VER > ver.txt
FOR /F “Tokens=*” %%a in (ver.txt) DO SET Win_Ver=%%a

Find /i “XP” < Ver.txt
if %ERRORLEVEL% == 0 (
     COPY “\\domain.com\netlogon\logon\msgina-xp.dll” “%WINDIR%\System32”
     IF %errorlevel% == 0 (
            SET GinaCopied=Yes
      ) ELSE (
            SET GinaCopied=No
      )
     CALL REGEDIT /S \\domain.com\netlogon\logon\logon-xp.REG
) ELSE (
     COPY “\\domain.com\netlogon\logon\msgina-2k.dll” “%WINDIR%\System32”
     IF %errorlevel% == 0 (
            SET GinaCopied=Yes
      ) ELSE (
            SET GinaCopied=No
      )
     CALL REGEDIT /S \\domain.com\netlogon\logon\logon-2k.REG
)

Echo %Comp_name%, %Win_Ver%, %GinaCopied% >> \\domain.com\netlogon\logon\MSGINAReport.csv

***End***

Script to Find DNS Server settings.

Script to find DNS settings:

 

  1. You can use up to Four Login attempts to check authentication on different servers or domains.
  2. Results get stored in a CSV format file. File name: Report.CSV
  3. Command window display for script information.
  4. Script supplies error message exactly.
  5. Servers Up/Down Status.

 

 

 

@echo off

 

@echo  =====================================================

@Echo  Script to Find DNS Servers configured for each server

@echo  =====================================================

 

@echo Please Enter Server List Path (e.i. E:\Nirmal\Srvlist\mgmsrv.txt)

 

setlocal enabledelayedexpansion

 

set /P srvlist=” “

 

IF exist %srvlist% (

  Echo Server list found: %srvlist%

  Echo Processing all the servers from %srvlist%

  CLS

 

) ELSE (

  CLS

  Echo Server list NOT found: %srvlist%

  Echo Exiting…

  goto:EOF

 

)

 

  SET DNS_Conf=

  SET Int_Logon=

  SET ComERRSRM=

  SET SNK_login=

  SET ComERRSNK=

  SET AMU_Login=

  SET Fold_Drive=

  SET Fold_Loc=

  SET REG_Upload=

  SET REG_Use=

  SET ServerStat=

  SET LOR_NEW=

  SET LOR_OLD=

  SET DLS_B=

  SET BIAS_B=

  SET DLS_A=

  SET BIAS_A=

  SET Rem_Req=

  SET PSEXEC_SPU=

  SET DST_Stat=

  SET AOS_Ver=

  SET AOS_Folder=

  SET AOS_Un=

  SET Uninst_Fold=

  SET Os_SRMto_E=

  SET Final_login=

  SET ComERR=

  SET NewComERR=

  SET Method_U=

  SET Copy_Un_F=

  SET DST_Source=

  SET DST_Dest=

 

set /a totsrv=0

set /a totcnt=0

 

FOR /F %%a in (%srvlist%) DO SET /a totsrv=!totsrv!+1

 

  SET SNK_login=

  SET Loc_Power=

  SET ComERRSNK=

  SET ComERRSRM=

  SET AMU_Login=

  SET ServerStat=

  SET LOR_NEW=

  SET LOR_OLD=

  SET DLS_B=

  SET Int_Logon=

  SET DNS_Conf=

  SET PSEXEC_TZ=

  SET Rem_Req=

  SET PSEXEC_SPU=

  SET AOS_Ver=

  SET AOS_Folder=

  SET AOS_Un=

  SET Uninst_Fold=

  SET Os_SRMto_E=

  SET Final_login=

  SET ComERR=

  SET NewComERR=

  SET PS_Rem=

  SET Method_U=

  SET Copy_Un_F=

  SET DST_Source=

  SET DST_Dest=

  SET Fold_Drive=

  SET Fold_Loc=

  SET Search_C=

  SET Search_D=

  SET Search_E=

 

Title DNS Server script in Progress…

 

IF exist E:\Nirmal\Dns\Report.csv Del E:\Nirmal\Dns\Report.csv

IF exist E:\Nirmal\Dns\Dnssrv.csv Del E:\Nirmal\Dns\DnsSrv.csv

IF exist E:\Nirmal\Dns\HostsAlive.txt Del E:\Nirmal\Dns\HostsAlive.txt

IF exist E:\Nirmal\Dns\HostsDown.txt Del E:\Nirmal\Dns\HostsDown.txt

IF exist E:\Nirmal\Dns\Alreadydone.txt Del E:\Nirmal\Dns\AlreadyDone.txt

IF exist E:\Nirmal\Dns\ToBeDone.txt Del E:\Nirmal\Dns\ToBeDone.txt

IF exist E:\Nirmal\Dns\RemovedDST.txt Del E:\Nirmal\Dns\RemovedDST.txt

IF exist E:\Nirmal\Dns\RemoveFailed.txt Del E:\Nirmal\Dns\RemoveFailed.txt

IF exist E:\Nirmal\Dns\PSFailed.txt Del E:\Nirmal\Dns\PSFailed.txt

IF exist E:\Nirmal\Dns\PSSuccess.txt Del E:\Nirmal\Dns\PSSuccess.txt

 

Echo Server Name, Up/Down, LOR-New Login, LOR-Old Login, SRM-Login?, SRMSNK Login?, Final Login?, PSEXEc, PSEXEC Remark, OS Version, DNS Servers Configured, Error REMARK-LOR New Login, Error REMARK – LOR Old Login, Error REMARK – SRM Login, Error REMARK – SRMSNKING Login >> Report.csv

REM Echo Server Name, DNS Configuration, >> DnsSrv.csv

 

FOR /F “TOKENS=*” %%a IN (%srvlist%) DO CALL:DONOW “%%a”

 

:DONOW

 

SET srvname=%~1

 

REM Echo %srvname%, >> Dnssrv.csv

 

IF [%OldSrv%] == [] SET OldSrv=%srvname%

 

SET /a totcnt=%totcnt%+1

 

CLS

 

Echo 1.Processing Server: %srvname% Total Server:[%totcnt% Of %totsrv%] Last Server: %OldSrv%

Echo 2.Checking Connectivity……………

 

IF exist E:\Nirmal\Dns\pingresult.txt Del E:\Nirmal\Dns\pingresult.txt

 

Ping -n 1 %srvname% > PingResult.txt 2>&1

 

FIND /i “Reply From” < PingResult.txt > DoNotShow.txt 2>&1

 

IF %errorlevel% == 0 (

 

  SET ServerStat=UP

 

  Echo 3.Reply received from Host %srvname%

  Echo %srvname% >> HostsAlive.txt

 

  REM This is to check wether currently logged in user have access or not.

 

  IF exist E:\Nirmal\Dns\Access.txt Del E:\Nirmal\Dns\Access.txt

  IF exist E:\Nirmal\Dns\NoAccess.txt Del E:\Nirmal\Dns\NoAccess.txt

 

  Echo 4.Checking Access for Currently Logged on user on Server: %srvname%

 

  DIR \\%srvname%\C$ > Access.txt 2>&1

 

  FIND /i “File(s)” < Access.txt > DoNotShow.txt

 

  IF !errorlevel! NEQ 0 (

 

     FOR /F “Tokens=*” %%T In (‘Type Access.txt’) DO SET NewComERR=”%%T”

 

     IF exist E:\Nirmal\Dns\LORold.txt Del E:\Nirmal\Dns\LORold.txt

 

     Echo 5.LOR New login failed…checking LOR Old password

 

     NET USE T: /delete > DoNotShow.txt 2>&1

     NET USE T: \\%srvname%\c$ /user:LORtest password > LOROld.txt 2>&1

    

     FIND /i “The command completed successfully.” < LORold.txt > DoNotShow.txt 2>&1

 

     IF !errorlevel! NEQ 0 (

            

        Echo 6.LOR Old password also failed…

        SET LOR_Old=Failed

        SET LOR_New=Failed

        SET Final_Login=Failed

  

        FOR /F “Tokens=*” %%T In (‘Type LORold.txt’) DO SET ComERR=”%%T”

 

        IF exist E:\Nirmal\Dns\SRMLogin.txt Del E:\Nirmal\Dns\SRMLogin.txt

 

        Echo 5.LOR Old login failed…checking SRM Login

 

        NET USE T: /delete > DoNotShow.txt 2>&1

        NET USE T: \\%srvname%\c$ /user:SRM\nsharma27 Password2006 > SRMLogin.txt 2>&1

    

        FIND /i “The command completed successfully.” < SRMLogin.txt > DoNotShow.txt 2>&1

 

        IF !errorlevel! NEQ 0 (

 

           Echo 7.SRM Login also failed…

 

           SET LOR_Old=Failed

           SET LOR_New=Failed

           SET AMU_Login=Failed    

           SET Final_Login=Failed

    

           FOR /F “Tokens=*” %%T In (‘Type SRMLogin.txt’) DO SET ComERRSRM=”%%T”

 

           IF exist E:\Nirmal\Dns\SNKlogin.txt Del E:\Nirmal\Dns\SNKLogin.txt

 

           Echo 5.SRM Login also failed…checking SRMSNKING Login…

 

           NET USE T: /delete > DoNotShow.txt 2>&1

           NET USE T: \\%srvname%\c$ /user:SRMSNKING\nsharma27 Password2006 > SNKLogin.txt 2>&1

    

           FIND /i “The command completed successfully.” < SNKLogin.txt > DoNotShow.txt 2>&1

 

           IF !errorlevel! NEQ 0 (

      

              Echo 7.SRM Login also failed…

 

              SET LOR_Old=Failed

              SET LOR_New=Failed

              SET AMU_Login=Failed    

              SET SNK_login=Failed

              SET Final_Login=Failed

          

              FOR /F “Tokens=*” %%T In (‘Type SNKLogin.txt’) DO SET ComERRSNK=”%%T”

 

           ) ELSE (

 

              SET ComERRSNK=

              Echo 7.SNKING Login passed…

        

              SET LOR_Old=Failed

              SET LOR_New=Failed

              SET AMU_Login=Failed

              SET SNK_login=Passed

              SET Final_Login=Passed

           )

 

        ) ELSE (

 

           SET ComERRSRM=

           Echo 7.SRM Login passed…

        

           SET LOR_Old=Failed

           SET LOR_New=Failed

           SET AMU_Login=Passed

           SET Final_Login=Passed

        )

 

     ) ELSE (

  

        SET ComERR=

               

        Echo 6.LOR Old password Passed…

        SET LOR_New=Failed

        SET LOR_old=Passed

        SET Final_Login=Passed

     )

 

  ) ELSE (

    

     SET NewComERR=

 

     Echo 5.Currently Logged on user have access…

     Echo 6.LOR New SRMthentication passed…

 

     SET LOR_New=Passed

     SET Final_Login=Passed

     SET LOR_Old=Not Checked

  )     

 

  IF !Final_Login! == Failed (

    

     SET DLS_B=

     SET BIAS_B=

     SET DLS_A=

     SET BIAS_A=

     SET TimeZone_N=

     SET PSEXEC_TZ=

     SET Rem_Req=

     SET AOS_Ver=

     SET AOS_Folder=

     SET AOS_Un=

     SET PSEXEC_SPU=

     SET Uninst_Fold=

     SET Os_SRMto_E=

 

     Echo 5.Login Failed…user DON’T have access to copy DST Folder.

    

     Echo %srvname% >> NoAccess.txt

 

  ) ELSE (

 

     Echo 5.Currently Logged in user have access on C:\ drive.

 

     Echo 6.Check OS Version and Windows System Folder name…

 

     IF exist E:\Nirmal\Dns\Windir.txt Del E:\Nirmal\Dns\Windir.txt

     IF exist E:\Nirmal\Dns\UnFold.txt Del E:\Nirmal\Dns\UnFold.txt

 

     Psexec.exe \\%srvname% cmd.exe /c SET > Windir.txt 2>&1

    

     FIND /i “windir=C:\WINDOWS” < Windir.txt > DoNotShow.txt 2>&1

 

     IF !errorlevel! == 0 (

        

      SET AOS_Ver=”Windows 2003″

        Echo 6.OS Version: !AOS_Ver!

 

     ) ELSE (

       

        SET AOS_Ver=”Windows 2000″

        Echo 6.OS Version: !AOS_Ver! 

 

     )

 

     IF exist E:\Nirmal\Dns\Dns.txt Del E:\Nirmal\Dns\Dns.txt

     IF exist E:\Nirmal\Dns\Othdns.txt Del E:\Nirmal\Dns\Othdns.txt

 

     Psexec.exe \\%srvname% Ipconfig /all > Dns.txt 2>&1

 

     Find /i “DNS Servers” < Dns.txt > Othdns.txt 2>&1

     FOR /F “Tokens=*” %%a IN (Othdns.txt) DO SET DNS_CONF=%%a

  

   

REM FOR /F “Tokens=*” %%a IN (othdns.txt) DO (

 

REM         SET DNS_Conf=

REM       SET DNS_Conf=%%a

REM          Echo ,!DNS_Conf!, >> DnsSrv.csv

        

REM   )

  

 

   )

 

) ELSE (

 

  SET ServerStat=Down

 

  Find /i “Request Timed” < PingResult.txt > DoNotShow.txt

 

  IF !errorlevel! == 0 (

     SET ServerStat=Request Timed Out

  ) ELSE (

     SET ServerStat=Uknown Host

  )

 

  SET LOR_NEW=

  SET LOR_OLD=

  SET DLS_B=

  SET BIAS_B=

  SET DLS_A=

  SET BIAS_A=

  SET TimeZone_N=

  SET PSEXEC_TZ=

  SET Rem_Req=

  SET PSEXEC_SPU=

  SET DST_Stat=

  SET AOS_Ver=

  SET AOS_Folder=

  SET AOS_Un=

  SET Uninst_Fold=

  SET Os_SRMto_E=

  SET DNS_Conf=

  SET DST_Stat=NotOk

  SET Rem_Req=

  SET ComERR=

  SET NewComERR=

  SET PS_Rem=

  SET REG_Use=

  SET Method_U=

  SET REG_Upload=

  SET Copy_Un_F=

  SET DST_Source=

  SET DST_Dest=

  SET Fold_Drive=

  SET Fold_Loc=

  SET Search_C=

  SET Search_D=

  SET Search_E=

  SET AMU_Login=

  SET ComERRSRM=

  SET Int_Logon=

  SET Loc_Power=

  SET SNK_login=

  SET ComERRSNK=

 

  Echo %srvname% >> HostsDown.txt

  Echo 3.Reply NOT received from Host %srvname%

 

)

 

SET OldSrv=%srvname%

 

IF [!srvname!] == [] (

 

  Echo Empty

 

) ELSE (

 

ECHO %srvname%, %ServerStat%, %LOR_NEW%, %LOR_OLD%, %AMU_Login%, %SNK_login%, %Final_Login%, %PSEXEC_TZ%, %PS_Rem%, %AOS_Ver%, %Dns_conf%, %NewComERR%, %ComERR%, %ComERRSRM%, %ComERRSNK%, >> Report.csv

 

  SET ServerStat=Down

  SET Final_login=

  SET LOR_NEW=

  SET Int_Logon=

  SET LOR_OLD=

  SET DLS_B=

  SET BIAS_B=

  SET DLS_A=

  SET BIAS_A=

  SET TimeZone_N=

  SET PSEXEC_TZ=

  SET Rem_Req=

  SET AOS_Ver=

  SET AOS_Folder=

  SET AOS_Un=

  SET Uninst_Fold=

  SET DNS_Conf=

  SET Os_SRMto_E=

  SET DST_Stat=NotOk

  SET Rem_Req=Yes

  SET ComERR=

  SET NewComERR=

  SET PS_Rem=

  SET Method_U=

  SET REG_Use=

  SET REG_Upload=

  SET Copy_Un_F=

  SET DST_Source=

  SET DST_Dest=

  SET Fold_Drive=

  SET Fold_Loc=

  SET Search_C=

  SET Search_D=

  SET Search_E=

  SET AMU_Login=

  SET ComERRSRM=

  SET SNK_login=

  SET ComERRSNK=

  SET Loc_Power=

  

)

 

:eof

 

How to create a Second Home folder on a different server:

The below script creates a second home folder for currently logged on user. This is very useful when you want to keep two home folders for one user: 

REM ***START***

@echo off

echo **************************************************************************************
echo Script to Create Second Home Folder for currently logged on user account
echo **************************************************************************************

REM The following command executes to create second home folder for user.
md \\server_name\Studentworks$\%username2%

REM The following command share second home folder remotely for currently logged on user.

rmtshare \\server_name\%username%2$ = c:\studentworks\%username%2

REM Now assign permissions to currently logged on user (Full Control)

xcacls.vbs \\server_name\studentworks$\%username%2 /g “domain_name/%username%”:F

REM Now map second home folder to J:\ drive.

net use j: \\server_name\studentworks$\%username%2

REM ***End***

List members of a Group

You can retrieve a list of users from a Security or
Distribution Group in domain by using DSget tool – a new tool introduced in
Windows 2003. This tool and other related tools ships with Windows 2003 CD.


Let’s say you need to gather a list of users (+nested groups) from a domain
group. This is bit easy. You can use the following command to accomplish the
goal:

dsget group “DN_of_group” -members -expand > userlist.txt

The output will be saved in userlist.txt

This is the sample output saved in userlist.txt

“CN=Shan Dallis,OU=Users,DC=test,DC=local”
“CN=Tapihe C Mdwa,OU=Users,DC=test,DC=local”

and so on…

Add a user to Local Admin group on All machines.

Scenario: You need to add a user (test1) to local
Administrators group on all computer. How do you achieve this??? no no…you’re
wrong here – don’t need to use VBScript or something like that simply use
PSEXEC to accomplish this! – intersting!

Here it is:

psexec.exe net localgroup administrators
test.local\test /add
-@server.txt

Isn’t simple as pie?

-@server.txt – This
file includes the list of servers to be processed by psexec to run the Net
Localgroup Administrators test.local\test /add
command.

net localgroup – This command directs NBT API to execute a
command using Windows Low-level sub-system. You should use Net Group for Global
security group if you’re gonna add to Global Security Group.

[H]