The Deployment Bunny

OS Deployment, Virtualization, Microsoft based Infrastructure…

  • Archives

  • Meta

Archive for the ‘SCCM’ Category

Nice to Know – A Geeks Guide for upgrading to ConfigMgr 2012 R2 and MDT 2013

Posted by Mikael Nystrom on June 18, 2014

Upgrading to ConfigMgr 2012 R2 is not a pain, but it could be. You really need to read and understand before you begin your journey.

The basic story is that you do an in-place upgrade and then fix “some” post items.

Just follow this fellow MVP and you should be good

Deployment Research (Johan Arwirdmark) http://www.deploymentresearch.com/Research/tabid/62/EntryId/117/A-Geeks-Guide-for-upgrading-to-ConfigMgr-2012-R2-and-MDT-2013.aspx

/mike

Posted in ConfigMgr, OS Deployment, OSD, SCCM, System Center 2012, System Center Configuration Manager 2012 R2 | Tagged: | Leave a Comment »

OSD–Using ZTISendMail to send email in a LTI/ZTI task sequence

Posted by Mikael Nystrom on June 13, 2014

Long time ago I had a need to send email an email in the end of the task sequence to notify the technician that the OS deployment was done, therefore creating a script which then ended up as a blog post at Deployment Research about two years ago. This week I’m running a Mastering Windows 7 and 8.1 OS Deployment using Lite Touch and Zero Touch in Minnesota and there where some requests on the subject so I decided to create a new version of the script and this time it is a PowerShell script instead. One of the request was to be able to send and email to the administrator that does the deployment (in Lite Touch) using the login name, so that need to to be taken under considerations to.

The script is tested in MDT 2013 but should work perfect in MDT 2012 Update 1 as well and it works when deploying Windows 8 and above.

Lite Touch

First you need to download the script and sample customsettings.ini  from here http://1drv.ms/1kvmobn and store the PowerShell it in the MDT Scripts folder.

Option Number One: Using the UserID directly

Update the CustomSettings like this. (you can copy and paste from the sample customsettings.ini files)

The name used to login to the LTI Wizard is defined as UserID and that is then used as a part of the email address to send it to.

image

Option Number Two: Using the UserID with translation.

In this case we create a section for every user account that should have an email an can logon. As an example, if you login as Administrator (don’t use that account!) an email would be sent to administartor@viamonstra.com, but you can have any other setting for that userID if you liketo.

Update the CustomSettings like this. (you can copy and paste from the sample customsettings.ini files)

image

Add a step in the TaskSequence.

image

Zero Touch

First you need to download the script and sample customsettings.ini  from here http://1drv.ms/1kvmobn and store the PowerShell it in the MDT Package Scripts folder.

In the ZTI we don’t really have a UserID and therefore we just send the email to a predefined email address and cc to an other.

Update the CustomSettings like this. (you can copy and paste from the sample customsettings.ini files)

image

Add a step in the Task Sequence like this.

image

Update the settings package and the MDT Package.

If you need a SMTP server to test against, read this https://deploymentbunny.com/2014/06/12/nice-to-knowa-simple-and-small-smtp-mailserver-fr-devlabtest-smtp4dev/

image

/mike

Posted in ConfigMgr, Deployment, Lite Touch, MDT, OS Deployment, OSD, SCCM, Zero Touch | Tagged: , , , , | 18 Comments »

PowerShell is King – Create a webpage containing LTI/ZTI Deployment issues with information and links to logs

Posted by Mikael Nystrom on December 29, 2013

Knowing is better than guessing, that is an indisputable fact as far as I know and since we try to automate more and more (someone wrote –automating the world, line by line and that is so darn correct) we now need to monitor much more. OS Deployment has been possible to automate for many years, but the level of monitoring to see if everything is working correctly is in place and there are many reasons for that, some solutions just takes forever to deploy and configure and some takes forever to understand how they work.

The Problem:

