Simple backup to USB Script
Here’s a simple script to help you backup one critical folder to your USB drive.
Here is how the script works. The script resides on the root of your USB drive and not on your computer. When you insert the drive, an autorun window pops up asking you if you would like to run the backup. If you choose to run the backup, the script checks your computer’s SID against a previously stored SID (I will explain how you can store that SID) and if they match, the script then uses robocopy to mirror your source folder to the USB drive. The SID check was put in place to prevent the script from accidentally removing important data.
How to use the script: Read the rest of this entry »
Update all Windows servers on a network
Microsoft’s patch tuesday is one time of the month when all Windows system admins get cold sweats. Will these patches break something? How much time will I have to spend patching all these servers?
Well, I have no control over Microsoft’s patch quality but I sure have a script that will help ease your pain when it comes to patching servers.
This script will help you update all windows servers on a network with just one click. You will also get an email report when the script has completed patching a server.
What the script does:
Script to reboot all servers in a network
Windows updates almost always require that you reboot your servers after a round of patching. Windows Admins would not really envy the task of rebooting servers after patching.
I have created a script that does the following:
- Reboots all servers defined in a simple text file.
- Reboots servers one at a time in a “rolling reboot” fashion.
- Notifies you if a server hangs at any point in the reboot cycle (during shutdown, POST or boot up. There are parameters that can be configured to adjust the script to your network.
- Checks to make sure that the RPC server service has started up before going onto reboot the next server.
- Extract the script to a location (preferrably on your second domain controller/DNS server)
- Edit the batch file and edit the parameters between *** TUNEABLE PARAMETERS ***. Update the mail server, to and from info here if you would like email alerts, please remember, if you are rebooting your mail server as part of this, you should use another external relay method to send emails.
- Edit the serverlist.txt file. This file should be populated with a list of servers in the order they will be rebooted in. Always exclude the name of the server you are performing the reboots from if you need to reboot it as well. Include all servers only if you are performing reboots from a workstation. In this case, you will need to ensure that the workstation can resolve DNS names for all the servers being rebooted.
Get a list of all email addresses for all Exchange Mailboxes
Here’s a handy script to give you a list of all Email Addresses for all Exchange Mailboxes. This power shell script works both in Exchange 2007 and Exchange 2010.
- To execute the script, copy the code below and save it as a .ps1 file.
- Open up the Exchange Management Shell and cd to the directory where you saved the powershell script.
- Run the script by typing .\script.ps1
- To save the output to a file run it as .\script.ps1 > output.txt
Here’s the Script:
Get-Mailbox | select name , alias ,EmailAddresses | foreach {
"Name: "+$_.name
"Alias: "+$_.alias
$_.EmailAddresses | foreach {
if($_.SmtpAddress){
if($_.IsPrimaryAddress){
"Primary SmtpAddress: $($_.SmtpAddress)"
} else {
"SmtpAddress: $($_.SmtpAddress)"
}
}
}
write-host
}
Drop me a line if this has helped you!
Script to clean up user profiles in a Citrix farm
You may have found yourself in a situation where you have had to rebuild a user’s profile to fix an issue or clean up old users’ local cached profiles from Citrix servers after they have left the organization. This wont pose a huge problem if your Citrix farm is small. But if you have a large enough farm, going through this process of properly cleaning a user profile would be a very time consuming process.
The following steps are involved in properly cleaning up a user’s profile:
- Delete the registry key HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfileList\<SID OF THE USER> on all servers.
- Take ownership of the user’s local profile folder on all Citrix servers (Eg: C:\Users\JohnDoe)
- Delete the local user profile folder on all Citrix servers.
- Take ownership of the user’s redirected folder (Eg: E:\USER_FOLDERS)
- Backup the user’s redirected folder.
- Take ownership of the user’s terminal server profile (Eg: E:\USER_PROFILES)
- Backup the user’s terminal server profile.
I’ve hated having to do this manually and so has my team, so I wrote this script that does all the steps mentioned above. Read the rest of this entry »

Recent Comments