• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Tachytelic.net

  • Get in Touch
  • About Me

Technical Posts

Files not visible on Windows Share due to Client Side Caching

December 16, 2019 by Paulie 1 Comment

I was working on a machine that was unable to see a number of files within a completely standard Windows Server Share. The machine was running Windows 7 64-Bit. Other clients were able to see the files and the same user logged into a different machine worked fine.

I checked the permissions and a number of other things, but nothing seemed to make the missing files appear.

Eventually I figured out that the problem was caused by SMB client side caching as explained here at Microsoft. Once I disabled SMB Client side caching the missing files appeared.

How to disable SMB2 Client Side Caching

  1. Open registry editor (Windows Key +R, Type in regedit and click OK).
  2. In Registry Editor navigate to and select:
    HKLM\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters
  3. From the Edit menu, click new, thenĀ DWORD (32-bit) Value
  4. Name the new DWORD DirectoryCacheLifetime
  5. Leave the default value of zero unchanged.
  6. Reboot the machine.

If you prefer, simply download this DisableSMB2ClientCache.Reg file and apply it to your machine.

Filed Under: Technical Posts

Reboot loop on Windows 2012 caused by KB4532920

December 12, 2019 by Paulie 13 Comments

There have been a number of reports that KB4532920 is causing endless reboots loops on Windows Server 2012. One of my customers experienced this today. This update was released on December 10th 2019.

This is a servicing stack update which improves the updates process on Windows, ironic that installing it puts the server into an endless reboot loop!

I was able to work around the problem by booting into safe mode with command prompt and then issuing the command:

shutdown /r /t 1

The problem was that I was unable to access safe mode because by default the F8 boot options are disabled on Windows Server 2012.

To access safe mode in Windows Server 2012

  • Boot from the Windows Server ISO.
  • Choose “Repair your computer” from the main installation dialog:
    Image showing Windows Server Setup Repair computer option
  • On the next screen choose “Troubleshoot”.
  • Then choose command prompt.
  • At the command prompt enter these commands:
    • bcdedit /set {bootmgr} displaybootmenu yes
    • bcdedit /set {bootmgr} timeout 10

Now reboot the machine and you should be able to access the boot options. Boot into safe mode and login as normal. At the command prompt you can just reboot the machine again. This particular machine required another reboot before it came up normally. But the update did show as having been installed:

Image showing KB4532920 installed successfully. The update which caused a reboot loop.

These unexpected problems really waste a lot of time, but thankfully it was not too difficult to fix.

Filed Under: Technical Posts Tagged With: Windows Update

Add item to VBScript Array

September 3, 2019 by Paulie 5 Comments

If you are using VBScript for scripting or in a classic ASP page adding items to an array is a difficult and slow process.

The arraylist class from .net is accessible via com and it provides a number of advantages over the native VBScript functionality:

  • It requires less code
  • It is faster
  • It makes it simple to sort arrays
  • Adding and removing item is easy
  • No need to re-dimension arrays

Example Code:

Set players = CreateObject("System.Collections.ArrayList")
players.Add "Novak Djokovic"
players.Add "Rafael Nadal"
players.Add "Roger Federer"
players.Add "Dominic Thiem"
players.Sort
WScript.Echo Replace("There are {0} players in the draw", "{0}", players.Count)

You can easily loop through each items in the array like this:

For Each player In players
	WScript.Echo player
Next 

or like this:

For i = 0 To players.Count - 1
	If i < players.Count - 1 Then
		WScript.Echo players(i)
	Else
		WScript.echo Replace("The last player is {0}", "{0}", players(i))
	End if
Next 

I used this technique on a script I wrote for a customer around 10 years ago. The script still worked fine but it was slow as it was working through a lot of data. By changing the script to use the Arraylist class I was able to reduce the amount of code and increased the performance by around 50%.

It’s also easy to remove items from a VBScript array created this way:

players.Remove "Dominic Thiem"

You can also use the arraylist class to store objects instead of simple values. So taking the above example slightly further you could do something like this:

