Add Powershell Support to WinPE x86 & x64 in MDT

There are times when you would want to use Powershell or run a Powershell Script in MDT WinPE. Powershell support is available but is not enabled by default. This is how you enable it.
Launch Deployment Workbench, Open Properties of your Deployment Share and Click on Windows PE tab. Choose Platform x86 from the drop down. Select Features tab.
Enable .NET Framework and Windows Powershell

Powershell_x86

Choose Platform x64 from the drop down. Select Features tab and Enable .NET Framework and Windows Powershell. Click Apply.

Powershell_x64

Switch to the General tab and Ensure that you Enable the check box for both x86 and x64 in the Platform Supported Section and then click OK.

WinPEPlatform

Next right click on your deployment share and click on update deployment share and completely regenerate the Boot Images and click Finish when done.
Boot off the new WinPE ISO, Press F8 to launch command prompt. Run powershell.exe to launch powershell prompt.

Powershell_WinPEx64 Powershell_WinPEx86

!! Preenesh

 

Advertisements
Posted in MDT | Tagged , , | Leave a comment

Getting minimum Hardware info from HP iLO (No need for credentials)

Thanks to Mikael Nystrom from DeploymentBunny.com cause have added a few addition to his idea and script to work as per my requirement
In HP Servers there is something called iLO, what many people do not know is that you can reach basic information using a normal web browser with out providing credentials, like this:
Just browse to http://IPaddress/xmldata?item=All and you will see this

HP_iLO

The below script reads each and every IP from the input file “Serverlist.txt” (Create a Text File “Serverlist.txt” in the same path you save this script) , the first thing is to try to get the name from DNS, then confirms the connectivity with the ilo, then we load the XML data, we then convert, modify, bend and twist so it looks the way I need it and last we dump it in a CSV file.
<# 
Author : Preenesh Nayanasudhan 
Script : Ping Multiple servers iLO IP provided in Text file Serverlist.txt 
Purpose : iLO Test Experiment - Ping Multiple Servers iLO and publish the result in CSV 
Pre-requisite : Create a Text File Serverlist.txt in the same path you save this script 
#> 
 
# Input file 
$Servers = Get-Content "ServerList.txt" 
$report = @() 
 
ForEach ($server in $Servers) 
{ 
    $HostName = [System.Net.Dns]::GetHostEntry($server).hostname 
    if (test-Connection -ComputerName $server -Count 3 -Quiet ) 
    { 
        $iLOIP = $($server); 
        $PingResult = 'ILO is Alive and Pinging' 
        $XML = New-Object XML  
        $XML.Load("http://$server/xmldata?item=All") 
        $iLOSN = $($XML.RIMP.HSI.SBSN);
        $ServerType = $($XML.RIMP.HSI.SPN); 
        $ProductID = $($XML.RIMP.HSI.PRODUCTID); 
        $ILOType = $($XML.RIMP.MP.PN);  
        $iLOFirmware = $($XML.RIMP.MP.FWRI) 
        $tempreport = New-Object PSObject 
        $tempreport | Add-Member NoteProperty 'ILO IP' $server 
        $tempreport | Add-Member NoteProperty 'Ping Result' $PingResult 
        $tempreport | Add-Member NoteProperty 'ILO HostName' $HostName 
        $tempreport | Add-Member NoteProperty 'ILO Serial NUmber' $iLOSN  
        $tempreport | Add-Member NoteProperty 'Server Type' $ServerType 
        $tempreport | Add-Member NoteProperty 'Product ID' $ProductID 
        $tempreport | Add-Member NoteProperty 'ILO Type' $ILOType 
        $tempreport | Add-Member NoteProperty 'ILO Firmware' $iLOFirmware  
        $report += $tempreport 
    }  
    else  
        {  
        $iLOIP = $($server); 
        $PingResult = 'ILO Seems dead NOT Pinging' 
        $tempreport = New-Object PSObject 
        $tempreport | Add-Member NoteProperty 'ILO IP' $server 
        $tempreport | Add-Member NoteProperty 'Ping Result' $PingResult 
        $tempreport | Add-Member NoteProperty 'ILO HostName' $HostName 
        $report += $tempreport 
    } 
 } 
$report | Export-Csv -NoTypeInformation ('iLO_Timeout_Test.csv')

!! Preenesh

Posted in Powershell | Tagged | 3 Comments

