List of Powershell Articles

A medley of misendeavours involving Windows PowerShell


Using the PowerShell Get-DhcpServ4Lease Cmdlet

2016-01-31T12:00:00Z

During the course of normal day-to-day system administration I found on a number of occasions that I had PTR records that would not resolve. I suspected there was an issue with the configuration of the DHCP Server running on our Microsoft AD Domain. My first step was confirming the problem.…

Windows Deployment Services and the Get-WdsDriverPackage Cmdlet

2016-01-27T19:30:00Z

I made the fatal mistake of importing 133 driver packages into a Windows Server 2012 Instance of Windows Deployment Services without adding them to a driver group. Needless to say, when I imaged a machine using WDS dependent on some of those drivers, they were not automatically installed. I wanted to…

Using PowerShell to List Domain Computers by Uptime

2015-11-18T20:30:00Z

This article introduces a short but powerful PowerShell snippet, the basis of which I find useful for performing a variety of ad-hoc tasks in my day-to-day work as a sysadmin. I had recently applied a change to a series of workstations via Group Policy. It was a slightly tricky software upgrade.…

Invoke-CimMethod : Unable to load PS module for validation - How to Resolve this DSC Problem

2015-11-03T10:30:00Z

After updating one of the DSC modules available on a Desired State Configuration Pull Server I found that, when forcing a DSC client to update it's configuration, I was presented with the error "Invoke-CimMethod : Unable to load PS module C:\Program Files\WindowsPowerShell\Modules\myDSCResources\DscResources\myDSCModule for validation.". PS E:\> Invoke-CimMethod -ComputerName somecomputer -Namespace…

Force a DSC Client to Refresh it's Configuration from the Pull Server

2015-10-13T17:00:00Z

Whilst testing Desired State Configuration settings and scripts, it can be quite useful to force a DSC client note to refresh it's configuration from the pull server. It's worth noting that each client node has a scheduled task called "Consistency". Opening Task Scheduler and manually triggering the scheduled task is…

How do I publish modules from the DSC Pull Server

2015-10-12T20:00:00Z

One of the huge advantages of using a Desired State Configuration Pull Server is the ability to easily distribute resources to subscribed client nodes. For this example, I've installed the xSmbShare module locally. The first step is then creating an archive for our module: PS \> Add-Type -A System.IO.Compression.FileSystem PS \> [IO.Compression.ZipFile]::CreateFromDirectory('C:\Windows\System32\WindowsPowerShell\v1.0\Modules\DSCResources\xSmbShare', "$env:TEMP\xSmbShare_1.0.zip") Move…

How do I query the DSC Compliance Server?

2015-10-12T19:00:00Z

Having previously installed the Windows Desired State Configuration service, configuring both pull and compliance servers, I was left wondering how to query the compliance server. I found that before I could query the the compliance server, I had to tweak a configuration file to allow Windows Authentication. Edit "C:\Windows\System32\inetsrv\config\applicationHost.config" directly,…

Creating a Desired State Configuration Pull Server

2015-10-07T17:30:00Z

Previously I've discussed using DSC in a push configuration where by an administrator applies configuration changes to a node by compiling a DSC script into a MOF (Managed Object File) and running Start-DSCConfiguration against a target node from their workstation. Pushing DSC configuration is hardly zero-touch as it relies on someone…

Migrating a Windows DHCP Server

2015-10-01T19:00:00Z

Today's main task was a Domain Controller migration as part of a continued Windows Server 2012 r2 Upgrade. The most enjoyable part of this task was the shortest - migrating the Windows DHCP Service from the old 2008 r2 Server to it's temporary new home on a virtualised 2012 r2…

Windows Desired State Configuration - A Primer

2015-09-27T17:30:00Z

I've recently completed my first DSC deployment, as part of an upgrade to 12 IIS Servers across two data centres. Whilst I was testing DSC in my lab, I wrote a primer for my colleages. Here is that primer, with some edits. It's a rough guide but it features links…

Stop Visual Studio 2013 from loading a Plug-in with a PowerShell Start-up script

2015-09-21T18:00:00Z

I was recently tasked with preventing Redgate's SQL Complete plug-in from starting with the Visual Studio 2013 IDE. Initially I created a GPO that removed the "C:\Program Files(x86)\Devart\dbForge SQL Complete" registry value from HKLM\Software\Microsoft\VisualStudio\12.0_Config\AutomationOptions\LookinFolders. This solution proved to be inadequate because although it ran when the user logged in, if…

Get Windows Event Log Entries using Powershell

2015-09-19T18:00:00Z

Whilst rolling an upgrade to Microsoft Server 2012 r2 in a VMWare VSphere virtualized cluster, we encountered a problem where-by individual servers would periodically lose network connectivity over one or both of their network adapters. Whilst the actual problem remains under investigation, I felt it might be useful to write…

Deleting a User's Local Profile with PowerShell

2015-09-19T17:00:00Z

In some situations it can be useful to remove a users local profile from a PC, for example, when testing installation of software into the users profile or even when testing the application of a Group Policy. This PowerShell one liner can accomplish just that: (Get-WmiObject -Class win32_userprofile -ComputerName <RemoteComputerName> |…