Tahir Hassan's Blog

My Technical Notes

Friday, 6 March 2015

Windows 7 - making networked drives work under administrator account

To the following Registry key:

add a new DWORD entry with the name `EnableLinkedConnections` and value `1`.

Getting all function names in a PowerShell module using C#

The following code gives all the module names within a powershell module. It uses the `System.Management.Automation` DLL found in

Here is the code:

PowerShell: Modules are auto-loaded by default

To stop modules from being auto-loaded by default, we add the following code to our `$profile`:

On another note, if a module contains no `Export-ModuleMember` statements, then all functions defined inside it will be imported.

Wednesday, 4 March 2015

C#: Getting most common integer in a list of integers

Wednesday, 25 February 2015

SQL Server: dropping a Default Constraint

The following script, with two parameters `table` and `column`, will delete the default constraint on that table:

If you would like to specify the constraint name when adding a column, you can do:

Thereafter, deleting the constraint with:

Thursday, 19 February 2015

PowerShell: Instantiating Objects and Finding Constructor Parameters

Instantiating an object has a similar syntax to C#:

However, this is a bit deceptive. Explicitly specifying the parameter names reveals how it works:

The `TypeName` parameter is actually a `string`. However, we still get completion on it, so we don't have to remember all the type names (except the containing namespace). The `ArgumentList` parameter is just an object array (`Object[]`). PowerShell ISE provides no information on the constructor parameters.

As a means of listing the constructor parameters, the PowerShell team have written a function Get-Constructor which lists all of the constructors for a given type:

Monday, 16 February 2015

PowerShell Equivalent of Touch

The `touch` command in Unix, given a file path, will either create a zero-length file if the file does not exist, or it will update the file's timestamp if it does. The following code defines a `Touch` CmdLet: