Showing posts with label Negyuh. Show all posts
Showing posts with label Negyuh. Show all posts

Saturday, August 24, 2013

MDX technical design

Hi folks, as promised i present the next part of my MDX posts. This time i will elaborate on the technical part of MDX as well as give you, the reader, a view of how  OS deployments are done; the MDX way.

MDX design; technical facts

MDX is build in PowerShell, the GUI is designed in SAPIEN’s Primal Forms Community Edition and the application is programmed in Microsoft’s own PowerShell ISA. the script counts around 3000 lines of code of which roughly 2000 lines are accounted for by the GUI. the script is divided in 15 Functions and 6 sections.

The general idea of the applications is: unification and simplification of MDT and accompanying tools to an end-to-end deployment solution.

mdx opbouw

Architecture

MDX is designed around the functionality of a few components:

Here is the graphical representation of the design

Architecture MDX

MDX has a few sections that do the work. each section does a part of the total solution; for example there is a section in MDX that accepts input from the GUI checks its validity and, if verified, adds or modifies a corresponding computer item in MDT- in its database. another section does communicate with PzExec.exe and adds the needed variables to the tools to get a deployment started.

How does MDT accomplish end-to-end automated deployment?

The ‘secret’ of MDX is the way all under laying components are ‘orchestrated’ to make a ‘deployment symphony’ …. the way MDX does this is as follows:

  • MDX controls the MDT database (which is crucial for end-to-end automated deployments) via PowerShell
  • MDX takes variables from the UI and combines it with preconfigured components in MDT and other used tools
  • MDX manipulates a computer object from the MDT database in such a way that it is deployment ready
  • MDX adds ‘non standard’ items or features to the preconfigured building blocks like: for example: add a few applications to the deployment of a certain computer and adds a user account as local administrator to the same deployment as well
  • MDX controls the WDS PXE server and thus controls who may- and may not boot to PXE and do a deployment via the network
  • MDX can directly fire a preconfigured computer to do a deployment.

What is to be expected from doing deployments with MDX

Apart from the fact that MDX takes away the direct interaction with MDT, MDX will give the User direct control over all building blocks of the deployment chain from a single GUI. the user can start off with a computer name, check the settings and modify them and fire of the deployment to the machine.

One important thing to realize is: MDX will help the user to select ALL settings and set them without the possibility of human error (like typing). MDX eases these tasks by presenting a simple but effective UI that will help de user select those things needed MUCH faster AND easier than when he- or she would do manually in MDT itself. as a bonus it eases the management of tools like WDS or the start of MDT deployment in the traditional way.

The next post will present a real world example of deployment with MDX. till next time.

Thursday, August 22, 2013

Introducing MDX

The last weeks is have not published anything since i was working on an IT solution i am introducing here on this page.
The next posts i will elaborate and present the code of my application, this is part 1: the introduction:
MDX stands for MDT Deployment eXerience. and it is a solution targeted at Microsoft OS deployment with MDT. So you can ask me; what does it do and, even more important, what does it add to MDT since that is quite a mature OSD solution in itself. my answer will be: MDT indeed is a very great OSD solution but it has its drawbacks. let me mention a few of them:
  • The interface of MDT is quite cumbersome in respect to manipulating individual computer deployments.
  • MDT does not have any functionality to automatically start a deployment on a client
  • MDT needs ‘start-up media’ to get a deployment running like a CD or USB stick, although MDT can deliver a distribution via the network, it does not have any mechanism to control PXE servers
Because of these (and many more) drawbacks i decided to develop my own ‘shell’ around MDT and address these items.

So what does MDX do?

since i always think images speak louder then words I'll show you the interface.

As you can see the Application has its own GUI, in it there are a few input sections-, output sections and some buttons to get the whole thing running. MDX was built in PowerShell, the code for the GUI was generated by SAPIEN’s Primal Forms Community edition
MDX can do the following:
  • On input of a computer name it will try to fetch a MAC address of the particular machine, if found it will use it to add- or find this machine in MDT and attach OSD properties to it to get it deployed
  • MDX will show Computer information when the machine is online; this can be quite handy when you are to be migrating existing computers from say Windows XP to Windows 7 or 8
  • MDX has a direct link with Microsoft's WDS servers, with this link it can control PXE boots of WDS clients
  • MDX can wake a machine with Wake On LAN with one push on a button
  • MDX can start a deployment remotely with the use of PS Exec.exe (a fine piece of toolkit developed by Mark Russinovich), with this it can completely automate MDT deployments to clients.
  • MDX can add extra applications to a individual OS deployment- as well ass add an account to the local administrators group.
Al together i think it will add some nice features to MDT or as a colleague remarked “this is real automation with budget (freeware) tools!”
Next post i will elaborate on the technical workings of MDX, if all goes well i will present a download link to the source code.
till next time.