Get Install Date & OS Version for a list of Servers provided in a text file

Get Install Date and OS Version for a list of Servers provided in a Text file and publish the result in CSV.
Script reads each and every IP/hostname from the inputfile “Serverlist.txt” (Create a Text File “Serverlist.txt” in the same path you save this script), checks if the IP/hostname can be reached. if it can be reached connects to WMI and collects the Install Date and OS Version (Caption) and we dump it in a CSV file in the same path where you have this script.
<# 
Author : Preenesh Nayanasudhan 
Script : Get Install Date and OS Version for list of Servers provided in Text file Serverlist.txt
Purpose : Get Install Date and OS Version for list of Servers provided in Text file and publish the result in CSV 
Pre-requisite : Create a Text File Serverlist.txt in the same path you save this script 
#>  
  
# Input File 
$Servers = Get-Content "ServerList.txt"  
$report = @() 
 
ForEach ($server in $Servers)  
{  
    #Test if computer is online      
    if (test-Connection -ComputerName $server -Count 3 -Quiet )  
    {  
        $PingResult = 'Server IS Pinging'         
        # Connect to WMI on remote machine to get the required information 
        $gwmios = Get-WmiObject -Class Win32_OperatingSystem -ComputerName $server  
        # Get the Install Date and Convert readable date & time format  
        $osidate = $gwmios.ConvertToDateTime($gwmios.InstallDate) 
        $osname = $gwmios.Caption 
        $tempreport = New-Object PSObject  
        $tempreport | Add-Member NoteProperty 'Server Name' $server 
        $tempreport | Add-Member NoteProperty 'Ping Result' $PingResult 
        $tempreport | Add-Member NoteProperty 'OS Version' $osname  
        $tempreport | Add-Member NoteProperty 'OS Install Date' $osidate 
        $report += $tempreport  
    }   
    else   
        {   
        $PingResult = 'Server NOT Pinging'  
        $tempreport = New-Object PSObject  
        $tempreport | Add-Member NoteProperty 'Server Name' $server 
        $tempreport | Add-Member NoteProperty 'Ping Result' $PingResult 
        $report += $tempreport  
    }    
}  
$report | Export-Csv -NoTypeInformation ('OSInstallDate.csv')

!! Preenesh

Posted in Powershell | Tagged | Leave a comment

Provide option to select Deployment Share during MDT Deployment

There are times when you would want to provide an option or prompt the user to select a Deployment Share during  an MDT Deployment, it quite simple to get it working with the help of Extra Directory.
See https://deploymentmechanic.wordpress.com/2015/10/31/add-extra-directory-to-winpe-x86-x64-in-mdt/ for more information about how to add Extra Directory. You would need to perform the following steps on any one of your deployment share and ensure that you generate WinPE ISO from the same deployment share.
Create an XML file and specify the various deployment servers/shares.  You could copy the below sample content into Notepad and save it as LocationServer.xml. You would need to update friendlyname and UNCPath as per your infrastructure/deployment share.
<?xml version=”1.0″ encoding=”utf-8″ ?>
<servers>
    <QueryDefault></QueryDefault>
    <server>
        <serverid>1</serverid>
        <friendlyname>Deployment LAB Share</friendlyname>
        <UNCPath>\\WIN2K8MDT12\DeployLab$</UNCPath>
    </server>
        <server>
        <serverid>2</serverid>
        <friendlyname>Deployment Mechanic Lab Share</friendlyname>
        <UNCPath>\\WIN2K8MDT12\DMLab$</UNCPath>
    </server>
</servers>
Next create a folder called “Deploy” under the root of Extra Directory, in my case under the x86 and x64 folder.
Deploy
Create another folder called “Control” under “Deploy” folder and Copy LocationServer.xml you created into the “Control” folder.

Control

Next Launch Deployment Workbench, Open Properties of your Deployment Share where you have made required configuration to add the Extra Directory and Click on Rules Tab and Click on the Edit Bootstrap.ini button at the bottom.
Modify the Bootstrap.ini file to NOT include any DeployRoot value, you could either delete the line or comment the line by putting a semi-colon in front of the specific value in this case DeployRoot. We would need to do this cause the LocationServer.xml feature dynamically sets the value. Save and close Bootstrap.ini. Click OK on the Properties Windows.

Bootstrap

