Categories
Windows

Server 2008 profile deletion

I know we’ve all done this before.. Playing around with GPO’s, scripts or what have you and want to start out fresh so we delete the user profile directory under C:\Documents and Settings\<user name> to force the creation of a new profile directory. My colleague went to do that exact same thing on a Windows Server 2008 and that’s when I found out it’s not that easy on Server 2008.

After doing some searching I found this blog entry by Helge Klein.

It looks like Microsoft has now added a registry key that keeps track of the user profiles and their paths, among other things, and by deleting the directory alone you only solve half the issue and will get profile errors every time that user tries to log in. You will get the unable to load profile error and a new directory, usually C:\USERS\TEMP, will be created for that user.

If you have done this, the easiest way to do this is go to this reg key, 
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
highlight each sub key until you find the "ProfileImagePath" that matches the one your deleted and then delete that key. I also found that you would have to reboot the server in order to complete this fix.

In future the best way to delete the profile is to go My Computer –> Properties –> Advanced System Settings –> User Profiles Settings and then delete the profile from there.

Categories
Windows 7

Can’t delete long or deep folder path

For a while now I’ve been using a scheduled backup that copies my windows profile to my file server on a nightly basis. Well since I switched to Vista and now Windows 7 I’ve noticed something funky.

If you look in your C:\users\<username>\AppData\Local (hidden folder) folder you’ll notice an "Application Data" directory with an icon that looks like it’s a shortcut and that you have no rights to access. Well it seems the Microsoft in all it’s wisdom created a junction point here that basically points back to itself.

So what happens when you have a backup solution that overrides access denied and then attempts to copy this folder is that you copy itself into itself over and over again until you reach the windows folder depth limit and error out. You end up with something like this but MUCH deeper

 folders.jpg

Well I search for about an hour and finally found a solution on Windows IT Pro, JSI Tip 9651.

By using RobCopy, which is now part of Vista and Windows 7, this script will automatically delete the deep/long folder structure. If you’re not runing Vista or Windows 7, make sure a copy of RoboCopy.exe is in the same folder as the batch file.

Copy and paste this into notepad and save as DelFolder.bat. The syntax is DelFolder.bat <FolderPath>:

@echo off
if {%1}=={} @echo Syntax: DelFolder FolderPath&goto :EOF
if not exist %1 @echo Syntax: DelFolder FolderPath – %1 NOT found.&goto :EOF
setlocal
set folder=%1
set MT="%TEMP%\DelFolder_%RANDOM%"
MD %MT%
RoboCopy %MT% %folder% /MIR
RD /S /Q %MT%
RD /S /Q %folder%
endlocal

Categories
Linux

Enable SSH on ESXi

ESXi 3.5 does have SSH capablities but it is disabled and not supported by default. If you want to enable it, follow these steps:

  1. At the ESXi console press ALT-F1
  2. Type in "unsupported" and press Enter. You will not see the text as you type.
  3. You will see a Tech Support Mode warning and be prompted for the root password. Enter the root password and press enter
  4. Edit the inetd.conf file located at /etc/inetd.conf using VI
  5. Scroll down the file till you find the file that stares with #ssh, move the cursor over the # and press x
  6. Exit and Save by pressing ESC and typing :wq
  7. Type in "ps | grep inetd" and take note of the process ID
  8. Type in "kill -HUP <process ID from step 7>"
  9. You can now SSH in to the ESXi host

UPDATE: Confirmed to be working on ESXi 4.0 also

Categories
Exchange

How to Authenticate to SMTP server via Command Line

Recently I had to prove to an application admin that the user he was using to send SMTP email was able to authenticate and properly send email via SMTP. The easiest way to prove that this was a configuration issue with the application and not a SMTP issue was to do it from the server via command line.

Steps to send SMTP email and authenticate:

Telnet to server on port 25

telnet servername 25

Type EHLO

EHLO
250-servername.domain.com Hello [10.149.1.55]
250-TURN
250-SIZE
250-ETRN
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-8bitmime
250-BINARYMIME
250-CHUNKING
250-VRFY
250-X-EXPS GSSAPI NTLM LOGIN
250-X-EXPS=LOGIN
250-AUTH GSSAPI NTLM LOGIN
250-AUTH=LOGIN
250-X-LINK2STATE
250-XEXCH50
250 OK

This is were it got interesting. It seems that an SMTP server asks and expects answers in Base64. For example, "VXNlcm5hbWU6" in Base64 means "Username:" and "UGFzc3dvcmQ6" means "Password:"
You can find a few Base64 encoders/decoders on the need just by googling it, I used makcoder.sourceforge.net/demo/base64.php.

So in order to authenticate to the SMTP server you will need to encode the username and password to Base64:
"Username" = "VXNlcm5hbWU="
"Password" = "UGFzc3dvcmQ="

Now to auth to the server:

Type AUTH login

AUTH login
334 VXNlcm5hbWU6

Enter the Base64 username and press enter:

VXNlcm5hbWU=

Next enter the Base64 password followed by enter