Class TennisPlayer
	Public Rank
	Public Name
	Public Points
End Class

Set players = CreateObject("System.Collections.ArrayList")

Set player = New TennisPlayer
player.Rank = "1"
player.Name = "Novak Djokovic"
player.Points = "11685"
players.Add player

Set player = New TennisPlayer
player.Rank = "2"
player.Name = "Rafael Nadal"
player.Points = "7945"
players.Add player

Set player = New TennisPlayer
player.Rank = "3"
player.Name = "Roger Federer"
player.Points = "6950"
players.Add player

WScript.Echo Replace("There are {0} players in the draw", "{0}", players.Count)

For Each P in players
	WScript.Echo StrFormat("Player {0}, is ranked {1}, and has {2} ATP points", Array(p.Name, p.Rank, p.Points))
Next 

Function StrFormat(FS, Args())
    Dim i
    StrFormat=FS
    For i = 0 To UBound(Args)
        StrFormat = Replace(StrFormat, "{" & i & "}", args(i))
    Next
End Function

Which produces the following output:

Image showing output of a VBScript script which has used the .net arraylist class to store objects

If you are wondering about the StrFormat function, it is just something I use to make formatting strings easier and you can read about that function here.

I have also written up this same information and method to add items to an array in PowerShell.

Filed Under: Technical Posts Tagged With: VBScript

Add items to a Powershell Array

August 22, 2019 by Paulie 1 Comment

By default, PowerShell arrays are fixed size, which makes adding items more difficult than you would expect. Take the following code as an example:

$names = "Paul","John","Peter"
$names.Add("Simon")         

This generates an error:

Image showing error when trying to add an element to a fixed sized Powershell Array.
Exception calling “Add” with “1” argument(s): “Collection was of a fixed size.”

This happens because arrays in PowerShell are fixed size. As a work around the above code can be modified:

$names = "Paul","John","Peter"
$names += "Simon"              

Using this method, the original array is replaced by entirely new array with the existing contents copied into it and the new element added. If your array has many items this will impact performance.

Use an ArrayList instead of a Standard Array

Using an ArrayList is an easier and faster than a standard PowerShell array. Here is an example:

$names = New-Object System.Collections.ArrayList
$names.Add("Paul")
$names.Add("John")
$names.Add("Simon")
$names.Remove("Paul")

This method makes it much easier to work with dynamically sized arrays. If you still require a standard PowerShell array you can do:

$PowerShellArray = $names.ToArray()

Hope this helps.

Filed Under: Technical Posts Tagged With: Powershell

Detect a rogue DHCP Server with Microsoft Rogue Check Tool

May 23, 2019 by Paulie

If a rogue DHCP server crops up on your network it can cause all sorts of problems. Many different kind of devices include a DHCP Server so this can happen by mistake very easily.

Microsoft created a tool called Rogue Checker which can make finding the unwanted DHCP server much easier. You can no longer download it from them, so I am making it available here:

Download Microsoft Rogue DHCP Server Detection Tool

The tool is very easy to use, simply run it and click on “Detect Rogue Servers” and it send out a DHCP request and show you the responses:

Microsoft Rogue DHCP Server Detection showing a Rogue Server

Find the hardware address of the unauthorised DHCP server

Knowing the IP address of the offending server is a useful start. By finding the the MAC Address you can also determine the manufacturer of the device. After you have run the detection tool your machine will have stored the hardware addrress of the DHCP server in it’s ARP cache. You can find the hardware address by running “arp -a” from a command line:

Image showing how to use the ARP command to get the mac address of a rogue DHCP server

Now use a mac vendor lookup tool to figure out who the device is made by and that will give you another clue where to look.

Filed Under: Technical Posts

  • Go to page 1
  • Go to page 2
  • Go to page 3
  • Interim pages omitted …
  • Go to page 8
  • Go to Next Page »

Primary Sidebar

Link to my LinkedIn Profile
Buy me a coffee

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 245 other subscribers.

Go to mobile version