We need to be able to see if everything works as expect, we all work in the Service Sector, we are suppose to service our organizations and help our users so they can do whatever they are suppose to do (I know, working in IT is not that cool anymore). If you have MDT you could enable the monitoring feature, but it will only tell you ongoing deployments and if they went well or not, you cannot see the issues, only the number of issues. If you have SCCM it is far better, but, better could be better…

The Solution

In MDT there is a monitoring feature and what not so many know about is that it is actually writing to the event log.

$MDTevents = Get-EventLog -LogName Application -Source MDT_Monitor -EntryType Warning,Error
$MDTevents | Select Message

image
Output from running the commands above.

So, if we could create script that dumps that, split the message into 3 objects, machine name, type of error, and message, add the path to the logs for each machine we have a solution, right?

Issue Number one

The event log is fantastic, it has so many parameters to work with, but in this case it does not work, since all data is just a string in the event it self, so we need to extract that and “bend the rules a bit”, this is what we get if we don’t do anything at all

image
As you can see, it is all in the EventData, just as a dumb string.

With this little function we can now dump the data, turn the string into 3 objects, flip them around so that the computer name comes first (like to sort it on computer name), remove junk

image

Issue Number two

Converting to HTML with links to the logs, well that can be done rather easy using this part

image
Here you can see that we dump out the data running the Function Get-MDTIssues with a select statement that on the first position creates a new object called “link” and it will add a href tag on the computer name, so now we have a nice HTML page, well not really. there is another problem

Issue Number three

ConvertTo-HTML does not like HTML, it will of course convert everything to HTML, including HTML and the HTML we had is no HTML anymore…

But, Convertto-html is an object, so we can of course convert that on the fly using –replace and at the same time we can add the computer name correctly to the server we are running this on

image

Issue Number four

Now everything works, Yeah, well no, as soon as you have this “not-so-very-designed-web-page” you will be able to click the links and THAT works, you will end up in the log folders

image

So let us click one of them:

So far so good:

image

But you cannot click any of the links until you add a mime type for .log in IIS

image

Install and Configure

  • Download file from here: http://sdrv.ms/1h4WrD7
  • Store it locally on the MDT server (The server with the Deployment workbench, it is possible to run the script from an other machine, but then you need to modify the script to read the log from another computer)
  • Make sure that MDT Monitoring is enabled

image

  • Make sure that CustomSettings.ini is correctly configured to store the logs and to enable to send monitor data
    • SLShare=\\SRVMGT01\Logs$
    • EventService=http://SRVMGT01:9800
  • Add the IIS Feature
  • Add two Web Applications

image

  • Enable Directory Browsing for Logs and MDT (If you call the file default.htm or similar you don’t need that)
  • Schedule the script to run (You could a be smart, schedule a task based on the MDT_Monitor to run the script for warnings and errors

imageimage

  • Testing could be done in two ways, you could either deploy a machine and hope it fails or you could run this POSH command:

Write-EventLog -LogName Application -Source MDT_Monitor -EntryType Warning -EventId 2000 -Message "Error logged for computer TEST01: Application Install – HP Support Pack returned an unexpected return code: 1"

image

and if everything works correct, well you should be able to see that in the webpage

image

Happy “Warnings, errors and failures”

/mike

Posted in Deployment, MDT, SCCM | Tagged: , , | 13 Comments »

Nice to Know–Getting Make and Model using CMD or PowerShell

Posted by Mikael Nystrom on December 19, 2013

Trust me, this is not a new thing, rather I get the question every time on a session (before or after) or when working on a customer site, how can I extract the Make and Model from the machine? So, as long as people are asking me, I think I should answer, right? :-)

Make and Model is commonly used in deployment solutions to figure out what drivers that needs to download to each machine during install. It is a part of the SMBBios information and can be accessed using WMI, in WMIC it is called Name and Vendor and in PowerShell it is called Manufacturer and Model. Now, lets take a look.

The Old WMI Method:

