Cake Build Script - Node, Gulp, .NET Core MSBuild

The following is a basic guide for setting up a Cake build script to work with a project that utilizes .NET Core, Node.JS, and Gulp. This build script can be used with various continuous integration setups to assist with automated builds and deployments of code. Requirements:.NET Core SDK…

C# and Remote PowerShell - Lookup Smallest Mailbox Database

The following example can be used to return the smallest available mailbox database with a given name pattern. This might be useful if you're running multiple mailbox databases with similar names: Database 1, Database 2, Database 3, etc.. You can pass in a search for "Database*" and it will find…

Using PowerShell to Retrieve DCs within a Specific Domain

The following example will use a remote PowerShell session to query a list of domain controllers under a domain name, and return the first result. Note: This does not verify that the domain controller is online and responding to queries! /// <summary> /// Returns a domain controller from the specified…

AD .NET - User's Can't Change Password Attribute (Get/Set)

The following is an example on how to read a user's Can't Change Password attribute in Active Directory using C#. public bool GetCantChangePassword(string userid) { bool cantChange = false; try { DirectoryEntry entry = new DirectoryEntry(string.Format("LDAP://{0},{1}", "OU=Standard Users,OU=Domain", "DC=domain,DC=org")); entry.AuthenticationType = AuthenticationTypes.…

Exchange 2010 - Enable Mailbox through C# & PowerShell

The following is an example on how to use C# to create exchange mailboxes for Exchange 2010 using remote PowerShell. Imports, not all are used in the example function below: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.DirectoryServices; using System.EnterpriseServices; using System.…