QuickTip: Comparing installed HotFixes on a two node Cluster

Wednesday, January 12, 2011

We had a Risk and Health Assessment Program (RAP) for SQL Server running in our environment in the last few days and one of the issues in the final report was:   My PowerShell "wheels" started to roll and I suggested our team have a script to check for such inconsistences. So, here's how we can perform a quick check against a two node cluster (or any other pair of computers) using PowerShell and find if the installed hotfixes are not identical. First we use the Get-HotFix cmdlet to retrieve the list of...

Quick Tip: Out-File and IOPs – Position matters

Thursday, December 9, 2010

Take a look at the following two examples. Both commands gets a list of log files, selects a subset of each file properties and logs them to a file.   Get-ChildItem -Filter *.log -Recurse | ForEach-Object {     $_ | Select-Object Name,Length,FullName | Out-File -FilePath D:\LogFilesReport.txt -Append } Get-ChildItem -Filter *.log -Recurse | ForEach-Object {     $_ | Select-Object Name,Length,FullName } | Out-File -FilePath D:\LogFilesReport.txt –Append At first glance both commands looks very similar but under the...

QuickTip: How to validate a UNC path

Thursday, May 27, 2010

The System.Uri class provides an object representation of a uniform resource identifier (URI) and easy access to the parts of the URI. One of its properties is IsUnc . IsUnc gets whether the specified Uri is a universal naming convention (UNC) path and returns a Boolean value that is True if the Uri is a UNC path or False otherwise.   #Requires -Version 2.0 function Test-UNC {     param(                         ]$Path     )...

QuickTip: Additional PowerShell Registry drives

Sunday, May 16, 2010

Windows PowerShell provides access to the system registry via two PowerShell drives: HKLM and HKCU, which maps to the HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER registry hives respectively. PS > Get-PSDrive -PSProvider RegistryName Used (GB) Free (GB) Provider Root CurrentLocation---- --------- --------- -------- ---- ---------------HKCU Registry HKEY_CURRENT_USERHKLM ...

QuickTip: How do you check Internet connectivity?

Tuesday, March 9, 2010

With the following PowerShell one-liner you can check if the machine you’re working on has internet connectivity. The result is a Boolean value. If TRUE, the local machine is connected to the internet; if FALSE, it is not. Minimum supported client: Windows Vista ::CreateInstance(::GetTypeFromCLSID('{DCB00C01-570F-4A9B-8D69-199FDBA5723B}')).IsConnectedToInternet