Batch of commands
I have a friend who is surely going to be some sysadmin in some small business and he asked me a couple of questions about how to manage the IT business he will have.
After some moment of reflection I can say that the way you manage your IT operations is really affected by all the little scripts you made and use. And today I feel like sharing a few.
You may need some support tools package from MSFT or other utils like from sysinternal to be able to enjoy but as every good admin you already have them don't you?
Get a list of the DC of your domain:
Nltest /dclist:%userdnsdomain%
DC Ip configuration:
for /f %i in ('dsquery server -domain %userdnsdomain% -o rdn') do psexec \\%i ipconfig /all
User with no logon script:
dsquery * domainroot -filter "(&(objectCategory=Person)(objectClass=User)(!scriptPath=*))" -limit 0 -attr sAMAccountName sn givenName pwdLastSet distinguishedName
DNS information
for /f %i in ('dsquery server -domain %userdnsdomain% -o rdn') do dnscmd %i /info
Group policy verification tool:
gpotool.exe /checkacl /verbose
ACL on OUs:
For /f "delims=|" %i in ('dsquery OU') do acldiag %i
Domain trust:
nltest /domain_trusts /v
DC diag:
dcdiag /s:%logonserver% /v /e /c
Replication Summary:
Repadmin /replsummary
Find NIC bandwith:
wmic /node:%server% path Win32_PerfRawData_Tcpip_NetworkInterface GET Name,CurrentBandwidth
List ACL in SDDL format:
setacl -on %filepath% -ot file -actn list -lst f:sddl
Dead links in offline files
I have come into some offline files synchronization issue when workin with offline files. Users have had offline files enabled on their network drive. And then as the use of this drive became useless, everyone disconnected this drive from their security context. Now users get an error from Syncronisation every time they log on or off saying it was not able to syncronise with these shares. I have tried to remove the links to these dead shares but I cannot do it in Explorer>Tools>Synchronise. the dead link would show up in the list, but unchecking it was not enough as it would come back checked at next reboot.
I assumed some Client side Caching corruption. The Offline Files (CSC or Client Side Caching) cache and database has a built-in capability to restart. Which led me to the MS kb230738 and gives you some registry tricks.
- Add the following registry entry using your prefered method...
"HKLM\Software\Microsoft\Windows\CurrentVersion\NetCache\FormatDatabase", 1, "REG_DWORD" - Restart the computer
What this does is wipe out orphaned user synchronization information in sysvol. I just would like to emphasize a warning: All cache files are deleted and unsynchronized data is lost.
Remote Desktop Connection + Dual/Big monitors Part #2
This post is part #2 of a research started about using Remote Desktop for Dual Screen capabilities started here.
Previously on Flog... With the help of the new Remote Desktop Client by MSFT (stockholders will understand Microsoft), you can now display the content of the remote machine on 2 monitors spanning it - the /span option of mstsc.exe.
A fellow reader tipped me about a software that would help tiling application on the screen, just like you would with the manual method:
Select the windows you want to tile (using the Ctrl key) and then right click and select tile Vertically or Horizontally.
The little software from www.splitview.com does a good job as it adds 2 extra buttons on each windows to switch them to some place of the tiled windows and some more handy functions for $19USD per user! However what we would like to do is basic:
On a large monitor or dual (and more) monitor, we want to display 2 (or more) applications evenly on the screen aka split them on the screen.
Of course it can be done manually, but some users may be reluctant in such manipulation.
Doing research about tiling windows I have found some help by the MS Script guy. A few lines of code can make users life more easy, here it goes:
Set objShell = CreateObject("Shell.Application")
objShell.TileHorizontally
To tile your windows Horizontally
Set objShell = CreateObject("Shell.Application")
objShell.TileVertically
To tile your windows Vertically
Set objShell = CreateObject("Shell.Application")
objShell.CascadeWindows
Or more fun, Cascade your windows!
I have compiled for your 2 vbs scripts (tile your windows) that you could conveniently place on the Quick Launch bar to tile windows that are opened the way you want.
To end, I'll just quote something from splitview:
Those scripts are perfect for deploying Citrix with dual-monitors, and ideal for using dual-monitors in 'span' mode. (for free)
Installing RSYNC on Windows 2003/2000/NT.

This document assumes that you want to install rsync as a daemon on a Windows NT/2000/2003 server or XP, without installing the entire cygwin suite.
You will need the following files:
From Cygwin:
- cygpopt-0.dll
- cygwin1.dll
- rsync.exe
These are available from http://www.cygwin.com
A zip file containing the three Files you need is available.
From the Windows NT or 2000 Resource Kit. You also may want to read this kb as well.
- instsrv.exe
- srvany.exe
For simplicity I have zipped them up in the previously mentioned package.
If you follow the following instructions you will an rsync service on your windows machine.
Please be careful where you place the server as any one who can see it can read from this service.
- Place rsync where you want to run it from.
(I usually use C:\program files\rsync) - Put the two dll's anywhere in the path, usually C:\winnt\system32 or c:\windows\system32 but for sure %windir%\system32.
- From a shell running in the directory containing instsrv and srvany type:
(Replace C:\DirectoryContaining\ as appropriate)instsrv Rsync "C:DirectoryContainingsrvany.exesrvany.exe"
- You should now have a new service called Rsync and you can verify by looking in Start->Control Panel->Services (you can also open services.msc from a run command on 2000 or newer)
DON'T START IT YET! - If you want to run rsync in daemon mode you will need a configuration file. Here is the one I use, call it rsyncd.conf and place it in the same directory as rsync
(C:\Program files\rsync\rsyncd.conf)use chroot = false strict modes = false hosts allow = * log file = c:/rsyncd.log [Repl] path = C:/rsync/ read only = no
(The command line to connect would look somthing like "rsync -avz server::BackupArea", where server is the name of the server running the rsync daemon.)
The first two lines are important for rsync to work on Windows. - You are going to need to hack some keys in the registry to make it work. Don't do this unless you are comfortable with the changes! Run regedit32 and add the following keys and values (quotation marks ARE IMPORTANT):
HKEY_LOCAL_MACHINE->SYSTEM->CurrentControlSet->Services->Rsync Edit->Add Key-> Key Name: Parameters Edit->Add Value-> Value Name: AppDirectory Value: "C:Program Filesrsync" Edit->Add Value-> Value Name: Application Value: "C:Program Filesrsyncrsync.exe" Edit->Add Value-> Value Name: AppParameters Value: --config="C:Program Filesrsyncrsyncd.conf" --daemon --no-detach
If you would like to add these keys automatically, there is a .reg file in the rsync.zip file hosted at the top. Just double click on rsync-param.reg
Rsync server uses port 873 by default. You can update registry to specify a new port :
[HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesRsyncServerParameters] "AppArgs"="--config rsyncd.conf --daemon --no-detach --port=new-port-number"
Remember, unless you trust me implicitly, read the reg file and make sure you understand what it's doing before you run it, I will not be held responsible for idiots.
- You will probably have to open up the services control panel and double click on the Rsync service. Open the Log On tab and either change it to logon using the Local System account or edit the account information to a valid login account.
- That's it, you should be able to start and stop the rsync service at will using the Services Control Panel. When running with the above configuration you should be able to test by attempting to telnet to port 873 from a remote machine. telnet rsync.server.com 873 (replacing rsync.server.com with your own server's address and the port) You should get a connection to the rsync daemon running on your server.
Then you may want to use rsync on another machine to rsync something.
your rsync command will be in the following format (but not exactly this):
rsync -avz --delete --exclude '.Bad files' '/cygdrive/f/Public/toBakup' rsync://remoteserv:87/Repl
Let's break this command down. Here you're calling rsync using the -a, v, z options (archive, verbose and use compression, respectively). It should delete any files that exist on the destination that don't exist on the source(--delete), and it should exclude all files called '.Bad files' (--exclude, because we don't need to backup the annoying little system files). The file source is on the drive f: /cygdrive/f/Public/toBakup on the source and the destination as defined on the server remotesrv named Repl (see conf file) on port 87.
Once you do and hit Enter, rsync will spring into action, and start transferring the files on the source and mirroring them in the destination directory on your server. The -v switch (verbose) means you'll see all the action as it's happening. check the rsync man for more switches.
Like all good command line interaction, the secret sauce which bends rsync to your will lies in the usage switches you provide it in the rsync call (ie, rsync -avz). To see all the available options, type rsync -h at the command line. A few of the more interesting ones are:
-r, --recursive recurse into directories -u, --update skip files that are newer on the receiver -n, --dry-run show what would have been transferred --existing only update files that already exist on receiver --delete delete files that don't exist on the sending side -z, --compress compress file data during the transfer --exclude=PATTERN exclude files matching PATTERN
If you're just getting started with rsync, the -n ("dry run") switch with -v (verbose) is a great way to see what files would get copied without actually performing the copy. Use that switch to test out your rsync recipe before you run it.
It runs well but a few questions remain:
Can it copy files in use?
How to preserve NTFS attributes?
I have found a few answers for the first one. The answer is quite simple: use VSS (volume shadow copy). go to the VSS MS ressource site and download the kit. Then you should be able to create Volume shadow in no time and copy files in use.
You would also like to read from the guy who wrote VSS:
Link to blog: http://blogs.msdn.com/adioltean
Link to first script: http://blogs.msdn.com/adioltean/archive/2005/01/20/357836.aspx
Link to second script: http://blogs.msdn.com/adioltean/archive/2005/01/05/346793.aspx
I am granting with an example I found:
SHADOWRSYNC.CMD setlocal @REM test if we are called by shadowrsync.cmd if NOT "%CALLBACK_SCRIPT%"=="" goto :IS_CALLBACK @REM @REM Set these variables to what you need. @REM SHADOW_DRIVE_LETTER is an existing drive you want to shadow @REM @REM MAP_SHADOW_TO needs to be either a drive letter that isn't @REM currently in use, or an empty directory @REM eg. x: or c:tempshadowcopy @REM set SHADOW_DRIVE_LETTER=D: set MAP_SHADOW_TO=X: @REM @REM Create the shadow copy - and generate env variables into a temporary script. @REM Then resursively come back into this script. set CALLBACK_SCRIPT=%~dpnx0 set TEMP_GENERATED_SCRIPT=GeneratedTempScript.cmd @echo ...Create the shadow copy... vshadow.exe -nw -p -script=%TEMP_GENERATED_SCRIPT% -exec=%CALLBACK_SCRIPT% %SHADOW_DRIVE_LETTER% del /f %TEMP_GENERATED_SCRIPT% @goto :EOF :IS_CALLBACK setlocal @REM Get the vshadow temp variables. call %TEMP_GENERATED_SCRIPT% @REM Map the drive to the shadow copy vshadow -el=%SHADOW_ID_1%,%MAP_SHADOW_TO% @REM Now do your rsync thing rsync blah blah blah blah........ @REM Delete the shadow vshadow -ds=%SHADOW_ID_1%
I still have to try this but I am sure it would work as it works for my backup software I usually use. In some way it looks like we are getting closer to DPM (Microsoft Data Protection Manager), a new MS software that almost continuously sync some contents for a user managed restore or for backup. maybe I should work on a GNU DPM eh!
I still have no answer about how to preserve NTFS attribute, since rsync is from the unix world and the NTFS mechanism is quite complex I am not they are very compatible. If only it were, this would be very useful for restore - just restore the data or switch to another server.
Mac OSx86 10.4.6 on Thinkpad T60
i have previously explained how to install OSx86 aka MacOS X on a T60 thinkpad 200762U, I would like here really sum up everything you need for the post OS install.
After installing the OS you will get a working T60 with no sound, a lousy resolution and no wireless. Let's review one after another.
Sound
1) Delete AppleHDA.kext:
* In Terminal, type: sudo rm -rf /System/Library/Extensions/AppleHDA.kext * sudo rm -rf /System/Library/Extensions.mkext * sudo rm -rf /System/Library/Extensions.kext
2) Edit AppleAzaliaAudio.kext:
* In Terminal, type: sudo pico /System/Library/Extensions/AppleAzaliaAudio.kext/Contents/Info.plist * Search for (use hotkey= ctrl + w): IOHDAudioCodecVendorID * change the string to: 0x10ec0882 * Exit pico * sudo pico /System/Library/Extensions/AppleAzaliaAudio.kext/Contents/PlugIns/AppleAzaliaController.kext/Contents/Info.plist * Search for (use hotkey= ctrl + w): IOPCIPrimaryMatch * change the string to: 0x27d88086 * Exit pico
3) Clean up the system:
* In Terminal, type: sudo kextload /System/Library/Extensions/AppleAzaliaAudio.kext * kextcache -k /System/Library/Extensions/
4) Then, reboot and enjoy sound out of two channels.
Video
1) Open the file:
/System/Library/Extensions/ATIRadeonX1000.kext/Contents/Info.plist
2) and find the line "IOPCIMatch". Modify the next line to say: "0x71091002 0x71C41002 0x71C01002"
3) Open the file "/Library/Preferences/SystemConfiguration/com.apple.Boot.plist"
4) after the lines:
"Boot Graphics
Yes"
add the lines:"Graphics Mode 1400x1050x32"
Wireless
The 200762U has the ThinkPad 11a/b/g Wireless LAN Mini-PCI Express Adapter (lenovo.com part #: 40Y7026) which is compatible with OSx
1) You must download the Apple 10.4.5 intel upgrade available here
2) You must also download a program called Pacifist available here
3) Install Pacifist and double click on the apple upgrade to mount it.
4) Next, open up pacifist and browse to the file inside the mounted image called "MacOSXUpd10.4.5Intel.pkg".
5) After it opens, click "find" and search for "IO80211Family.kext". Drag that file into the folder: "/System/Library/Extensions/" replacing any pre-existing files.
6) Delete the files "/System/Library/Extensions.kextcache" and "/System/Library/Extensions.mkext"
And reboot! Alternatively you may want to check if your wireless worked before rebooting.
7) open the disk utility (/Application/Utilities/Disk Utility), then repair permissions on your Startup volume (may take a little while)
open up terminal, and switch to root (enter sudo -s, enter your user password)
cd /System/Library/Extensions chmod -R 755 IO80211family.kext chown -R root:wheel IO80211family.kext
then list the contents
ls -l
make sure the IO80211Family line looks like this:
drwxr-xr-x 3 root wheel 102 Feb 2 2006 IO80211Family.kext
check that the permissions propagated to subdirectories:
cd IO80211Family.kext/contents/plugins ls -l
should look like this:
total 0 drwxr-xr-x 3 root wheel 102 Feb 2 2006 AirPortAtheros5424.kext drwxr-xr-x 3 root wheel 102 Feb 2 2006 AppleAirPortBrcm4311.kext
then test that the extensions works:
kextload AirPortAtheros5424.kext
should give a extension loaded successfully message
then you have to go to System Preferences>Network
a message should pop up telling you you have a new AirPort. from the Show: box, pick AirPort. you can set the options here, i suggest you check the Show airport status in menu bar, make sure you click apply now.
There you have it, fully working native Atheros card!
To do now is to get the BlueTooth working...
KitKatNeko