Execute wmic csproduct get name,vendor from a CMD prompt.

image

The New POSH Method:

Execute Get-WmiObject Win32_ComputerSystem | Select Model,Manufacturer from a PowerShell prompt.

image

/mike

Posted in Deployment, Drivers, MDT, PowerShell, SCCM, WMI | Tagged: , , , | 4 Comments »

Step-by-Step: Upgrading BIOS during LiteTouch(ZeroTouch) Deployment, for Dell, Hewlett-Packard and Lenovo (v2)

Posted by Mikael Nystrom on December 16, 2013

Long time ago I wrote a post on how to upgrade the BIOS/Firmware during the deployment of a PC in the beginning of a TaskSequence, since then I have been hammered with the question on how to do the same thing but later on, when Windows is running, that has been nagging me, (which obviously paid off for all of you that has been doing that). My friends, here it is, this time in PowerShell, but hey, I don’t do XP anymore.

The basics

The basic Idea is to have a PowerShell script run that will discover what bios version we have and IF we have an update run the update according the that model’s specific way of running a firmware upgrade. It is also possible to just use the PowerShell script as a framework for other similar task of course, or you could use it to kick off something like SSM(HP) to do the job. I did one change, besides using PowerShell and that is to copy down the files to the local drive before running the upgrade, just to be sure that a messy network does not break the upgrade. The script is tested with a couple of HP’s, a Dell and a Lenovo, so there is of course no way I can guarantee it will work with every piece of PC around the globe, but hey, its PowerShell so you can modify it on your own :-). I also created it as an application for MDT LiteTouch, so you need to modify it slightly to run it in SCCM and it also needs the “AliasUserExit.vbs” script since I’m using ModelAlias and MakeAlias. If you don’t like that, just change the lines in he PowerShell code to use Make and Model or anything else that you can read from WMI using PowerShell

The PowerShell script (section One)

This part is just about creating log files, and getting basic data from the TaskSequence/TSEnviroment

image

The PowerShell script (section Two)

Here you can see the function that gets the SMBIOSBIOSVersion, and for all these vendors it is the same, but that could change in the future, so I decided to use the PowerShell Switch to figure out on how to get it. If you look close you can also see that I’m feeding back data to the TSEnviroment, that is not needed for this to work, but hey, you cannot get enough variables to play with, can you :-)

image

The PowerShell script (section three)

Here is when we get serious, you need to add every model that should be upgraded as a Switch Value and then update the $ExpectedBIOSVersion so it match what you should have. Then you need to add the BIOS update files in to the folder structure in the the Application and last you need to create/modify the UpgradeBIOS.cmd for each model so it runs whatever it is suppose to run to make magic happen.

image

The Folder Structure

Here you can see the folder structure, in this case HP Elitebook 8460p also has sub folders, whatever the vendors has a structure I put in the folder and that will then end up on the local drive, where I run the batch file.

image

The Application in MDT

Just a standard “app” in MDT, I don’t use the “Run PowerShell” script since Applications are easier to modify, move, export, import, and play with. But there should no very little work to get it to work as a script instead, basically the only thing you need to to is to store the script in a folder that the TS can reach, all the folder structure and the file copy is based on where the script is located.

image

CustomSettings.ini needs to be updated!

To figure out if a reboot is needed or not I added a reboot step and reads the property RebootNedeed, so you need to add that to customsettings.ini

image

The TaskSequence

As you can see, I did create a folder for this, easy to copy, easy to move, easy to enable/disable. The restart computer step does have a condition, it only executes if RebootNeeded is set to YES, which is set IF you run the BiosUpgrade.CMD batch file, in the PowerShell script I do return 3010 and I also set the RebootNeeded to YES.

image

The Restart computer Condition

image

 

How to?

  • Download the script
  • Unpack
  • Create a new Application in MDT (If you use SCCM or don’t like Apps, modify the script inside the folder first and add it as a script in the TS)
    • CommandLine: powershell.exe -ExecutionPolicy Unrestricted -File ViaMonstraUpgradeBios.ps1
  • Modify the script to fit your computers, versions and download each upgrade into each folder in the folder structure
  • Add it as an application
  • Enjoy

