Quickly add large numbers of users to a computer or server using addusers.exe

addusers.exe is a great tool that is included in Windows 2000 Resource Kit and is described by Microsoft as “32-bit administrative utility that uses a comma-delimited text file to create, modify, and delete user accounts”. The main benefit is using something like Excel or notepad to create a list of users, passwords and other details and then instantly generating their user accounts. We had to do this recently for almost 100 user accounts and it took seconds once we had written the text file. Although this isn’t officially supported on Windows 2003 or later, it still worked for us.

You can download addusers.exe direct from Microsoft’s FTP server or from Petri.il.

The command we used to import a list of users contained in “listofusers.txt” to our server “servername” using addusers.exe was:

addusers /C C:listofusers.txt \servername /P:LE

Where the text file listofusers.txt looked something like:

[User]
username1,User Fullname,p4ssword,email@somesite.com
username2,User2 Fullname,p4ssword2,email2@somesite.com
[Global]
[Local]

You can do a lot more with addusers.exe but this is a very handy and quick way of managing the creation of large numbers of users.

Easily migrate content between SharePoint servers using stsadm.exe and fix the HTTP 401.1 site collection administrator local login problem

I needed to migrate content from one install of SharePoint Web Services 3.0 on Windows 2003 to another physical server and ran into an issue with checking my site locally before changing all the DNS records over. The actual export and import process is quite easy but can take a while if there are a lot of subsites or files within your SharePoint portal.

Migrating between SharePoint installs using stsadm.exe

The easiest way to export an entire SharePoint site is to use stsadm.exe, which is typically located in “C:Program FilesCommon FilesMicrosoft Sharedweb server extensions12BIN” and is available when you have installed SharePoint. I created a reference to this in the PATH variable so I could use it everywhere to make things easier. Thankfully the documentation is good (thanks Microsoft) and you can find more explicit details on exporting and importing from TechNet. Note that this is similar to other versions of SharePoint and more information on various methods of migration can be found on Microsoft Support, including moving databases directly. Chris O’Brian also has a good post about the various approaches.

The simple stsadm command I used to export my portal (including all files and subsites etc) at http://portal.sitename.com was:

stsadm -o export -url http://portal.sitename.com -filename sitename.bak

This produced a lot of ~30mb files and a good log of everything that took place. All the Active Directory user permissions were also included in the export, which was one of my big worries moving to a new server. For local users you have more of a problem as these don’t exist on the new server and need to be recreated.

To import your site back into another SharePoint install, you have to first make sure there is an existing web application and associated site collection (on the root “/”) before copying over all your exported files to the new server. The first time I tried I assumed it would regenerate the site collection based on my export from scratch, but apparently not. The command I used to import was:

stsadm -o import -url http://portal.sitename.com -filename sitename.bak

Now even though you will probably have a lot of files from the export process, you do not need to specify them all, just the main one, in this case “sitename.bak”. After a while your new site will be populated with all the content from your export and is ready for testing before you go live and change your DNS records to point to the new server.

Testing your newly migrated site locally, avoiding HTTP 401.1

As I was using remote desktop to access my new server to run the stsadm.exe import command I wanted to test the site locally by logging in with my site collection administrator details before changing the DNS over. To do this I set up a reference in my hosts file “C:Windowssystem32driversetchosts” on the new server to point http://portal.sitename.com to localhost (127.0.0.1) then tried to visit http://portal.sitename.com within my remote desktop session. This is where I hit a HTTP 401.1 login error due to a security setting built into Windows 2003, even though I tried logging in with the correct site collection administrator details.

This is apparently a security fix to Windows Server 2003 SP1 that stops reflection attacks and according to Microsoft “authentication fails if the FQDN or the custom host header that you use does not match the local computer name”. The details on how to fix this are located at Microsoft Support and I’ve noted the easiest way to fix this by removing the loopback check entirely.

First you need to disable strict name checking by editing the registry on your server. Open the registry editor (run regedit.exe) and go to “HKEY_LOCAL_MACHINESystemCurrentControlSetServicesLanmanServerParameters”. Now click “Edit -> New -> DWORD Value” and name it “DisableStrictNameChecking” and then right click and set it to decimal “1″.

Now go to “HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlLsa” and click “Edit -> New -> DWORD Value” and name it “DisableLoopbackCheck” and then right click and set it to decimal “1″ as well.

You need to restart your server for the changes to have any effect and once you have you should be able to log in to your local site at http://portal.sitename.com without hitting a HTTP 401.1 error with your site collection administrator details. Now you can test out the site before changing the DNS records to point to the new server and removing your host file record.

Reduce the size of the winsxs directory in Windows 7 using DISM

