Category: sysadmin-tips

CSVDE and Active Directory

While working heavily in Active Directory in previous jobs, I came across a very simple and useful tool that can be used to pull information from AD – this tool is called CSVDE (stands for Comma Separated Value Data Exchange). Whether you need some quick information about a few user accounts or thousands of computer objects, CSVDE will prove useful in no time.

My first experience with the CSVDE tool was when I had a task to create a list of all disabled users in Active Directory. In a company with hundreds or thousands of user accounts, it might prove beneficial to have some sort of tool or script built, that would help with this task. Instead of trying to make my own script to do this, I did a quick Google search and came across the built-in tool. CSVDE is extremely useful whether you are trying to gather information or even import AD information to another domain. It is built into Windows 2008 and can easily be installed with the AD DS server role (you’ll find it under the C:\Windows\System32 folder). It can also run under the other Windows Server OSes – 2003/R2, 2008/R2, and 2012.

…so once I ensured that the csvde program was already installed, I got my command prompt up and running, and navigated into the directory (command is ‘cd c:\windows\system32’). By default, CSVDE will export, unless you specify the import parameter (-i). So to quickly get a list of all users and computers into a .csv file on my server, I would simply run ‘csvde.exe -f c:\adinfo.csv’. This will export all of the Active Directory information into a comma separated value under my C:\ drive. I’ll be going into more detail in a future video series (yes, I’m planning to start mini tutorials via YouTube…hopefully they help out some people). You can export specific parts of a user or computer object by using the delimiter parameter (-d), which will make it much easier/cleaner to read. Another quick tip is to have Excel installed when opening the .csv file…I tend to find it easier to read with Excel versus Notepad.

Happy Sys Admin Day!

Hopefully all the sys admins out there enjoyed the 17th Sys Admin Appreciation Day! Maybe some folks at work got you some gifts or free coffee and food?

To “celebrate”, I’m providing a link to download Microsoft’s ‘Account Lockout Status’ tool. This nifty little executable can be run on any Windows domain controller to find the status of a specific user account. It provides the number of bad password attempts, the date/time of the last bad attempt, and the date/time that the password was reset for the user. It has definitely proven helpful when starting the adventure in finding out why a user is always locking out from systems. Hopefully you find this helpful!

Quickly find uptime of Windows server

When trying to figure out the uptime of a Windows server, there is no clear cut answer when looking at Task Manager or in the Control Panel. To quickly find out the uptime, do the following:

  1. click ‘Start’
  2. type ‘cmd’ (without quotes)
  3. click the Command Prompt application
  4. once in the app, type ‘net stats server’ and press Enter
  5. in the results that populate, look for the line starting with ‘Statistics since…’ and you should see a date and time next to it. That is the last time that the computer booted up.

That’s it…a nice, quick and easy tutorial to get that (what seems to be hidden) Windows server uptime!

How to speed up your old desktops or laptops in Windows

We typically see newer systems being purchased for a household or business because “it’s too slow” or “it doesn’t work”. Before going out hunting for the latest, greatest, and fastest piece of equipment, you really should ask yourself if you can get it working again. Over the past 15 years or so, I’ve cleaned up Windows desktops and laptops so that they run faster than when they were originally handed to me. Fortunately, Windows has some easy tweaks that you can make to get things running more efficiently. The tweaks below should mostly work with Windows XP, Vista, and 7 (I have not played around with 8/8.1/10 that much….yet):

  1. Appearance vs. Performance:
    • If your old system is going to be tossed out the window, I’m guessing that you don’t mind how it looks vs. how it performs
    • A quick tip to get Windows working faster (with a small decrease in visual appeal) would be to remove the fancy graphics and visualizations that Windows typically has setup by default
    • To do this: click ‘Start’ – right-click ‘Computer’ – click ‘Properties’ – click ‘Advanced’ tab – click ‘Settings’ (in ‘Performance’ section) – select ‘Adjust for best performance’ radio button
  2. Remove old software:
    • Just having extra software from 6 years ago, that you don’t use anymore, is completely pointless to keep on your computer. The only reason to keep this software is if it’s a dependency for a more current version of the software that you’re running (I’ve never seen software in the last 8 or so years that keeps the old version around for the current version to run properly)
    • Windows XP: click ‘Start’ – click ‘Control Panel’ – click ‘Add or Remove Programs’ and then select which programs to remove
    • Windows Vista/7: click ‘Start’ – click ‘Control Panel’ – click ‘Programs’ – click ‘Programs and Features’, and then select which programs you want to uninstall (so this is almost exactly like Windows XP, except for the small name change of ‘Add or Remove Programs’ to be ‘Programs and Features’)
  3. Clean up old data
    • So nowadays, we have 1TB drives and data in the cloud, but for our old hunks of junk, we might have some smaller drives, and large amounts of music or movies filling it up
    • Windows XP: click ‘Start’ – click ‘All Programs’ – click ‘Accessories’ – click ‘System Tools’ – click ‘Disk Cleanup’ . Disk Cleanup was really easy to find and use….or maybe it’s just the fact that I used XP for so very long
    • Windows Vista/7: click ‘Start’ – click ‘Computer’ – right-click your C: drive and click ‘Properties’ – click ‘Disk Cleanup’ in the window that opens
    • Overall, Disk Cleanup is a great tool to easily free up space on any drive (temp files, compresses files, empties your trash, etc)
    • Another method which I tend to use is the manual method. Yes, I simply scope out my various folders and decide what stays and what gets axed.