Saturday, February 23, 2013

Start MDT Litetouch deployment remote

Hello again, i am back with a script that is quite handy for IT deployments done with MDT (any version would actually work with this script)
So Microsoft made MDT to be integrated with SCCM and, if done correctly, that combination is very powerful to deploy any kind of Microsoft OS to the enterprise, but what about the smaller clients, the ones who don’t have SCCM? MDT can be used on its own and Litetouch deployments can do the trick!
There is one little thing though that has not properly been addressed by the MDT development team (at least that's my opinion) and that is to hand us a way to get deployments started remotely from the Administrators console. As always with these kind of things i am not the only one so on TechNet a thread was started to get this issue addressed.
Handed solutions were two: present a batch file with a link to the litetouch.vbs and use psexec.exe to get a deployment started remotely. (Psexec is a formidable tool, part of the sysinternals Pstools toolkit)  i have used the first one many times before but its drawbacks are: most of the time you have to log on to the remote deployment system. the Psexec solution however is really nice, that's what i used as a base for this script.
image                                 image
figure 1 the batched solution                                                         figure 2 the Psexec solution
The main difference is: the batched (first) solution is one in which the clients have to fetch the litetouch scripts by themselves, the second Psexec solution is the other way around, in this case you bring the litetouch.vbs script to the client.

$ErrorActionPreference = "SilentlyContinue"
Do {
Clear-Host
Do {
$trgMachine = Read-Host("Give the machinename that has to receive a LiteTouch deployment (Netbios or DNS name are equally good)")
    If($trgMachine -eq ""){Write-Host "Please give a name"}
}While($trgMachine -eq "")
psexec.exe -i \\$trgMachine -h -u DOMAIN\User -p Userpassword cscript.exe //B "\\MDTServer\Deploymentshare$\Scripts\litetouch.vbs"
   if($LASTEXITCODE -eq 0){Write-Host "All went well"}else{Write-Host "Something went wrong: " + $LASTEXITCODE}
 
$goOn= Read-Host("Another machine? (y)")
}while($goOn -eq "y")

Some explanation: the main line of the script is the line starting with psexec.exe it will run the command starting at cscript.exe on the remote machine (designated by $trgMachine) under credentials of the given –u Username and (optional) –p password (this gets sent in clear text so you can omit the –p option and give a password any time in the command shell when running the script) then there are some Do – While loops will restart the script when an empty hostname is found and at the end of a run. the option -h in the psexec line will suppress any UAC prompt (provided you started the script with an account (the -u option) that has local administrator rights)
To use the script, make sure you have psexec.exe installed on a location that's in one of the path locations (usually C:\Windows\System32 is a good location)
have fun and see you next time

Wednesday, February 20, 2013

A handy EventLog Reader with Powershell

Tags van Technorati: ,,,,
So here i am back with another handy script for the IT administrator.

Question: are you, like me, fed up with the tedious way Microsoft event log are to be retrieved and viewed? then i might have a (PowerShell) solution for you!

In this script i have taken some AD PowerShell plugin functions and combined it with a few .Net forms. (thanks to a post on Microsoft TechNet_ furthermore i added Get-Eventlog Cmdlet to derive any eventlog content from any machine you can access in one script. the script fetches only the first n (asked in the script “how many lines”) recent Errors or failures.



# this script reads eventlog from any Computer you can access
# Script build by Bas Huygen February 2013
# the MS forms procedures are from Microsoft: http://technet.microsoft.com/en-us/library/ff730941.aspx
$ErrorActionPreference = "SilentlyContinue"

Do{
# Procedure 1: Get all AD computers and make a selection by filtering it
Clear-Host
$compfilter = Read-Host("please make a selection of computers, this can be one name or a range by the use of * (wildcards)")
If($compfilter -eq ""){$compfilter = "*"}
$allcomps = Get-ADComputer -filter * |Select-Object Name |Sort-Object name |where {$_.name -like "$compfilter"}

# Procedure 2: Select a computer in a form
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")

$objForm2 = New-Object System.Windows.Forms.Form
$objForm2.Text = "Select a Computer"
$objForm2.Size = New-Object System.Drawing.Size(300,200)
$objForm2.StartPosition = "CenterScreen"

$objForm2.KeyPreview = $True
$objForm2.Add_KeyDown({if ($_.KeyCode -eq "Enter")
{$x=$objListBoxcmp.SelectedItem;$objForm2.Close()}})
$objForm2.Add_KeyDown({if ($_.KeyCode -eq "Escape")
{$objForm2.Close()}})

$OKButton2 = New-Object System.Windows.Forms.Button
$OKButton2.Location = New-Object System.Drawing.Size(75,120)
$OKButton2.Size = New-Object System.Drawing.Size(75,23)
$OKButton2.Text = "OK"
$OKButton2.Add_Click({$x=$objListBoxcmp.SelectedItem;$objForm2.Close()})
$objForm2.Controls.Add($OKButton2)

$CancelButton2 = New-Object System.Windows.Forms.Button
$CancelButton2.Location = New-Object System.Drawing.Size(150,120)
$CancelButton2.Size = New-Object System.Drawing.Size(75,23)
$CancelButton2.Text = "Cancel"
$CancelButton2.Add_Click({$objForm2.Close()})
$objForm2.Controls.Add($CancelButton2)

$objLabel2 = New-Object System.Windows.Forms.Label
$objLabel2.Location = New-Object System.Drawing.Size(10,20)
$objLabel2.Size = New-Object System.Drawing.Size(280,20)
$objLabel2.Text = "Please select a computer:"
$objForm2.Controls.Add($objLabel2)

$objListBoxcmp = New-Object System.Windows.Forms.ListBox
$objListBoxcmp.Location = New-Object System.Drawing.Size(10,40)
$objListBoxcmp.Size = New-Object System.Drawing.Size(260,20)
$objListBoxcmp.Height = 80

# loop through all compyters filtered out of the AD in procedure 1
ForEach ($c in $allcomps){[void] $objListBoxcmp.Items.Add($c.name)}

$objForm2.Controls.Add($objListBoxcmp)

$objForm2.Topmost = $True

$objForm2.Add_Shown({$objForm2.Activate()})
[void] $objForm2.ShowDialog()

$trgHost = $objListBoxcmp.Text

# Procedure 3: Select an Eventlog Source in a form
#[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
#[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")

$objForm = New-Object System.Windows.Forms.Form
$objForm.Text = "Select an Eventlog Source"
$objForm.Size = New-Object System.Drawing.Size(300,200)
$objForm.StartPosition = "CenterScreen"

$objForm.KeyPreview = $True
$objForm.Add_KeyDown({if ($_.KeyCode -eq "Enter")
{$x=$objListBox.SelectedItem;$objForm.Close()}})
$objForm.Add_KeyDown({if ($_.KeyCode -eq "Escape")
{$objForm.Close()}})

$OKButton = New-Object System.Windows.Forms.Button
$OKButton.Location = New-Object System.Drawing.Size(75,120)
$OKButton.Size = New-Object System.Drawing.Size(75,23)
$OKButton.Text = "OK"
$OKButton.Add_Click({$x=$objListBox.SelectedItem;$objForm.Close()})
$objForm.Controls.Add($OKButton)

$CancelButton = New-Object System.Windows.Forms.Button
$CancelButton.Location = New-Object System.Drawing.Size(150,120)
$CancelButton.Size = New-Object System.Drawing.Size(75,23)
$CancelButton.Text = "Cancel"
$CancelButton.Add_Click({$objForm.Close()})
$objForm.Controls.Add($CancelButton)

$objLabel = New-Object System.Windows.Forms.Label
$objLabel.Location = New-Object System.Drawing.Size(10,20)
$objLabel.Size = New-Object System.Drawing.Size(280,20)
$objLabel.Text = "Please select an Eventlog source:"
$objForm.Controls.Add($objLabel)

$objListBox = New-Object System.Windows.Forms.ListBox
$objListBox.Location = New-Object System.Drawing.Size(10,40)
$objListBox.Size = New-Object System.Drawing.Size(260,20)
$objListBox.Height = 80

[void] $objListBox.Items.Add("System")
[void] $objListBox.Items.Add("Application")
[void] $objListBox.Items.Add("Security")

$objForm.Controls.Add($objListBox)

$objForm.Topmost = $True

$objForm.Add_Shown({$objForm.Activate()})
[void] $objForm.ShowDialog()

$evtLog = $objListBox.Text
$howmany = Read-host ("How many lines should i fetch? (blank fetches 25 lines)")
If ($howmany -eq ""){$howmany = 25}
If($evtLog -eq "Security"){$errtype = "failureaudit"} else{ $errtype = "error"}
# now get the eventlog from the selection
Get-EventLog -ComputerName $trgHost $evtLog -Newest $howmany -EntryType $errtype
Get-EventLog -ComputerName $trgHost $evtLog -Newest $howmany -EntryType $errtype | group-object -property source -noelement |
sort-object -property count -descending

$erID = Read-Host("Zoom in to a specific event? (give IDnumber)")
If($erID -eq ""){}else{Get-EventLog -ComputerName $trgHost $evtLog -Newest $howmany -EntryType $errtype |?{$_.Index -like $erID} |select Message}
$again = Read-Host("Start again? (y)")
}while($again -eq "y" -or $again -eq "Y")





its output will like something like this:






Have fun, comments are welcome and till next time!