Category Archives: Microsoft

DNS Zone export to TXT & Clear DNS

Exports the contents of the specific DNS zone to a .txt file. Just makes the process easier for debugging etc, when dealing with larger DNS zones:

dnscmd /zoneexport domain.com c:\zones-export.txt

Clears the local computer cache.

Ipconfig /flushdns

Clears the DNS server cache.

dnscmd /clearcache

Terminal Services Licensing service cannot start Server 2008

Event Viewer displays:

  1. The Terminal Services Licensing service cannot start. The following error occurred: Can’t initialize Cryptographic – error code 8009000f.
  2. An error occurred during the Terminal Services license server initialization phase.
  3. To resolve this issue, ensure that required groups are granted the correct permissions to the TermServLicensing registry key and that the value of the DBPath registry key matches the location of the LServer directory. If the problem persists, shut down and then restart the Terminal Services license server

Fix:

  • Change permissions on C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys
  • Manually restarted the service (service.msc)

In my case, Local administrator already had full access. Added Domain Admin (Full Access) and Network Services (Full Access)

Check this article which pointed me in the right direction: http://msdn.microsoft.com/en-us/library/bb909654(VS.90).aspx

Next…

Now with the above problem solved… we then move onto our next problem:

http://blogs.msdn.com/b/rds/archive/2010/03/30/event-17-certificate-corruption-on-terminal-services-remote-desktop-license-servers.aspx#CertDeletion

Another useful link:

http://www.windowsitpro.com/article/licensing/jsi-tip-9040-you-cannot-activate-a-terminal-services-license-server-in-a-windows-server-.aspx

Exchange *.Log File Removal (BAT)

It is BAD BAD practice to try and delete the exchange 2007 log files! It should not be done ever!

Running into space issues on exchange needed to remove 80,000+ *.log files. These would be removed by doing a backup, but without any space to run the backup there’s not a lot of options.

I ran this command to perform a removal of the log files in the mailbox DB, I had to use this script the job as the windows would crash as soon as multiple files were highlighted and selected for deletion:

  • CD /D E:\Exchange\Mailbox\First Storage Group
  • del /s *.txt

In order to move logs onto another drive use this command:

  • CD /D E:\Exchange\Mailbox\First Storage Group
  • move *.log “K:\Exchange_Logs_Move”

DO NOT DELETE / REMOVE THFOLLOWING FILES:

  • E00.chk
  • E00.log
  • Mailbox Database.edb

Add Network Printer via VBS

Use the script below to add a network printer, you can simply dump this into a txt file, rename to a .VBS and change the printer addresses (these need to be shared of course!)
The last bit of code should stop the “Error: 8007007B – the filename, directory name, or volume label syntax is incorrect” as it will keep retrying the connection to the printer share if the network is slow and timming out etc.

Last bit is to drop the script into the DC netlogon and add to group policy! BAMM!


Dim net
Set net = CreateObject("WScript.Network")
net.AddWindowsPrinterConnection "\\server\printer"
net.SetDefaultPrinter "\\server\printer"

MapPrinter "\\server\printer"

Sub MapPrinter(strPrinter)
On Error Resume Next
Set objNetwork = CreateObject("WScript.Network")
boolConnected = False
intAttempts = 1
While boolConnected = False And intAttempts <= 5
Err.Clear
objNetwork.AddWindowsPrinterConnection strPrinter
If Err.Number <> 0 Then
intAttempts = intAttempts + 1
WScript.Sleep 2000
Else
boolConnected = True
End If
Wend
End Sub

“Active Desktop Recovery” / Script Error

“Active Desktop Recovery”

“An error has occurred in a script on this page”

Not 100% sure why this error occurs, however if you bung this information into a VBS file and run “hey-presto” the error is gone and the background is back to normal. I have only seen this when there is a GP in place that sets the background and doesn’t allow it to be changed by the user, I think this could be why it can’t just be changed back!

Most other fixes I’ve tried mean you have to reset the computer or uninstall/reinstall Internet Explorer (IE), I must have wasted hours on this problem until I found this script!

Option Explicit
' Create the Shell object
Dim objShell
Set objShell = CreateObject("WScript.Shell")
'Change values that mess up IE 7 from decimal 272 to 0
objShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Internet
Explorer\Desktop\SafeMode\Components\DeskHtmlVersion", "0",
"REG_DWORD"
objShell.AppActivate "Program Manager"
objShell.SendKeys "{F5}"
WScript.Quit

