Category Archives: Scripting

Case of the Slow PowerShell Logon Script

A logon script was taking 30-40 seconds to run at logon. $domain = "contoso" $Searcher = New-Object System.DirectoryServices.DirectorySearcher("domain",$domain) $Searcher.Filter = ("(sAMAccountName=$env:username)") $user=$searcher.FindOne() $ugroups=$User.GetDirectoryEntry().memberOf $ugroups -split ‘=,’ | ForEach-Object { $Searcher.Filter = ("(distinguishedName=$_)") $groups=$searcher.FineOne() $nested=$groups.GetDirectoryEntry().memberOf if($nested -like "CN=*") { $ugroups = … Continue reading

Posted in Performance, PowerShell, Scripting | Tagged | Leave a comment

Accessing Windows Security Centre Status from PowerShell

Sometimes you might want to script checking health of anti-virus/firewall/&c. However since Windows Vista the method frequently used in scripts is accessing the wmi namespace root/securitycenter2 which is undocumented from publicly available Microsoft. Although the values of what productState mean … Continue reading

Posted in .NET, PowerShell, Scripting | Tagged | 2 Comments

Windows 7 Can Teach You PowerShell–Inbuilt Wealth of Scripts

This is looking at all scripts included in Windows 7. These contain a lot of useful sample code. The purpose here is to show you PowerShell scripts included in Windows and where I think the script contains useful code examples … Continue reading

Posted in PowerShell, Scripting | Tagged | 2 Comments

Case of the Missing Desktop Shortcut Icons

On Windows 7 a user was reporting their desktop icons kept disappearing, but only specific ones. Each time they got re-created they kept disappearing randomly on Monday mornings. Initial investigation started with the Event Log, and having an approximate time … Continue reading

Posted in PowerShell, ProcMon, Scripting, Troubleshooting, Windows 7 | Tagged | 10 Comments

Using SMB sniffing to determine target’s host name, domain, OS version, system time and time zone

Once again needed an alternative method to “verify” a massive list of computers : 1) The machines existed on the network 2) that DNS was resolving to the actual machine on the list. i.e. when verifying machine name “PC-1234” I … Continue reading

Posted in Batch Files, Network, NMap, Scripting | Tagged | Leave a comment

Creating a Single .EXE when you need a separate .EXE to run on x86 and x64 Platforms

Sometimes you may have separate .EXEs to run whether on x86 (32-bit) or x64 (64-bit) platforms. Reasons for this are often around the need to access the native 64-bit registry location i.e. HKLM\SOFTWARE without getting redirected to HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node…But sometimes having … Continue reading

Posted in 64-bit, AutoIT, Scripting | Tagged | Leave a comment