334 UGFzc3dvcmQ6
UGFzc3dvcmQ=
235 2.7.0 Authentication successful.

This shows that the user was able to authenticate and then all that’s next is to send a test email and then confirm that the mailbox recieved it

MAIL FROM: username@domain.com
250 2.1.0 username@domain.com….Sender OK
RCPT TO: username@domain.com
250 2.1.5 username@domain.com
DATA
354 Start mail input; end with <CRLF>.<CRLF>
This is a test SMTP email from application server
.
250 2.6.0 <servernameLrLySMy00000002@servername.domain.com> Queued mail for delivery

Categories
Linux

Grant Shell access (SSH) to Root on ESX 3.5 update 2

If you’d like to allow shell access to the root account on ESX 3.5 Update 2 you need to modify the sshd_config file.

  1. Login into the console using the root account
  2. Edit the sshd_config file
     

    vi /etc/ssh/sshd_config

  3. Find "PermitRootLogin no" and change to "PermitRootLogin yes"
  4. Restart the sshd server
     

    service sshd restart

Categories
Vista

Turn off DEP on Windows Vista and NO BOOT.INI

If your used to turning DEP off completely on Windows XP you’ll have a hard time doing it on Vista.

The BOOT.INI file that is in Windows XP is now gone in Vista so you can’t just edit it to turn off DEP.

Windows Vista now comes with a command line tool called BCDEDIT.EXE that will edit the boot configs for you. It’s actually easier then editing the BOOT.INI file but only if you know the command to do it.

So here’s the command, make sure you run in with elevated priviledges.

Turn OFF DEP:
 

bcdedit.exe /set {current} nx AlwaysOff

Turn ON DEP:
 

bcdedit.exe /set {current} nx AlwaysOn

 

Categories
Windows

Convert accountExpires attribute in AD to date

If you’ve ever exported the accountExpires attribute from AD you’ll notice that it’s an 64-bit number. It represents the number of 100-nanosecond intervals since 12:00 AM January 1, 1601 in UTC. What this means is that it’s practically impossible to read unless your a math genius. 😉

Here is a quick VBS script that will take that number and convert it to a real date:

Dim WshShell, oExec, objArgs, exe, work
Set WshShell = CreateObject("WScript.Shell")
Set objArgs = Wscript.Arguments
if objArgs.count = 0 Then
Wscript.Echo "FileTime argument required"
Wscript.Quit
end If
exe = "w32tm.exe /ntte " & objArgs(0)
set oExec = WshShell.Exec(exe)
Do While oExec.Status = 0
WScript.Sleep 100
Loop
work = Split(oExec.StdOut.Read(60))
Wscript.Echo work(3) & " " & work(4)

Just copy and paste this into notepad and save as finddate.vbs. Then just run "finddate.vbs <accountExpires value>"

Finddate.vbs 128674944000000000

Would result in this pop up:

date.jpg

Categories
Windows

Replace Notepad with Notepad2

I find that Notepad2 from www.flos-freeware.ch is a vast improvment on the notepad that ships with Windows.

But as usual MS has made it very difficult to replace any system file so here’s a quick and easy way to replace your regular notepad with notepad2.

  1. First download Notepad2 and extract it.
  2. Rename notepad2.exe to notepad.exe
  3. Open Explorer and navigate to %systemroot%\ServicePackFiles\I386
  4. Rename notepad.exe in that folder to notepad.exe.old and copy the new notepad.exe
  5. Do the same for %systemroot%\system32\dllcache and %systemroot%\system32

You will need to ensure that you have "Display contents of system folders" and "Show hidden files and folders" checked and "Hide protected operating ssytem files" unchecked.

When you make the switch you may get a pop up warning you that some system files maybe be changed, just cancel and and your good to go.

Categories
Windows

Easy way to get Display name from list of UserID’s from AD

This is a quick one line command that I created to return a list of Display names when all I had was UserID’s.

It’s a simple DSQUERY command piped into a DSGET to return the Display Name and SAMID of the user. Just have a look of at the DSGET command you can see all the different attributes that i can return for you.

First you need a text file with UserID’s one per line. Then just open a command prompt in the same directory where you have the text files and run this command, don’t forget to change the USERID.TXT to the name of your text file:
 

FOR /F %i in (userid.txt) DO DSQUERY user -samid %i | DSGET user -display -samid >> displayname.txt

You’ll now find a text file in that directory named displayname.txt with all your Display Names.

Categories
General

Welcome to Technical411.info | Introduction

My friend, Rod and I, were thinking that after being in the IT industry for almost a decade, we needed to start keeping a repository of all the technical information that we have come across and/or figured out.

I’m sure many of you IT people out there have recovered from an issue but then a month, 6 months, a year later you came across the same issue but couldn’t remember how you solved the problem.

This is why we decided to start up our blog repository. We will try to update this blog whenever we come across one of those issues so that not only we have a place to store the information but perhaps it may help other IT people help them solve thiers.

Bear with us as we experiment with different blog formats and get this site going.

If you’d like any information on myself or Rod feel free to send us an email at info@technical411.info.

Mike