RDP via TS Web “error occurred… Desktop Gateway server.”

Problem connecting to server via RDP when using the TS web interface.

  1. Login OK to the TS Web Interface.
  2. Click “Connect” to server
  3. RDP Loads…
  4. Error displays: “An error occurred while sending data to the Remote Desktop Gateway server. The server is temporarily unavailable or a network connection is down. Try again later, or contact your network administrator for assistance.”

Note: This problem is related to newer features in RDP v7 which are not installed by default on Windows XP Service Pack 3 (SP3), Windows Vista Service Pack 1 (SP1), and Windows Vista Service Pack 2 (SP2)

Fix:

Turn on CredSSP.

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa
Right-click -> Security Packages -> Modify -> type “tspkg”. (Leave other info) -> click OK.

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders

Right-click -> SecurityProviders -> Modify -> type “credssp.dll” (Leave other info) -> click OK.

Exit -> Restart computer

Outlook 2007 | Cached Mode

In order to change outlook to allow cached exchange mode for multiple mailboxes change the following reg key:

Key: HKCU\Software\Microsoft\Office\12.0\Outlook\Cached Mode
DWORD: CacheOthersMail
Value: 1

Close Outlook, after you have changed / added this key start Outlook.
When you access the shared mailboxes – the first time it will download the content then after this access will be much faster – same as your main mailbox

Note: this fix is also in Office SP2 so best off just updating the SP.

Windows | % System path variables %

%AppData%

Contains the full path to the Application Data folder of the logged-in user. Does not work on Windows NT 4.0 SP6 UK.

%ComSpec%

This variable contains the full path to the command processor; on Windows NT based operating systems this is cmd.exe, while on Windows 9x and ME it is the DOS command processor, COMMAND.COM.

%Localappdata%

This variable is the temporary files of Applications. Its uses include storing of Desktop Themes, Windows Error Reporting, Caching and profiles of web browsers.

%Path%

This variable contains a semicolon-delimited (do not put spaces in between) list of directories in which the command interpreter will search for an executable file that matches the given command. Equivalent to the Unix $PATH variable.

%ProgramFiles%

This variable points to Program Files directory, which stores all the installed program of Windows and others. The default on English-language systems is C:\Program Files. In 64-bit editions of Windows (XP, 2003, Vista), there are also %ProgramFiles(x86)% which defaults to C:\Program Files (x86) and %ProgramW6432% which defaults to C:\Program Files.

The %ProgramFiles% itself depends on whether the process requesting the environment variable is itself 32-bit or 64-bit (this is caused by Windows-on-Windows 64-bitredirection).

%CommonProgramFiles%

This variable points to Common Files directory. The default is C:\Program Files\Common Files.

%SystemDrive%

The %SystemDrive% variable is a special system-wide environment variable found on Microsoft Windows NT and its derivatives. Its value is the drive upon which the system folder was placed. Also see next item.

The value of %SystemDrive% is in most cases C:.

%SystemRoot%

The %SystemRoot% variable is a special system-wide environment variable found on Microsoft Windows NT and its derivatives. Its value is the location of the system folder, including the drive and path.

The drive is the same as %SystemDrive% and the default path on a clean installation depends upon the version of the operating system. By default, on a clean installation:

Windows NT 5.1 (Windows XP) and newer versions use \WINDOWS

Windows NT 5.0 (Windows 2000), Windows NT 4.0 and Windows NT 3.1 use \WINNT

Windows NT 3.5x uses \WINNT35

%WinDir%

This variable points to the Windows directory (on Windows NT-based operating systems it is identical to the %SystemRoot% variable, above). If the System is on drive C: then the default values are:

C:\WINDOWS on Windows 95, Windows 98, Windows Me, Windows XP, Windows Server 2003, Windows Vista,Windows Server 2008 and Windows 7

C:\WINNT for Windows NT 4, and Windows 2000

Note that Windows NT 4 Terminal Server Edition by default installs to C:\WTSRV.

%Logonserver%

Awesome little short-cut. Allows us to get to the DC which was used for login. Very handy if trying to change passwords are you can update the DC so there is no waiting for replications.

FSEXTEND.EXE (Diskpart)