There are plenty of other methods to enhance upon your Windows operating system. I’ll be adding some more of these in a later post.

PS Tools

PS Tools is a resource kit that is part of the Windows Sysinternals suite of tools provided by Microsoft. It’s free to download and easy to get started using this variety pack of goodies. Mainly geared for system administrators in the business sector, PS Tools provides a variety pack of commands that can be run to help a sys admin out in their day-to-day tasks. Some of the top tools that I’ve used are PsLoggedOn, PsShutdown, PsExec, and PsKill. I’ll highlight their uses and basic syntax below (ensure that you are in the parent directory of PS Tools before running the commands in the command prompt).

PsLoggedOn – if you’re trying to figure out who is logged onto a remote computer, this is the best tool to use that I’ve found (there are others out there like NetUsers or even Windows Server’s ‘Remote Desktop Services Manager’ or ‘query’ command). Common syntax is:
PsLoggedOn.exe \\SERVER-NAME

PsShutdown – does exactly what you would think it does….yes, it shuts down a remote computer. Interestingly enough, it can also reboot, log off, and lock a remote computer as well. For our purposes, the basic syntax to shutdown a remote system is:
PsShutdown.exe \\SERVER-NAME

PsExec – this is a great tool to execute or run remote processes on remote systems. This command is a little more tricky since you can pass specific options to run a process or executable, and these options might not exactly be options (more like requirements depending on the scenario). So if you have an executable file on your server where PS Tools runs and you want it to run on a remote server, the syntax would involve copying the executable onto the remote system and running it (-c is used to specify the copy portion and test-application.exe is the name of the executable that you want to run remotely):
PsExec.exe \\SERVER-NAME -c C:\test-application.exe

PsKill – another great tool that I’ve used frequently to kill processes remotely. If you’ve used Windows for a while and start to remember process names that could typically be running, then you don’t need to use PsInfo to gather the process information or IDs. In the case that you have a great memory, just run PsKill using the following syntax (notepad.exe is an easily remembered process, along with word.exe, excel.exe, outlook.exe, iexplore.exe, firefox.exe, explorer.exe, etc):
PsKill.exe \\SERVER-NAME notepad.exe

SATA drive testing

Requirements:

  • Laptop or desktop with Windows 7 (or higher)
  • Cygwin installed with smartmontools
  • SATA to USB docking station or cable adapter
  • 2.5” or 3.5” SATA hard drive to be tested

Steps:

  1. Power on the laptop and plugin the SATA to USB (dock or adapter)
  2. Plug the hard drive into the dock or adapter
  3. Wait a few moments and Windows should start installing the drivers for the SATA to USB device
  4. After drivers are all loaded, open Cygwin (Run as Administrator)
  5. Type ‘smartctl -a /dev/sdb -d sat’ and press Enter (Note: you might need to use a variation for the device itself (sdb, sdc, etc) or the type of device (ata, sat, usbjmicron, etc)
  6. After you are able to get the basic hard drive information from the command above, you will now need to run a short offline test, using the command from above with the addition of ‘-t short’ (Ex: smartctl -a /dev/sdb -d sat -t short)
  7. After the short offline test completes successfully, you can run an extended offline test with the command from above with the addition of ‘-t long’ (Ex: smartctl -a /dev/sdb -d sat -t long)