none
Powershell MDT module's "Get-MDTComputer" -description switch doesn't work and a Fix Proposed RRS feed

  • General discussion

  • I ran into a problem where the “–description” switch was not working with the get-mdtcomputer powershell cmdlet in the MDTDB.psm1 module.

    Get-MDTComputer uses the “ComputerSettings” view in the MDT database.  This view doesn’t have a “description” field, but it is easy to add.  After adding the description field to the ComputerSettings view, the –description switch will function correctly.  Can anyone see a pitfall with this proposed solution?

    Here’s how I fixed the problem. 

    In SQL Management Studio find your MDT Database (mine is called MDT2012)  and open the Views folder.  Find the “dbo.ComputerSettings” view, right click on it and choose “Script VIEW as > Alter To > New Quesry Editor Window.

    Using the text below as a guide, add the “ci.description” field to the VIEW and save it.  It is also worth noting that any time you add additional settings to your MDT database (via the MDT Front End tools perhaps) you have to rebuild this view.  Standard disclaimers…  Works for me, it might not work for you. Test. I’m not responsible for this not working in your environment yadda yadda yadda.    I have also discovered that ComputerSetting will not contain any computers from the MDT database that do not have MDT Settings.  This was a problem for me because I just add a computer to the MDT database and assign a ROLE to the computer – but don’t specify any additional settings.  In this case the get-MDTComputer will not return any computers.  I worked around this by making sure to set at least one setting on each computer – and that fixed the problem with Get-MDTComptuer

    USE [YOUR MDT DATABASE NAME HERE]

    GO

    /****** Object:  View [dbo].[ComputerSettings]    Script Date: 1/21/2015 9:02:24 AM ******/

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    ALTER VIEW [dbo].[ComputerSettings] AS

    SELECT ci.description, ci.AssetTag, ci.UUID, ci.SerialNumber, ci.MacAddress, s.* FROM [dbo].[Settings] s

    JOIN [dbo].[ComputerIdentity] ci

           ON s.[ID] = ci.[ID]

    WHERE [Type] = 'C'

    Wednesday, January 21, 2015 3:13 PM