Note : When you use the LocationServer.xml feature, By default the logic in this feature discards any credentials provided in bootstrap.ini
Next right click on the deployment share and click on update deployment share and completely regenerate the Boot Images and click Finish when done.
Boot off the new WinPE and you should see the LocationServer.xml feature in action.

select_share

!! Preenesh

Posted in MDT | Tagged , | Leave a comment

Add Extra Directory to WinPE x86 & x64 in MDT

So, This blog post is a foundation for few of my future blog post.
Create a folder in your deployment share; I have created “DMExtraFiles”. In the folder you just created, “DMExtraFiles” in my case. Create 2 more folders “x86” and “x64” these folders can be used to organize and store folders, files, scripts etc that would be injected into respective versions of WinPE. You would get a better understanding as we move along..
MDTExtraFiles
Launch Deployment Workbench, Open Properties of your Deployment Share and Click on Windows PE tab. Choose Platform x86 from the drop down, In the Lite Touch Boot Image Setting  section give an Image Description and ISO Filename of your choice. In the Windows PE Customization’s section in Extra directory to add browse to the x86 folder we created.
MDT_WPEExtFld_x86Choose Platform x64 from the drop down, In the Lite Touch Boot Image Setting  section give an Image Description and ISO Filename of your choice (Ensure that it is unique). In the Windows PE Customization’s section in Extra directory to add browse to the x64 folder we created and click Apply
MDT_WPEExtFld_x64Switch to the General tab and Ensure that you Enable the check box for both x86 and x64 in the Platform Supported Section and then click OK.
WinPEPlatformNext right click on your deployment share and click on update deployment share and completely regenerate the Boot Images and click Finish when done.
Now lets boot using the WinPE ISO that was just generated, you can find these in  <your deployment share>\Boot folder. Once you have a machine booted off the WinPE (I have booted of the x86 WinPE), Press F8 to launch command prompt and go to the root of the drive and list all files and  folder. But where is the x86 Folder ?
MDT_WPEExtFld1You will not find it cause <your deployment share>\DMExtraFiles\x86 folder is Empty. OK, let me prove that to you.
Create a folder Tools_x86 under <your deployment share>\Tools\x86 and create a text file called “Inside_SubFolder_In_ExtraFolder.txt”
WinPESubFolderx86Next right click on your deployment share and click on update deployment share and completely regenerate the Boot Images and click Finish when done.
Once again boot off the new WinPE (I have booted of the x86 WinPE), Press F8 to launch command prompt and go to the root of the drive and list all files and folders. You can see Tools_x86 folder has appeared like magic, go into the folder and you can also see the text file “Inside_SubFolder_In_ExtraFolder.txt”
MDT_WPEExtFld2
OK go back to <your deployment share>\DMExtraFiles\x86 and create a text file “Root_of_ExtraFolder.txt”
MDTExtraFiles1
Next right click on your deployment share and click on update deployment share and completely regenerate the Boot Images and click Finish when done.
Once again boot off the new WinPE (I have booted of the x86 WinPE), Press F8 to launch command prompt and go to the root of the drive and list all the files and folder. You can see the text file “Root_of_ExtraFolder.txt” in the root of X drive.

MDT_WPEExtFld3

So this should give you a fair idea of how Extra Directory/Folder Works. Go ahead and try adding a few files into WinPE X64 Boot Image.

!! Preenesh

Posted in MDT | Tagged , | 2 Comments

Add Custom Background and BGInfo to MDT WinPE x86 & x64

Create a folder in your deployment share; I have created “DMExtraFiles”.
In the folder you just created, “DMExtraFiles” in my case. Create 2 more folders “x86” and “x64”.
MDTExtraFiles
First let’s get Custom Background and BGInfo in place for both  x86 & x64 Platform of WinPE.
Create a folder in your deployment share to hold your Custom Background’s “DMBackground” (It is not a requirement). I have 2 Custom Background one that I will use for x86 and one for x64 (Just showing off my MS Paint Skills) that I will place in the folder “DMBackground”

WinPEBGx86 WinPEBGx64