The Download

http://sdrv.ms/1ffLbji

/mike

The “old” Post: https://deploymentbunny.com/2011/05/20/step-by-step-upgrading-bios-during-litetouch-deployment-for-dell-hewlett-packard-and-lenovo/

The link to the AliasUserExit Script: https://deploymentbunny.com/2013/03/06/back-to-basiccustomsettings-inisample-2/

Posted in BIOS, Deployment, Firmware, MDT, SCCM | Tagged: | 3 Comments »

Nice to Know – Dumping MDT Monitor data to a Webpage (using PowerShell) – Update

Posted by Mikael Nystrom on December 13, 2013

A couple of days ago I published a simple PowerShell script that dumps the MDT monitoring data and convert it into a web page, the interest for that has been huge. The customer came back to me with one of those –Is it possible to…

They wanted to have the role that is assigned to the computer and that information is not in the MDT monitoring data output, but it is in the MDT database, so if I could read that using PowerShell and use the name from the MDT Monitoring as input, that should be doable. So I “sacrificed” the evening and now it is working, email the customer and the response was “Thank you!!”, so I thought maybe you would like to get the update to.

The new look! (including the Role information from the MDT database)

image

The new Script

image

The difference is:

Line 2 and 3:
  • I added the logic to connect to the DB
Line 11 – 15
  • I added logic to get the role from the DB
Line 42
  • I added Role in the select state
Line 49
  • I added Role in the select state

That’s all

/mike

Download the script: http://sdrv.ms/1hRSMZv

Read about the original post here: https://deploymentbunny.com/2013/12/09/nice-to-know-dumping-mdt-monitor-data-to-a-webpage-using-powershell/

Read about Sean O’Mahony’s ”branding/styling” here : http://mentalseepage.wordpress.com/2013/12/12/output-mdt-monitor-tab-to-webpage/

Read about getting the MDT Monitor to work in SCCM here: http://www.deploymentresearch.com/Research/tabid/62/EntryId/131/Adding-DaRT-8-1-from-MDOP-2013-R2-to-ConfigMgr-2012-R2.aspx

Read about the PowerShell module for MDT here: http://blogs.technet.com/b/mniehaus/archive/2009/07/09/3241504.aspx

Posted in Deployment, MDT, PowerShell, SCCM | Tagged: , , | 25 Comments »

Nice to Know – Dumping MDT Monitor data to a Webpage (using PowerShell)

Posted by Mikael Nystrom on December 9, 2013