Looking for ways to shrink the massive Windows 7 install? The winsxs folder was 6.7GB on my tiny 60GB SSD, way too big for something that seems to just hold service pack backups. Microsoft are AWFUL at explaining how to deal with this, numerous searches always come up with “Don’t touch it, it’ll break Windows!”. Thanks to some helpful people on Technet the solution is to use the Deployment Image Servicing and Management Tool (DISM). Just type the following in a command prompt:

dism /online /cleanup-image /spsuperseded

Instantly reduced my winsxs folder from 6.7GB to 4.5GB, which is a fair chunk of space on an SSD.

Allow larger file downloads than 50mb from SharePoint (fix error 0x800700DF)

I ran into a 0x800700DF error when trying to download a 100mb file from SharePoint using Windows Explorer. I tend to do all my file operations in SharePoint with the WebDAV interface by pointing Windows Explorer to \portal.server.nameportal and logging in with an account with permissions to access the portal. The 0x800700DF error when attempting to copy large files is actually described as:

Error 0x800700DF: The file size exceeds the limit allowed and cannot be saved.

The fix involves changing a registry setting on your client machine to allow 4GB downloads (the maximum possible). From Microsoft Answers:

FileSizeLimitInBytes is set to 5000000 which limits your download so just set it to maximum! (this is client side btw on windows 7)

HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/WebClient/Parameters

  • Right click on the FileSizeLimitInBytes and click Modify
  • Click on Decimal
  • In the Value data box, type 4294967295, and then click OK. Note this sets the maximum you can download from the Webdav to 4 gig at one time, I haven’t figured out how to make it unlimited so if you want to download more you need to split it up.

Connect your free wordpress.com blog to Twitter using your RSS feed and Feedburner

This blog is currently hosted for free on wordpress.com, which means it is always up to date and doesn’t rely on my own hosting, unlike my website at jamesrossiter.co.uk. Although there are several advantages to hosting on wordpress.com the main disadvantage is that you can’t load plugins or write your own. One of the plugins I miss most is the WordPress Tweeter plugin, which allows WordPress to integrate nicely with Twitter by posting to Twitter when new posts are written and even when posts are updated.

One workaround for this is to use the built in Publicize feature under Settings – Sharing on your wordpress.com blog. Unfortunately, it’s terrible.. It doesn’t add #hashtags or allow you to customise anything. The alternative is to add your RSS feed to Feedburner.

Once you have signed up to Feedburner and added your RSS feed (http://yourblogname.wordpress.com/feed) open it on the Feedburner dashboard and click on the “Publicize” tab at the top. Now click on the “Add a Twitter Account” and allow Twitter access. Now whenever you create a new post, your RSS feed will be updated and Feedburner will push a link to your new blog post (based on the title) to Twitter.

Send email alerts for low disk space using perfmon.exe in Windows using bmail.exe

I needed to set up email alerts for one of the servers so when disc space dropped below a threshold it would email the team to deal with the issue. I know you can use full monitoring packages for this kind of thing (like Nagios etc) but in this case that kind of monitoring is overkill. I used the bmail.exe command line SMTP mailer from beyondlogic.org but you can use any command line mailer you want really.

First I created a simple .cmd script to send the warning email, making sure to include %1 so as to include any command line arguments produced by perfmon.exe. Apparently if you don’t have any commmand line arguments when you set up alerts the script will not be called:

c:\emailfromcmdbmail.exe -s mail.server.ip -t email@addresstosendto.com -f email@addresstosendfrom -h -a “Disk Space Warning on server.name.com” -b “Less than 100GB free on server.name.com. Please free space to ensure weekly backups can continue. Free: %1 MB”

The direct path to the executable must be explicitly stated, otherwise it will not be called and no error/warning will be shown.

Now open perfmon.exe, expand “Performance Logs and Alerts” – “Alerts”. Right click and select “New Alert Settings…” and choose a name. The comment can be anything.

Now add a counter. I used “LogicalDisk” – “Free Megabytes” – “C:” to select free space on the C drive. Set “Alert when the value is:” to “Under” and the “Limit:” to whatever free space warning you need. I set the sample interval to 3 hours. Now select run as to be an administrator on the machine and set the password.

Click the action tab and select “Run this program:” and put in the path to your .cmd file, in my case “C:emailfromcmdemailteam.cmd”. Select “Measured value” in “Command Line Arguments…”. Now click OK, you may need to enter the password for the user with permission to run your .cmd.

Done, now your server will email you when drive space gets low.

Managing VMWare Server 2 hosts with vSphere

You can download VMWare Server 2 for free and it comes with a web interface to create/manage virtual machines. I ideally wanted something similar to Microsoft System Centre Virtual Machine Manager to manage multiple hosts. Unfortunately you have to pay for both VMWare and Microsoft’s offering (but SCVMM is free on our MSDN subscription).

To manage a single host, without using the slow/buggy web interface you can use the free vSphere management app that comes with the free version of ESXi. You need to download and copy a directory to your install dir of vSphere, which is available here.

Full instructions are available at Andrea Benini’s blog at linux.com.