After performing the “diskpart extend” command to merge two partitions the new partition will display in disk management however will not show the full capacity. This is a known problem if the command was run without sufficient system resources.
The partition size is extended, but the file system remains the original size when you extend an NTFS volume” – Unfortunately Microsoft have pulled the original “KB832316” (As of 2021) so there is limited information available. There are some references for diskpart here: KB325590

The following method of fixing this with the diskpart tool may work for some (but not others)

diskpart
list volume
select volume X
extend filesystem

If like me you received the following error “Diskpart failed to extend the volume. Please make sure the volume is valid for extending” then there is a 99% this method will not work, in this case you can use the FSEXTEND.EXE tool, after burning around the net and looking at the following EE article it seems that getting hold of the tool is another problem. I resolved this by 45minutes of talking to Microsoft and getting a case open… but to avoid this I’ve uploaded the tool…

Trying to get FSEXTEND.EXE ?

How to Use:

The FSExtend tool really is a “one trick pony” if you try to get the switches required by the program it will simply return with “usage: fsextend.exe driveLetter” so you just need to perform the following:

DISKPART> select volume 1
DISKPART> extend filesystem
DiskPart successfully extended the file system on the volume.
DISKPART> exit
Leaving DiskPart...

Outlook 2007 File Locations

To access the folder holding the toolbar, VBA, send & receive settings, and nickname files, copy and paste:

  • Vista/W7: %USERPROFILE%\AppData\Roaming\Microsoft\Outlook
  • XP: %USERPROFILE%\Application Data\Microsoft\Outlook

To see the message store files, copy and paste:

  • Vista/W7: %USERPROFILE%\AppData\Local\Microsoft\Outlook
  • XP: %USERPROFILE%\Local Settings\Application Data\Microsoft\Outlook

BCDEdit – VHD into boot.ini

bcdedit /copy {current} /d “XPP32-VHD”
bcdedit /set {ef3e950f-0d1f-11df-81c3-0009dd502a5a} device vhd=3D[J:]\Virtual_PC\Microsoft-VPC\Windows-XPP32\Windows-XPP_HDD_10gb_Office2003_DYN.vhd
bcdedit /set {ef3e950f-0d1f-11df-81c3-0009dd502a5a} osdevice vhd=3D[J:]\Virtual_PC\Microsoft-VPC\Windows-XPP32\Windows-XPP_HDD_10gb_Office2003_DYN.vhd
bcdedit /set {ef3e950f-0d1f-11df-81c3-0009dd502a5a} detecthal on
bcdedit /delete {6a8b1f82-071e-11df-8287-c6f21c814b9c} /cleanup
bcdedit /delete {ef3e950e-0d1f-11df-81c3-0009dd502a5a} /cleanup

Ref: Windows 7 to VHD
 

Windows XP Activation Verification

Many computers come with Original Equipment Manufacturer (OEM) versions of XP where the manufacturer has altered or totally removed options from the original menus. This brings up the activation screen to change the product key in XP.

Run -> “oobe/msoobe /a”

TS Web Access not working – ActiveX not installed or enabled

Microsoft RDP ActiveX Control is disabled when you install Windows XP Service Pack 3 or Windows Small Business Server 2003 SP1.

Use the Manage Add-ons dialog in Internet Explorer to enable the Terminal Services ActiveX Control, if the ActiveX control is not listed in Manage Add-ons dialog deleting the following registry keys:

Option1:

HKCU\Software\Microsoft\Windows\CurrentVersion\Ext\Settings\{7390f3d8-0439-4c05-91e3-cf5cb290c3d0}
HKCU\Software\Microsoft\Windows\CurrentVersion\Ext\Settings\{4eb89ff4-7f78-4a0f-8b8d-2bf02e94e4b2}

Option2:

run -> cmd.exe /C “cscript %systemroot%\Installer\TSClientMsiTrans\tscuinst.vbs”

Once you delete these keys, the activeX control should be enabled.

List all AD users & email addresses

Simply put this into the Start -> Run bar and hit enter! to get a print out of users & email addresses within the domain.

  • cmd /c dsquery.exe * -limit 0 -filter “(&(objectCategory=person)(objectClass=user)(mail=*))” -attr name mail >”c:\PrimaryEmailAddresses.txt”
  • cmd /c csvde.exe -r “(&(objectCategory=person)(objectClass=user)(mail=*))” -l name,mail -f “c:\PrimaryEmailAddresses.csv”