(update – https://deploymentbunny.com/2013/12/13/nice-to-know-dumping-mdt-monitor-data-to-a-webpage-using-powershell-update/)

A customer asked me –Could you create like a web page that shows the same info as the MDT monitoring tab, so can see all the deployment all the time?, the answer is of course –Yes, of course you can!

Now, before you start barking at me and say “That could be done much easier using C#, Lisp, VB.Net” or something, this was the “My-flight-leaves-very-soon” kind of coding, so it jus a very simple PowerShell snip that runs on a 5 min schedule and create a new page and the result looks like this:

image

The script will read the data from the MDT monitoring feed, so the web server does not need to be on the server it self, it does not require anything at all, the script generates a HTML page and the we “modify” it on the fly and the save it in the inetpub folder, and here is the code:

image

And in text form:

$URL = "http://EDUDEPLOY09:9801/MDTMonitorData/Computers"

function GetMDTData { 
  $Data = Invoke-RestMethod $URL

  foreach($property in ($Data.content.properties) ) { 
    New-Object PSObject -Property @{ 
      Name = $($property.Name); 
      PercentComplete = $($property.PercentComplete.’#text’); 
      Warnings = $($property.Warnings.’#text’); 
      Errors = $($property.Errors.’#text’); 
      DeploymentStatus = $( 
        Switch ($property.DeploymentStatus.’#text’) { 
        1 { "Active/Running" } 
        2 { "Failed" } 
        3 { "Successfully completed" } 
        Default { "Unknown" } 
        } 
      ); 
      StartTime = $($property.StartTime.’#text’) -replace "T"," "; 
      EndTime = $($property.EndTime.’#text’) -replace "T"," "; 
    } 
  } 
} 

$Head = "<style>"
$Head = $Head + "BODY{background-color:peachpuff;}"
$Head = $Head + "TABLE{border-width: 2px;border-style: solid;border-color: black;border-collapse: collapse;}"
$Head = $Head + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:thistle}"
$Head = $Head + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black}"
$Head = $Head + "</style>"

$Title = "LabCenter Deployment Status"

GetMDTData | Select Name, DeploymentStatus, PercentComplete, Warnings, Errors, StartTime, EndTime | Sort -Property Name |
ConvertTo-Html  `
-Title $Title  `
-Head $Head  `
-Body (Get-Date -UFormat "%Y-%m-%d - %T ")  `
-PreContent "<H2>LabCenter Deployment Status for: $ENV:COMPUTERNAME </H2><P>Generated by Power of the Force</P>"  `
-PostContent "<P>For details, contact support@truesec.se.</P>"  `
-Property Name,DeploymentStatus,PercentComplete,Warnings,Errors,StartTime |
ForEach {
if($_ -like "*<td>Successfully completed</td>*"){$_ -replace "<tr>", "<tr bgcolor=green>"}
elseif($_ -like "*<td>Failed</td>*"){$_ -replace "<tr>", "<tr bgcolor=red>"}
else{$_}
} > C:\inetpub\wwwroot\default.htm 
#Invoke-Item $ENV:TEMP\Default.htm

And as a download of course http://sdrv.ms/J4ttVC

/mike

Posted in Deployment, MDT, PowerShell, SCCM | Tagged: , , | 28 Comments »

PowerShell is King – Using PowerShell in a Task Sequence – Part 1

Posted by Mikael Nystrom on April 24, 2013

Traditionally VBscript has been “the” script type to use in OS Deployment scenarios, but with WinPE 4.0 in the ADK and MDT 2012 (u1) it is now an option in some scenarios.

Scenario:

You would like to use a PowerShell script that uses properties from the ZTIGather process

Solution:

Create the script and save it in the scripts folder in the deployment share (LTI) or in the MDT packages folder (ZTI) and then add it to the Task Sequence and if needed add any parameters you need to pass to the script. You don’t need to add any parameters from the LTI/ZTI environment, since they will be available within $TSenv:

image

The script:

Here is just a demo script that does not do anything at all, but it should give you an idea of how to create those scripts.


#Demo.ps1

#Setting
$ScriptFile = $MyInvocation.MyCommand.Name
$ScriptLocation  = Split-Path $MyInvocation.MyCommand.Path -Parent

#Setting Vars
$OSDComputername = $TSEnv:OSDCOMPUTERNAME
$Make = $TSEnv:Make
$Model = $TSEnv:Model

#Performing Action
Write-Progress -Activity "Checking Hardware…" -Status "Running Inventory" -PercentComplete 12 -Id 1
Start-Sleep -Seconds 3

Write-Progress -Activity "Checking Hardware…" -Status "Running $ScriptFile" -PercentComplete 12 -Id 1
Start-Sleep -Seconds 3

Write-Progress -Activity "Checking Hardware…" -Status "Running $ScriptLocation" -PercentComplete 12 -Id 1
Start-Sleep -Seconds 3

Write-Progress -Activity "Checking Hardware…" -Status "Make is now $Make" -PercentComplete 32 -Id 1
Start-Sleep -Seconds 3

Write-Progress -Activity "Checking Hardware…" -Status "Model is now $MODEL" -PercentComplete 85 -Id 1
Start-Sleep -Seconds 3

Write-Progress -Activity "Checking Hardware…" -Status "Waiting when we are at 99% just because we can…" -PercentComplete 99 -Id 1
Start-Sleep -Seconds 3

Write-Progress -Activity "Checking Hardware…" -Status "Done" -PercentComplete 100 -Id 1
Start-Sleep -Seconds 3


 

Explaining the script:

The first block is just to set variables for the script it self, it s possible to use other methods, but I prefer to use the built-in method in PowerShell to find out where I am instead of using the translated way in LTI/ZTI

The next block is to show you how to convert a variable from the Task Sequence using the $TSEnv: drive. You don’t need to do this, it is possible to use $TSEnv:OSDComputername directly, but I think this is a bit easier.

Remaining blocks will display the information on the screen while running.

Download Script

/mike

Posted in Deployment, MDT, PowerShell, SCCM | Tagged: | 4 Comments »

Deployment Roadshow 2013 in Sweden!

Posted by Mikael Nystrom on March 29, 2013

Inte första gången

och inte heller sista gången som vi gör detta, det är nämligen en av de få sakerna vi gör bara för att det är så grymt kul. Vi kommer att visa massor med olika saker kring OS Deployment och management. Du kan ta med dej kunskaperna hem och I praktiken använde det du har lärt dej direkt!. Mitt förslag är att du snabbt som attan anmäler dig här innan det är fullt. För du vill väl inte missa tillfället att ställa frågor och få svar, eller se praktiska runbooks, VDI demos, ConfigMgr 2012 SP1 prylar, nya snygga saker I AD:t, en portion PowerShell och annat smått och gott!

http://www.deploymentevents.se/

Var? När?
Göteborg 2013-04-22
Malmö 2013-04-23
Stockholm 2013-04-24
Umeå 2013-04-25

 

/mike

Posted in Deployment, Lite Touch, MDT, RoadShow, SCCM, System Center 2012, Windows 7, Windows 8, Windows Server 2012 | Tagged: , , , , , | Leave a Comment »

PowerShell is King – I need to monitor OS Deployment in MDT 2012 not using Deployment Workbench

Posted by Mikael Nystrom on March 6, 2013

Scenario:

You are using MDT 2012 Update 1 (Lite Touch or Zero Touch), you have enabled MDT monitoring and you would like to know the current status of the OSD deployment, but you would like to read directly from the OData feed using PowerShell and maybe get a nice grid-view. Now, you might wonder why and that is easy, basically every blog post I have seen on this topic assumes you are logged on to the server where the MDT Workbench exists, but that is not always the case.

Solution:

Use PowerShell to get the data using the Invoke-RESTMethod, convert and read it as a Grid view

Display on screen in text

image

Display using grid view:

image

PowerShell command to execute:

You need to change MDT01 to the name of your deployment server for this to work.


$URL = "http://MDT01:9801/MDTMonitorData/Computers"

function GetMDTData {
  $Data = Invoke-RestMethod $URL

  foreach($property in ($Data.content.properties) ) {
    New-Object PSObject -Property @{
      Name = $($property.Name);
      PercentComplete = $($property.PercentComplete.’#text’);
      Warnings = $($property.Warnings.’#text’);
      Errors = $($property.Errors.’#text’);
      DeploymentStatus = $(
        Switch ($property.DeploymentStatus.’#text’) {
        1 { "Active/Running" }
        2 { "Failed" }
        3 { "Successfully completed" }
        Default { "Unknown" }
        }
      );
      StartTime = $($property.StartTime.’#text’) -replace "T"," ";
      EndTime = $($property.EndTime.’#text’) -replace "T"," ";
    }
  }
}

GetMDTData | Select Name, DeploymentStatus, PercentComplete, Warnings, Errors, StartTime, EndTime | Out-GridView


Download script here:  http://sdrv.ms/WtxtnU

/mike

Posted in Deployment, MAP, PowerShell, SCCM | 7 Comments »