In case you are wondering where did I get the background image from its in “<Install Drive>\Program Files\Microsoft Deployment Toolkit\Samples\Background.bmp” and Use your MS Paint Skills, Also let me tell you this everything that you need to follow along to complete this blog post is already available on the server you have MDT Installed on.
Now browse to the <your deployment share>\DMExtraFiles\x86 folder and Create a folder Tools_x86
Open <your deployment share>\Tools\x86\Tools folder and Copy BGInfo.exe and STEP_01.BGI to <your deployment share>\DMExtraFiles\x86\Tools_x86 folder and Rename STEP_01.BGI to WinPE_x86.BGI
Now open WinPE_x86.BGI (Accept License Agreement if asked) and click on Background, update path of Wallpaper Bitmap : %systemroot%\System32\winpe.bmp and click OK twice to save the changes.
Create a Windows Command Script BGInfo.cmd with this in it “X:\Tools_x86\BGInfo.exe” “X:\Tools_x86\WINPE_x86.BGI” /silent /timer:0 /NOLICPROMPT
So your Tools_x86 folder should look like this

WinPEToolsx86

Next browse to the <your deployment share>\DMExtraFiles\x64 folder and Create a folder Tools_x64
Open your <your deployment share>\Tools\x64 folder and Copy BGInfo64.exe and STEP_01.BGI to <your deployment share>\DMExtraFiles\x64\Tools_x64 folder and Rename STEP_01.BGI to WinPE_x64.BGI
Now open WinPE_x64.BGI (Accept License Agreement if asked) and click on Background, update path of Wallpaper Bitmap : %systemroot%\System32\winpe.bmp and click OK twice to save the changes.
Create a Windows Command Script BGInfo.cmd with this in it “X:\Tools_x64\BGInfo64.exe” “X:\Tools_x64\WINPE_x64.BGI” /silent /timer:0 /NOLICPROMPT
So your Tools_x64 folder should look like this

WinPEToolsx64

Next we need to update Unattend.xml to launch BGInfo.cmd, As I said earlier there is already a WinPE Unattend.xml file template for both x86 and x64 available in <Install Drive>\Program Files\Microsoft Deployment Toolkit\Templates.
Copy Unattend_PE_x86.xml to <your deployment share>\DMExtraFiles\x86 folder and Rename it to Unattend.xml and Also copy Unattend_PE_x64.xml to <your deployment share>\DMExtraFiles\x64 folder and Rename it to Unattend.xml
Now open the Unattend.xml in x86 folder in the world best XML Editor.. Notepad and add the below lines in the <RunSynchronous> section
<RunSynchronousCommand wcm:action=”add”>
<Description>Run BGInfo</Description>
<Order>1</Order>
<Path>X:\Tools_x86\BGInfo.cmd</Path>
</RunSynchronousCommand>
Few things you would want to ensure once you add these lines.. Order for Lite Touch PE should be set to 2..
WinPEUnattendx86Now open the Unattend.xml in x64 folder and add the below lines in the <RunSynchronous> section
<RunSynchronousCommand wcm:action=”add”>
<Description>Run BGInfo</Description>
<Order>1</Order>
<Path>X:\Tools_x64\BGInfo.cmd</Path>
</RunSynchronousCommand>
and ensure Order for Lite Touch PE is set to 2
WinPEUnattendx64Launch Deployment Workbench, Open Properties of your Deployment Share and Click on Windows PE tab
Choose Platform x86 from the drop down, configure the following (I have my deployment share on E drive) and click Apply
Image Description: MDT Custom Windows PE (x86)
ISO Filename: MDTCustomPE_x86.iso
Custom background bitmap file: E:\DMLab\DMBackground\DMBackground_WinPEx86.bmp
Extra directory to add: E:\DMLab\DMExtraFiles\x86
MDTWinPEx86Choose Platform x64 from the drop down, configure the following (I have my deployment share on E drive) and click Apply
Image Description: MDT Custom Windows PE (x64)
ISO Filename: MDTCustomPE_x64.iso
Custom background bitmap file: E:\DMLab\DMBackground\DMBackground_WinPEx64.bmp
Extra directory to add: E:\DMLab\DMExtraFiles\x64
MDTWinPEx64Switch to the General tab and Ensure that you Enable the check box for both x86 and x64 in the Platform Supported Section and then click OK.
WinPEPlatformFinally update the deployment share to generate the WinPE Iso and Boot using the New WinPE Iso

MDT_WinPEBG_BGInfox64 MDT_WinPEBG_BGInfox86

!! Preenesh

Posted in MDT | Tagged , , | Leave a comment