Microsoft System Center Virtual Machine Manager 2007 – Foundation of Virtualized Data Center. Part 2. Architecture.

Posted in Microsoft, Retrospective, Technology, Virtualization | Leave a comment

Architecture and Design. Code and Programming. Part 3. Introduction. Powershell Functions. PSVisio.ps1. MsSCVMM2k7ArchDiagramV1.ps1. Brief Summary.

 

Introduction


Hello to all readers of the blog about IT Architecture and Education.

We continue publishing articles under the conceptual title “Architecture and Design. Implementation and Operation. Code and Programming”.

In the last article, it was about displaying the Microsoft System Center Virtual Machine Manager 2007 system architecture diagram in Visio format for the corresponding series of articles. We did this work using Powershell code. The result fully met our expectations. However, the main significant drawback is the amount of code and the lack of a strategy for its reuse. With the help of functions, you can organize blocks of code for reuse and reduce its overall volume.

This post will be dedicated to this.

Powershell functions


The implementation of Powershell functions requires the placement of this code in a file and the corresponding command syntax and initialization of these elements. So, let’s create a new file PSVisio.ps1 in which all our work will be placed.

In order to initialize the code of the Powershell functions written by us, the following command should be executed:

. .\PSVisio.ps1

When making changes to the code, the modified function should be unloaded by the command:

rm Function:\NameOfFunction

And perform the initialization again with the command described above.

At the beginning of our code writing and function filling, the PSVisio.ps1 file will contain a header in the form of comments and the initial initialization of several variables. They will be used in the formation of the name of the object by consecutive numbering:

#######################################################################
#
# Powershell functions for operate Visio Drawing
#  
# Version:        0.1
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  14.09.2007
# Purpose/Change: Initial script development.
# Create function New-VisioApplication.
#
# Run:
#   
# . .\PSVisio.ps1
#
#######################################################################

# Set Variables
$Shape=0
$Line=0
$Icon=0
$Text=0
$PolyLine=0

New-VisioApplication 

Let’s recall the initial piece of code that we described in the last post:

# Step 1.
# Create Visio Object
# Create Document from Blank Template
# Set Active Page
$Application = New-Object -ComObject Visio.Application
$Application.Visible = $True
$Documents = $Application.Documents
$Document=$Application.Documents.Add('')
$Page=$Application.ActivePage
$Application.ActivePage.PageSheet

# Step 2.
# Add Basic Visio Stensils
# Set Masters Item Rectangle
$Stensil1 = $Application.Documents.Add("BASIC_M.vss")
$Rectangle = $Stensil1.Masters.Item("Rectangle")

As you can see, it starts with the operators for creating the Visio Application Object. Let’s formalize these simple steps in the form of the first function – New-VisioApplication.

Function New-VisioApplication {

#######################################################################
#
# Powershell function for create Visio Application
#  
# Version:        0.1
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  14.09.2007
# Purpose/Change: Initial script development
#
# Run:
#   
# New-VisioApplication
#
#######################################################################

# Create Visio Object
$Script:Application = New-Object -ComObject Visio.Application
$Script:Application.Visible = $True
}

The function turned out to be quite simple and does not involve working with any parameters. Do not forget to make comments with explanations to your code.

New-VisioDocument

We will describe the following function for creating a new Visio document: New-VisioDocument.

The function will create a new Visio Document based on an empty template. This function also has no input parameters.

Function New-VisioDocument {

#######################################################################
#
# Powershell function for create Visio Document
#  
# Version:        0.1
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  14.09.2007
# Purpose/Change: Initial script development
#
# Run:
#   
# New-VisioDocument
#
#######################################################################

# Create Document from Blank Template
$Script:Documents = $Script:Application.Documents
$Script:Document=$Script:Application.Documents.Add('')
}

Set-VisioPage 

The Set-VisioPage function is also straightforward. Its logic is in setting the Active page, which will be the basis of our future scheme. The function also has no input parameters.

Function Set-VisioPage {

#######################################################################
#
# Powershell function for Set Active Visio Document Page
#  
# Version:        0.1
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  14.09.2007
# Purpose/Change: Initial script development
#
# Run:
#   
# Set-VisioPage
#
#######################################################################

# Set Visio Active Page
$Script:Page=$Script:Application.ActivePage
$Script:Application.ActivePage.PageSheet
}

Add-VisioStensil

In Visio, shapes are based on stencils. Therefore, the task of the following Add-VisioStensil function is to add shape stencils from the corresponding .vss file. The function receives two input parameters: Name – the name for the stencil object, and File – the name of the stencil file.

Function Add-VisioStensil ($Name, $File) {

#######################################################################
#
# Powershell function for Add Visio Stensil
#  
# Version:        0.1
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  15.09.2007
# Purpose/Change: Initial script development
#
# Run:
#   
# Add-VisioStensil -Name "Basic" -File "BASIC_M.vss"
#
#######################################################################

# Set Expression and Add Visio Stensil
$Expression = '$Script:' + $Name + ' = $Script:Application.Documents.Add("' + $File +'")'
Invoke-Expression $Expression
}

Set-VisioStensilMasterItem

To work with a specific figure, you should specify what will be the main sample of the figure. We will design the logic of this operation in the form of the Set-VisioStensilMasterItem function. The function has two input parameters: Stensil – the name of the stencil object and Item – the name of the figure.

Function Set-VisioStensilMasterItem ($Stensil, $Item) {

#######################################################################
#
# Powershell function for Set Stensil Master Item
#  
# Version:        0.1
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  15.09.2007
# Purpose/Change: Initial script development
#
# Version:        0.2
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  17.09.2007
# Purpose/Change: Reorganize Variables
#
# Run:
#   
# Set-VisioStensilMasterItem -Stensil "Basic" -Item "Rectangle"
#
#######################################################################

# Set Expression And Set Masters Item Rectangle
$ItemWithoutSpace = $Item -replace " ",""
$Expression = '$Script:' + $ItemWithoutSpace + ' = $Script:' + $Stensil + '.Masters.Item("' + $Item + '")'
Invoke-Expression $Expression
}

Draw-VisioItem

So we came directly to the functions that will perform the actions of creating and displaying objects with the specified characteristics. To begin with, these will be simple geometric shapes – rectangle, circle, line, etc.

Let’s recall again the code fragment that performs these actions.

# Step 3.
# Draw Main Rectangle, Set Size, Set Colour
# Set Text, Size, Color, Align
# Draw Line, Set Weight, Color
$Shape1 = $Page.Drop($Rectangle, 6.375, 7.125)
$Shape1.Cells('Width').Formula = '12.2501'
$Shape1.Cells('Height').Formula = '7.25'
$Shape1.Cells('FillForegnd').Formula = '=RGB(0,153,204)'
$Shape1.Cells('LinePattern').Formula = 0
$Shape1.Text = "Microsoft Virtual Machine Manager Architecture"
$Shape1.Cells('VerticalAlign') = 0
$Shape1.Cells('Para.HorzAlign') = 0
$Shape1.Cells('Char.Size').Formula = '20 pt'
$Shape1.Cells('Char.Color').Formula = '=RGB(255,255,255)'
$Line1 = $Page.DrawLine(0.3125, 10.3438, 12.4948, 10.3438)
$Line1.Cells('LineWeight').Formula = '1 pt'
$Line1.Cells('LineColor').Formula = '=RGB(255,255,255)'

# Step 4.
# Draw Client Rectangle, Set Size, Set Colour
# Set Text, Align
# Draw Line
$Shape2 = $Page.Drop($Rectangle, 1.7656, 9.2344)
$Shape2.Cells('Width').Formula = '2.7813'
$Shape2.Cells('Height').Formula = '1.9688'
$Shape2.Cells('FillForegnd').Formula = '=RGB(209,235,241)'
$Shape2.Cells('LinePattern').Formula = 1
$Shape2.Text = "Client"
$Shape2.Cells('VerticalAlign') = 0
$Shape2.Cells('Char.Size').Formula = '14 pt'
$Line2 = $Page.DrawLine(0.4297, 9.9427, 3.0833, 9.9427)
$Line2.Cells('LineWeight').Formula = '0.5 pt'
$Line2.Cells('LineColor').Formula = '=RGB(0,0,0)'

# Step 5.
# Add Computer Items Visio Stensils
# Set Masters item PC
$Stensil2 = $Application.Documents.Add("COMPS_M.vss")
$PC1 = $Stensil2.Masters.Item("PC")

# Step 6.
# Draw item PC
# Set Text, Size
$Shape3 = $Page.Drop($PC1, 1.1173, 9.1693)
$Shape3.Text = "Administrator Console"
$Shape3.Cells('Char.Size').Formula = '10 pt'

# Step 7.
# Draw Powershell Icon
# Set Position, Size
# Set Text
$Picture1 = $Page.Import("c:\!\powershell.png")
$Picture1.Cells('Width').Formula = '0.9843'
$Picture1.Cells('Height').Formula = '0.9843'
$Picture1.Cells('PinX').Formula = '2.5547'
$Picture1.Cells('PinY').Formula = '9.2682'
$Picture1.Text = "Windows Powershell"
$Picture1.Cells('Char.Size').Formula = '10 pt'

The Draw-VisioItem function has three mandatory parameters: Master – The name of the shape sample, and the X and Y coordinates of the location. The remaining parameters, such as: FillForegnd – the color of the shape, LinePattern – the line style of the shape outline, Text – The text of the shape, VerticalAlign and ParaHorzAlign – vertical and horizontal text alignment parameters, CharSize and CharColor – the size and color of the inscription characters are optional.

Function Draw-VisioItem ($Master, $X, $Y, $Width, $Height, $FillForegnd, $LinePattern, $Text, $VerticalAlign, $ParaHorzAlign, $CharSize, $CharColor) {

#######################################################################
#
# Powershell function for Draw Visio Item
#  
# Version:        0.1
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  15.09.2007
# Purpose/Change: Initial script development
#
# Version:        0.2
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  16.09.2007
# Purpose/Change: Add Flow Control Input Parameters
#
# Version:        0.3
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  17.09.2007
# Purpose/Change: Reorganize Variables
#
# Run:
#   
# Draw-VisioItem -Master "Rectangle" -X 6.375 -Y 7.125 -Width 12.2501 -Height 7.25 -FillForegnd "RGB(0,153,204)"`
# -LinePattern 0 -Text "Microsoft Virtual Machine Manager Architecture" -VerticalAlign 0 -ParaHorzAlign 0`
# -CharSize "20 pt" -CharColor "RGB(255,255,255)"
#
#######################################################################

$Script:Shape++
$Master = $Master -replace " ",""

# Set Expression And Draw Item
$Expression = '$Script:Shape' + $Script:Shape + ' = $Script:Page.Drop(' + '$' + $Master + ',' + $X + ',' + $Y + ')'
Invoke-Expression $Expression

# Set Item Width Properties
If ($Width)
	{
		$Expression = '$Script:Shape' + $Script:Shape + '.Cells("Width").Formula = ' + $Width
		Invoke-Expression $Expression
	}

# Set Item Height Properties
If ($Height)
	{
		$Expression = '$Script:Shape' + $Script:Shape + '.Cells("Height").Formula = ' + $Height
		Invoke-Expression $Expression
	}

# Set Item FillForegnd Properties
If ($FillForegnd)
	{
		$Expression = '$Script:Shape' + $Script:Shape + '.Cells("FillForegnd").Formula = "=' +  $FillForegnd + '"'
		Invoke-Expression $Expression
	}

# Set Item LinePattern Properties
If ($LinePattern)
	{
		$Expression = '$Script:Shape' + $Script:Shape + '.Cells("LinePattern").Formula = ' + $LinePattern
		Invoke-Expression $Expression
	}

# Set Item Text
If ($Text)
	{
		$Expression = '$Script:Shape' + $Script:Shape + '.Text = "' + $Text + '"'
		Invoke-Expression $Expression
	}

# Set Item VerticalAlign Properties
If ($VerticalAlign)
	{
		$Expression = '$Script:Shape' + $Script:Shape + '.Cells("VerticalAlign").Formula = ' + $VerticalAlign
		Invoke-Expression $Expression
	}

# Set Item HorzAlign Properties
If ($ParaHorzAlign)
	{
		$Expression = '$Script:Shape' + $Script:Shape + '.Cells("Para.HorzAlign").Formula = ' + $ParaHorzAlign
		Invoke-Expression $Expression
	}

# Set Item Char.Size Properties
If ($CharSize)
	{
		$Expression = '$Script:Shape' + $Script:Shape + '.Cells("Char.Size").Formula = "' + $CharSize + '"'
		Invoke-Expression $Expression
	}

# Set Item Char.Color Properties
If ($CharColor)
	{
		$Expression = '$Script:Shape' + $Script:Shape + '.Cells("Char.Color").Formula = "=' +  $CharColor + '"'
		Invoke-Expression $Expression
	}
}

Draw-VisioLine

The Draw-VisioLine function is designed to draw a variety of lines. It has several mandatory parameters: coordinates of the beginning BeginX, BeginY, and the end coordinates EndX, EndY. Optional parameters can also be specified: LineColor – line color and arrow style BeginArrow, EndArrow.

Function Draw-VisioLine ($BeginX, $BeginY, $EndX, $EndY, $LineWeight, $LineColor, $BeginArrow, $EndArrow) {

#######################################################################
#
# Powershell function for Draw Visio Line
#  
# Version:        0.1
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  15.09.2007
# Purpose/Change: Initial script development
#
# Version:        0.2
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  17.09.2007
# Purpose/Change: Add Flow Control Input Parameters
#
# Run:
#   
# Draw-VisioLine -BeginX 0.3125 -BeginY 10.3438 -EndX 12.4948 -EndY 10.3438 -LineWeight "1 pt"`
# -LineColor "RGB(255,255,255)" -BeginArrow 4 -EndArrow 4
#
#######################################################################

$Script:Line++

# Set Expression And Draw Line
$Expression = '$Script:Line' + $Script:Line + ' = $Script:Page.DrawLine(' + $BeginX + ',' + $BeginY + ',' + $EndX + ',' + $EndY + ')'
Invoke-Expression $Expression

# Set Line Width Properties
If ($LineWeight)
	{
		$Expression = '$Script:Line' + $Script:Line + '.Cells("LineWeight").Formula = "' + $LineWeight + '"'
		Invoke-Expression $Expression
	}

# Set Line Color Properties
$Expression = '$Script:Line' + $Script:Line + '.Cells("LineColor").Formula = "=' +  $LineColor + '"'
Invoke-Expression $Expression

# Set Line Begin Arrow Properties
If ($BeginArrow)
	{
		$Expression = '$Script:Line' + $Script:Line + '.Cells("BeginArrow").Formula = ' + $BeginArrow
		Invoke-Expression $Expression
	}

# Set Line End Arrow Properties
If ($EndArrow)
	{
		$Expression = '$Script:Line' + $Script:Line + '.Cells("EndArrow").Formula = ' + $EndArrow
		Invoke-Expression $Expression
	}
}

Draw-VisioIcon 

The Draw-VisioIcon function will allow you to add pre-prepared icons in .png or .jpeg format to schemes. It has several mandatory parameters: IconPath – path and file name of the icon, dimensions Width, Height and coordinates PinX, PinY. Optional parameters are the text of the label Text and its character size CharSize.

Function Draw-VisioIcon ($IconPath, $Width, $Height, $PinX, $PinY, $Text, $CharSize) {

#######################################################################
#
# Powershell function for Draw Visio Icon
#  
# Version:        0.1
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  16.09.2007
# Purpose/Change: Initial script development
#
# Version:        0.2
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  17.09.2007
# Purpose/Change: Add Flow Control Input Parameters
#
# Run:
#   
# Draw-VisioIcon -IconPath "c:\!\powershell.png" -Width 0.9843 -Height 0.9843 -PinX 2.5547 -PinY 9.2682`
# -Text "Windows Powershell" -CharSize "10 pt"
#
#######################################################################

$Script:Icon++

# Import Icon Item
$Expression = '$Script:Icon' + $Script:Icon + ' = $Script:Page.Import("' + $IconPath + '")'
Invoke-Expression $Expression

# Set Icon Width Properties
$Expression = '$Script:Icon' + $Script:Icon + '.Cells("Width").Formula = ' + $Width
Invoke-Expression $Expression

# Set Icon Height Properties
$Expression = '$Script:Icon' + $Script:Icon + '.Cells("Height").Formula = ' + $Height
Invoke-Expression $Expression

# Set Icon PinX Properties
$Expression = '$Script:Icon' + $Script:Icon + '.Cells("PinX").Formula = ' + $PinX
Invoke-Expression $Expression

# Set Icon PinY Properties
$Expression = '$Script:Icon' + $Script:Icon + '.Cells("PinY").Formula = ' + $PinY
Invoke-Expression $Expression

# Set Icon Text
If ($Text)
	{
		$Expression = '$Script:Icon' + $Script:Icon + '.Text = "' + $Text + '"'
		Invoke-Expression $Expression
	}

# Set Icon Char.Size Properties
If ($CharSize)
	{
		$Expression = '$Script:Icon' + $Script:Icon + '.Cells("Char.Size").Formula = "' + $CharSize + '"'
		Invoke-Expression $Expression
	}
}

Resize-VisioPageToFitContents

The Resize-VisioPageToFitContents function is extremely simple, its task is to resize the page to fit the image. It has no input parameters.

Function Resize-VisioPageToFitContents {

#######################################################################
#
# Powershell function for Resize Active Visio Document Page to Fit Contents
#  
# Version:        0.1
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  17.09.2007
# Purpose/Change: Initial script development
#
# Run:
#   
# Resize-VisioPageToFitContents
#
#######################################################################

# Resize Page to Fit Contents
$Script:Page.ResizeToFitContents()
}

Save-VisioDocument

Small final steps remain. The logic of the Save-VisioDocument function is to save the created diagram as a Visio .vsd file. The function has a mandatory File parameter – the name of the Visio .vsd file.

Function Save-VisioDocument ($File) {

#######################################################################
#
# Powershell function for save Visio Document
#  
# Version:        0.1
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  17.09.2007
# Purpose/Change: Initial script development
#
# Run:
#   
# Save-VisioDocument -File 'C:\!\MsSCVMM2007Arch.vsd'
#
#######################################################################

# Save Document
$Expression = '$Script:Document.SaveAs("' + $File + '")'
Invoke-Expression $Expression
}

Close-VisioApplication 

The Close-VisioApplication function completes this storyline. It has no parameters, and the logic is only in closing the Visio application.

Function Close-VisioApplication {

#######################################################################
#
# Powershell function for create Visio Application
#  
# Version:        0.1
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  17.09.2007
# Purpose/Change: Initial script development
#
# Run:
#   
# Close-VisioApplication
#
#######################################################################

# Close Visio Application
$Script:Application.Quit()
}

PSVisio.ps1


The final output of the functions code in the PSVisio.ps1 file looks like this:

#######################################################################
#
# Powershell functions for operate Visio Drawing
#  
# Version:        0.1
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  14.09.2007
# Purpose/Change: Initial script development.
# Create function New-VisioApplication.
#
# Version:        0.2
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Change Date:    14.09.2007
# Purpose/Change: Create function New-VisioDocument.
#
# Version:        0.3
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Change Date:    14.09.2007
# Purpose/Change: Create function Set-VisioPage.
#
# Version:        0.4
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Change Date:    15.09.2007
# Purpose/Change: Create function Add-VisioStensil.
#
# Version:        0.5
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Change Date:    15.09.2007
# Purpose/Change: Create function Set-VisioStensilMasterItem.
#
# Version:        0.6
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Change Date:    15.09.2007
# Purpose/Change: Create function Draw-VisioItem.
#
# Version:        0.7
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Change Date:    15.09.2007
# Purpose/Change: Create function Draw-VisioLine.
#
# Version:        0.8
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  16.09.2007
# Purpose/Change: Change function Draw-VisioItem.
#
# Version:        0.9
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Change Date:    16.09.2007
# Purpose/Change: Create function Draw-VisioIcon.
#
# Version:        0.10
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Change Date:    17.09.2007
# Purpose/Change: Change function Draw-VisioIcon.
#
# Version:        0.11
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Change Date:    17.09.2007
# Purpose/Change: Change function Draw-VisioLine.
#
# Version:        0.12
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Change Date:    17.09.2007
# Purpose/Change: Change function Set-VisioStensilMasterItem.
#
# Version:        0.13
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Change Date:    17.09.2007
# Purpose/Change: Change function Draw-VisioItem.
#
# Version:        0.14
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Change Date:    17.09.2007
# Purpose/Change: Add function Resize-VisioPageToFitContents.
#
# Version:        0.15
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Change Date:    17.09.2007
# Purpose/Change: Add function Save-VisioDocument.
#
#
# Version:        0.16
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Change Date:    18.09.2007
# Purpose/Change: Add function Draw-VisioText.
#
# Version:        0.17
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Change Date:    18.09.2007
# Purpose/Change: Add function Draw-VisioPolyLine.
#
# Version:        0.18
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Change Date:    19.09.2007
# Purpose/Change: Change function Draw-VisioText.
#
# Run:
#   
# . .\PSVisio.ps1
#
#######################################################################

# Set Variables
$Shape=0
$Line=0
$Icon=0
$Text=0
$PolyLine=0

Function New-VisioApplication {

#######################################################################
#
# Powershell function for create Visio Application
#  
# Version:        0.1
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  14.09.2007
# Purpose/Change: Initial script development
#
# Run:
#   
# New-VisioApplication
#
#######################################################################

# Create Visio Object
$Script:Application = New-Object -ComObject Visio.Application
$Script:Application.Visible = $True
}

Function New-VisioDocument {

#######################################################################
#
# Powershell function for create Visio Document
#  
# Version:        0.1
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  14.09.2007
# Purpose/Change: Initial script development
#
# Run:
#   
# New-VisioDocument
#
#######################################################################

# Create Document from Blank Template
$Script:Documents = $Script:Application.Documents
$Script:Document=$Script:Application.Documents.Add('')
}

Function Set-VisioPage {

#######################################################################
#
# Powershell function for Set Active Visio Document Page
#  
# Version:        0.1
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  14.09.2007
# Purpose/Change: Initial script development
#
# Run:
#   
# Set-VisioPage
#
#######################################################################

# Set Visio Active Page
$Script:Page=$Script:Application.ActivePage
$Script:Application.ActivePage.PageSheet
}

Function Add-VisioStensil ($Name, $File) {

#######################################################################
#
# Powershell function for Add Visio Stensil
#  
# Version:        0.1
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  15.09.2007
# Purpose/Change: Initial script development
#
# Run:
#   
# Add-VisioStensil -Name "Basic" -File "BASIC_M.vss"
#
#######################################################################

# Set Expression and Add Visio Stensil
$Expression = '$Script:' + $Name + ' = $Script:Application.Documents.Add("' + $File +'")'
Invoke-Expression $Expression
}

Function Set-VisioStensilMasterItem ($Stensil, $Item) {

#######################################################################
#
# Powershell function for Set Stensil Master Item
#  
# Version:        0.1
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  15.09.2007
# Purpose/Change: Initial script development
#
# Version:        0.2
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  17.09.2007
# Purpose/Change: Reorganize Variables
#
# Run:
#   
# Set-VisioStensilMasterItem -Stensil "Basic" -Item "Rectangle"
#
#######################################################################

# Set Expression And Set Masters Item Rectangle
$ItemWithoutSpace = $Item -replace " ",""
$Expression = '$Script:' + $ItemWithoutSpace + ' = $Script:' + $Stensil + '.Masters.Item("' + $Item + '")'
Invoke-Expression $Expression
}

Function Draw-VisioItem ($Master, $X, $Y, $Width, $Height, $FillForegnd, $LinePattern, $Text, $VerticalAlign, $ParaHorzAlign, $CharSize, $CharColor) {

#######################################################################
#
# Powershell function for Draw Visio Item
#  
# Version:        0.1
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  15.09.2007
# Purpose/Change: Initial script development
#
# Version:        0.2
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  16.09.2007
# Purpose/Change: Add Flow Control Input Parameters
#
# Version:        0.3
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  17.09.2007
# Purpose/Change: Reorganize Variables
#
# Run:
#   
# Draw-VisioItem -Master "Rectangle" -X 6.375 -Y 7.125 -Width 12.2501 -Height 7.25 -FillForegnd "RGB(0,153,204)"`
# -LinePattern 0 -Text "Microsoft Virtual Machine Manager Architecture" -VerticalAlign 0 -ParaHorzAlign 0`
# -CharSize "20 pt" -CharColor "RGB(255,255,255)"
#
#######################################################################

$Script:Shape++
$Master = $Master -replace " ",""

# Set Expression And Draw Item
$Expression = '$Script:Shape' + $Script:Shape + ' = $Script:Page.Drop(' + '$' + $Master + ',' + $X + ',' + $Y + ')'
Invoke-Expression $Expression

# Set Item Width Properties
If ($Width)
	{
		$Expression = '$Script:Shape' + $Script:Shape + '.Cells("Width").Formula = ' + $Width
		Invoke-Expression $Expression
	}

# Set Item Height Properties
If ($Height)
	{
		$Expression = '$Script:Shape' + $Script:Shape + '.Cells("Height").Formula = ' + $Height
		Invoke-Expression $Expression
	}

# Set Item FillForegnd Properties
If ($FillForegnd)
	{
		$Expression = '$Script:Shape' + $Script:Shape + '.Cells("FillForegnd").Formula = "=' +  $FillForegnd + '"'
		Invoke-Expression $Expression
	}

# Set Item LinePattern Properties
If ($LinePattern)
	{
		$Expression = '$Script:Shape' + $Script:Shape + '.Cells("LinePattern").Formula = ' + $LinePattern
		Invoke-Expression $Expression
	}

# Set Item Text
If ($Text)
	{
		$Expression = '$Script:Shape' + $Script:Shape + '.Text = "' + $Text + '"'
		Invoke-Expression $Expression
	}

# Set Item VerticalAlign Properties
If ($VerticalAlign)
	{
		$Expression = '$Script:Shape' + $Script:Shape + '.Cells("VerticalAlign").Formula = ' + $VerticalAlign
		Invoke-Expression $Expression
	}

# Set Item HorzAlign Properties
If ($ParaHorzAlign)
	{
		$Expression = '$Script:Shape' + $Script:Shape + '.Cells("Para.HorzAlign").Formula = ' + $ParaHorzAlign
		Invoke-Expression $Expression
	}

# Set Item Char.Size Properties
If ($CharSize)
	{
		$Expression = '$Script:Shape' + $Script:Shape + '.Cells("Char.Size").Formula = "' + $CharSize + '"'
		Invoke-Expression $Expression
	}

# Set Item Char.Color Properties
If ($CharColor)
	{
		$Expression = '$Script:Shape' + $Script:Shape + '.Cells("Char.Color").Formula = "=' +  $CharColor + '"'
		Invoke-Expression $Expression
	}
}

Function Draw-VisioLine ($BeginX, $BeginY, $EndX, $EndY, $LineWeight, $LineColor, $BeginArrow, $EndArrow) {

#######################################################################
#
# Powershell function for Draw Visio Line
#  
# Version:        0.1
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  15.09.2007
# Purpose/Change: Initial script development
#
# Version:        0.2
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  17.09.2007
# Purpose/Change: Add Flow Control Input Parameters
#
# Run:
#   
# Draw-VisioLine -BeginX 0.3125 -BeginY 10.3438 -EndX 12.4948 -EndY 10.3438 -LineWeight "1 pt"`
# -LineColor "RGB(255,255,255)" -BeginArrow 4 -EndArrow 4
#
#######################################################################

$Script:Line++

# Set Expression And Draw Line
$Expression = '$Script:Line' + $Script:Line + ' = $Script:Page.DrawLine(' + $BeginX + ',' + $BeginY + ',' + $EndX + ',' + $EndY + ')'
Invoke-Expression $Expression

# Set Line Width Properties
If ($LineWeight)
	{
		$Expression = '$Script:Line' + $Script:Line + '.Cells("LineWeight").Formula = "' + $LineWeight + '"'
		Invoke-Expression $Expression
	}

# Set Line Color Properties
$Expression = '$Script:Line' + $Script:Line + '.Cells("LineColor").Formula = "=' +  $LineColor + '"'
Invoke-Expression $Expression

# Set Line Begin Arrow Properties
If ($BeginArrow)
	{
		$Expression = '$Script:Line' + $Script:Line + '.Cells("BeginArrow").Formula = ' + $BeginArrow
		Invoke-Expression $Expression
	}

# Set Line End Arrow Properties
If ($EndArrow)
	{
		$Expression = '$Script:Line' + $Script:Line + '.Cells("EndArrow").Formula = ' + $EndArrow
		Invoke-Expression $Expression
	}
}

Function Draw-VisioIcon ($IconPath, $Width, $Height, $PinX, $PinY, $Text, $CharSize) {

#######################################################################
#
# Powershell function for Draw Visio Icon
#  
# Version:        0.1
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  16.09.2007
# Purpose/Change: Initial script development
#
# Version:        0.2
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  17.09.2007
# Purpose/Change: Add Flow Control Input Parameters
#
# Run:
#   
# Draw-VisioIcon -IconPath "c:\!\powershell.png" -Width 0.9843 -Height 0.9843 -PinX 2.5547 -PinY 9.2682`
# -Text "Windows Powershell" -CharSize "10 pt"
#
#######################################################################

$Script:Icon++

# Import Icon Item
$Expression = '$Script:Icon' + $Script:Icon + ' = $Script:Page.Import("' + $IconPath + '")'
Invoke-Expression $Expression

# Set Icon Width Properties
$Expression = '$Script:Icon' + $Script:Icon + '.Cells("Width").Formula = ' + $Width
Invoke-Expression $Expression

# Set Icon Height Properties
$Expression = '$Script:Icon' + $Script:Icon + '.Cells("Height").Formula = ' + $Height
Invoke-Expression $Expression

# Set Icon PinX Properties
$Expression = '$Script:Icon' + $Script:Icon + '.Cells("PinX").Formula = ' + $PinX
Invoke-Expression $Expression

# Set Icon PinY Properties
$Expression = '$Script:Icon' + $Script:Icon + '.Cells("PinY").Formula = ' + $PinY
Invoke-Expression $Expression

# Set Icon Text
If ($Text)
	{
		$Expression = '$Script:Icon' + $Script:Icon + '.Text = "' + $Text + '"'
		Invoke-Expression $Expression
	}

# Set Icon Char.Size Properties
If ($CharSize)
	{
		$Expression = '$Script:Icon' + $Script:Icon + '.Cells("Char.Size").Formula = "' + $CharSize + '"'
		Invoke-Expression $Expression
	}
}

Function Resize-VisioPageToFitContents {

#######################################################################
#
# Powershell function for Resize Active Visio Document Page to Fit Contents
#  
# Version:        0.1
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  17.09.2007
# Purpose/Change: Initial script development
#
# Run:
#   
# Resize-VisioPageToFitContents
#
#######################################################################

# Resize Page to Fit Contents
$Script:Page.ResizeToFitContents()
}

Function Save-VisioDocument ($File) {

#######################################################################
#
# Powershell function for save Visio Document
#  
# Version:        0.1
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  17.09.2007
# Purpose/Change: Initial script development
#
# Run:
#   
# Save-VisioDocument -File 'C:\!\MsSCVMM2007Arch.vsd'
#
#######################################################################

# Save Document
$Expression = '$Script:Document.SaveAs("' + $File + '")'
Invoke-Expression $Expression
}

Function Close-VisioApplication {

#######################################################################
#
# Powershell function for create Visio Application
#  
# Version:        0.1
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  17.09.2007
# Purpose/Change: Initial script development
#
# Run:
#   
# Close-VisioApplication
#
#######################################################################

# Close Visio Application
$Script:Application.Quit()
}

Function Draw-VisioText ($X, $Y, $Width, $Height, $FillForegnd, $LinePattern, $Text, $VerticalAlign, $ParaHorzAlign, $CharSize, $CharColor, $CharStyle, $FillForegndTrans) {

#######################################################################
#
# Powershell function for Draw Visio Text Label
#  
# Version:        0.1
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  18.09.2007
# Purpose/Change: Initial script development
#
# Version:        0.2
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  19.09.2007
# Purpose/Change: Add CharStyle Parameter
#
# Run:
#   
# Draw-VisioText -X 4.25 -Y 8.875 -Width 1.3751 -Height 0.375 -Text "Microsoft Virtual Machine Manager Architecture"`
# -LinePattern "0" -FillForegndTrans "100%" -CharStyle 17
#
#######################################################################

$Script:Text++
$Master = "Rectangle"

# Set Expression And Draw Text
$Expression = '$Script:Text' + $Script:Text + ' = $Script:Page.Drop(' + '$' + $Master + ',' + $X + ',' + $Y + ')'
Invoke-Expression $Expression

# Set Item Width Properties
If ($Width)
	{
		$Expression = '$Script:Text' + $Script:Text + '.Cells("Width").Formula = ' + $Width
		Invoke-Expression $Expression
	}

# Set Item Height Properties
If ($Height)
	{
		$Expression = '$Script:Text' + $Script:Text + '.Cells("Height").Formula = ' + $Height
		Invoke-Expression $Expression
	}

# Set Item FillForegnd Properties
If ($FillForegnd)
	{
		$Expression = '$Script:Text' + $Script:Text + '.Cells("FillForegnd").Formula = "=' +  $FillForegnd + '"'
		Invoke-Expression $Expression
	}

# Set Item LinePattern Properties
If ($LinePattern)
	{
		$Expression = '$Script:Text' + $Script:Text + '.Cells("LinePattern").Formula = ' + $LinePattern
		Invoke-Expression $Expression
	}

# Set Item Text
If ($Text)
	{
		$Expression = '$Script:Text' + $Script:Text + '.Text = "' + $Text + '"'
		Invoke-Expression $Expression
	}

# Set Item VerticalAlign Properties
If ($VerticalAlign)
	{
		$Expression = '$Script:Text' + $Script:Text + '.Cells("VerticalAlign").Formula = ' + $VerticalAlign
		Invoke-Expression $Expression
	}

# Set Item HorzAlign Properties
If ($ParaHorzAlign)
	{
		$Expression = '$Script:Text' + $Script:Text + '.Cells("Para.HorzAlign").Formula = ' + $ParaHorzAlign
		Invoke-Expression $Expression
	}

# Set Item Char.Size Properties
If ($CharSize)
	{
		$Expression = '$Script:Text' + $Script:Text + '.Cells("Char.Size").Formula = "' + $CharSize + '"'
		Invoke-Expression $Expression
	}

# Set Item Char.Color Properties
If ($CharColor)
	{
		$Expression = '$Script:Text' + $Script:Text + '.Cells("Char.Color").Formula = "=' +  $CharColor + '"'
		Invoke-Expression $Expression
	}
	
# Set Item Char.Style Properties
If ($CharStyle)
	{
		$Expression = '$Script:Text' + $Script:Text + '.Cells("Char.Style").Formula = "' + $CharStyle + '"'
		Invoke-Expression $Expression
	}
	
# Set Item FillForegndTrans Properties
If ($FillForegndTrans)
	{
		$Expression = '$Script:Text' + $Script:Text + '.Cells("FillForegndTrans").Formula = "' + $FillForegndTrans + '"'
		Invoke-Expression $Expression
	}		
}

Function Draw-VisioPolyLine ($PolyLine, $LineWeight, $LineColor, $BeginArrow, $EndArrow) {

#######################################################################
#
# Powershell function for Draw Visio PolyLine
#  
# Version:        0.1
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  18.09.2007
# Purpose/Change: Initial script development
#
# Run:
#   
# Draw-VisioPolyLine -Polyline 1.0938,9.0625,1.4063,9.0625,1.4063,8.6563,1.0938,8.6563 -LineWeight "0.5 pt"`
# -LineColor "RGB(255,255,255)" -BeginArrow 1 -EndArrow 1
#
#######################################################################

$Script:PolyLine++
[double[]]$PolyLineCoordinates=@()
$PolyLineCoordinates += $Polyline

# Set Expression And Draw PolyLine
$Expression = '$Script:PolyLine' + $Script:PolyLine + ' = $Script:Page.DrawPolyLine(($PolyLineCoordinates),0)'
Invoke-Expression $Expression

# Set Line Width Properties
If ($LineWeight)
	{
		$Expression = '$Script:PolyLine' + $Script:PolyLine + '.Cells("LineWeight").Formula = "' + $LineWeight + '"'
		Invoke-Expression $Expression
	}

# Set Line Color Properties
$Expression = '$Script:PolyLine' + $Script:PolyLine + '.Cells("LineColor").Formula = "=' +  $LineColor + '"'
Invoke-Expression $Expression

# Set Line Begin Arrow Properties
If ($BeginArrow)
	{
		$Expression = '$Script:PolyLine' + $Script:PolyLine + '.Cells("BeginArrow").Formula = ' + $BeginArrow
		Invoke-Expression $Expression
	}

# Set Line End Arrow Properties
If ($EndArrow)
	{
		$Expression = '$Script:PolyLine' + $Script:PolyLine + '.Cells("EndArrow").Formula = ' + $EndArrow
		Invoke-Expression $Expression
	}
}

The current version of the above code is in the Git repository at this link: PSVisio.ps1.

MsSCVMM2k7ArchDiagramV1.ps1


Accordingly, the code for forming the Microsoft System Center Virtual Machine Manager 2007 system architecture diagram in Visio format:

. .\PSVisio.ps1

# Step 1.
# Create Visio Application
# Create Document from Blank Template
# Set Active Page
New-VisioApplication
New-VisioDocument
Set-VisioPage

# Step 2.
# Add Basic Visio Stensils
# Set Masters Item Rectangle
Add-VisioStensil -Name "Basic" -File "BASIC_M.vss"
Set-VisioStensilMasterItem -Stensil Basic -Item "Rectangle"

# Step 3.
# Draw Main Rectangle, Set Size, Set Colour
# Set Text, Size, Color, Align
# Draw Line, Set Weight, Color
Draw-VisioItem -Master "Rectangle" -X 6.375 -Y 7.125 -Width 12.2501 -Height 7.25 -FillForegnd "RGB(0,153,204)"`
 -LinePattern 0 -Text "Microsoft Virtual Machine Manager Architecture" -VerticalAlign '0' -ParaHorzAlign '0'`
 -CharSize "20 pt" -CharColor "RGB(255,255,255)"
Draw-VisioLine -BeginX 0.3125 -BeginY 10.3438 -EndX 12.4948 -EndY 10.3438 -LineWeight "1 pt" -LineColor "RGB(255,255,255)"
 
# Step 4.
# Draw Client Rectangle, Set Size, Set Colour
# Set Text, Align
# Draw Line
Draw-VisioItem -Master "Rectangle" -X 1.7656 -Y 9.2344 -Width 2.7813 -Height 1.9688 -FillForegnd "RGB(209,235,241)"`
 -LinePattern 1 -Text "Client" -VerticalAlign '0' -ParaHorzAlign '1'`
 -CharSize "14 pt" -CharColor "RGB(0,0,0)"
Draw-VisioLine -BeginX 0.4297 -BeginY 9.9427 -EndX 3.0833 -EndY 9.9427 -LineWeight "0.5 pt" -LineColor "RGB(0,0,0)"

# Step 5.
# Add Computer Items Visio Stensils
# Set Masters item PC
Add-VisioStensil -Name "Computer" -File "COMPS_M.vss"
Set-VisioStensilMasterItem -Stensil "Computer" -Item "PC"

# Step 6.
# Draw item PC
# Set Text, Size
Draw-VisioItem -Master "PC" -X 1.1173 -Y 9.1693 -Text "Administrator Console" -CharSize "10 pt"

# Step 7.
# Draw Powershell Icon
# Set Position, Size
# Set Text
Draw-VisioIcon -IconPath "c:\!\powershell.png" -Width 0.9843 -Height 0.9843 -PinX 2.5547 -PinY 9.2682 `
 -Text "Windows Powershell" -CharSize "10 pt"

# Step 8.
# Draw WCF Rectangle, Set Size, Set Colour
# Set Text, Align
# Draw Line
Draw-VisioItem -Master "Rectangle" -X 4.2682 -Y 6.9063 -Width 1.5 -Height 6.625 -FillForegnd "RGB(255,255,255)"`
 -LinePattern 1 -Text "Windows Communication Foundation" -VerticalAlign '0'`
 -CharSize "14 pt"
Draw-VisioLine -BeginX 3.5664 -BeginY 9.4063 -EndX 4.9492 -EndY 9.4063 -LineWeight "0.5 pt" -LineColor "RGB(0,0,0)"

# Step 9.----
# Draw WCF Icon
# Set Position, Size
Draw-VisioIcon -IconPath "c:\!\WCF.png" -Width 1.412 -Height 1.0443 -PinX 4.2708 -PinY 6.9779

# Step 10.
# Draw Line communication from Client to WCF
# Set Arrow
Draw-VisioLine -BeginX 3.1563 -BeginY 9.2396 -EndX 3.5174 -EndY 9.2396 -LineColor "RGB(255,255,255)" -BeginArrow 4 -EndArrow 4

# Step 11.
# Draw Web Client Rectangle, Set Size, Set Colour
# Set Text, Align
# Draw Line
Draw-VisioItem -Master "Rectangle" -X 1.7656 -Y 6.8776 -Width 2.7813 -Height 2.1094 -FillForegnd "RGB(209,235,241)"`
 -LinePattern 1 -Text "Web Client" -VerticalAlign '0'`
 -CharSize "14 pt"
Draw-VisioLine -BeginX 0.4297 -BeginY 7.6562 -EndX 3.0833 -EndY 7.6562 -LineWeight "0.5 pt" -LineColor "RGB(0,0,0)"

# Step 12.
# Draw Self Service Portal Icon
# Set Position, Size
# Set Text
Draw-VisioIcon -IconPath "c:\!\SelfServicePortal.png" -Width 0.8438 -Height 0.8438 -PinX 1.1094 -PinY 6.9271 `
 -Text "Self Service Portal" -CharSize "10 pt"

# Step 13.
# Draw Powershell Icon
# Set Position, Size
# Set Text
Draw-VisioIcon -IconPath "c:\!\powershell.png" -Width 0.9843 -Height 0.9843 -PinX 2.4922 -PinY 6.9192 `
 -Text "Windows Powershell" -CharSize "10 pt"

# Step 14.
# Draw Line communication from Web Client to WCF
# Set Arrow
Draw-VisioLine -BeginX 3.158 -BeginY 6.8802 -EndX 3.5191 -EndY 6.8802 -LineColor "RGB(255,255,255)" -BeginArrow 4 -EndArrow 4

# Step 15.
# Draw Scripting Client Rectangle, Set Size, Set Colour
# Set Text, Align
# Draw Line
Draw-VisioItem -Master "Rectangle" -X 1.7657 -Y 4.5469 -Width 2.7813 -Height 1.9062 -FillForegnd "RGB(209,235,241)"`
 -LinePattern 1 -Text "Scripting Client" -VerticalAlign '0'`
 -CharSize "14 pt"
Draw-VisioLine -BeginX 0.4297 -BeginY 5.1979 -EndX 3.0834 -EndY 5.1979 -LineWeight "0.5 pt" -LineColor "RGB(0,0,0)"

# Step 16.
# Draw Powershell Icon
# Set Position, Size
# Set Text
Draw-VisioIcon -IconPath "c:\!\powershell.png" -Width 0.9843 -Height 0.9843 -PinX 1.7631 -PinY 4.6015 `
 -Text "Windows Powershell" -CharSize "10 pt"

# Step 17.
# Draw Line communication from Scripting Client to WCF
# Set Arrow
Draw-VisioLine -BeginX 3.158 -BeginY 4.5729 -EndX 3.5191 -EndY 4.5729 -LineColor "RGB(255,255,255)" -BeginArrow 4 -EndArrow 4

# Step 18.
# Draw Microsoft System Center
# Virtual Machine Manager Server 2007 Rectangle
# Set Size, Set Colour
# Set Text, Align
Draw-VisioItem -Master "Rectangle" -X 6.3281 -Y 8.2812 -Width 1.5 -Height 2.8125 -FillForegnd "RGB(255,192,0)"`
 -LinePattern 1 -Text "Microsoft System Center Virtual Machine Manager Server 2007" -CharSize "14 pt"

# Step 19.
# Draw Microsoft SQL Server 2005 Rectangle
# Set Size, Set Colour
# Set Text, Align
Draw-VisioItem -Master "Rectangle" -X 6.3281 -Y 4.9219 -Width 1.5 -Height 2.6563 -FillForegnd "RGB(255,192,0)"`
 -LinePattern 1 -Text "Microsoft SQL Server 2005" -CharSize "14 pt"

# Step 20.
# Add Server Items Visio Stensils
# Set Masters item Management Server and Database Server
Add-VisioStensil -Name "Server" -File "SERVER_M.vss"
Set-VisioStensilMasterItem -Stensil "Server" -Item "Management server"
Set-VisioStensilMasterItem -Stensil "Server" -Item "Database server"

# Step 21.
# Draw item Management Server
Draw-VisioItem -Master "Management server" -X 5.6043 -Y 9.7421

# Step 22.
# Draw item Management Server
Draw-VisioItem -Master "Database server" -X 5.5832 -Y 6.3046

# Step 23.
# Draw Line communication from WCF to Microsoft System Center
# Virtual Machine Manager Server 2007
# Set Arrow
Draw-VisioLine -BeginX 5.0052 -BeginY 8.2604 -EndX 5.6024 -EndY 8.2604 -LineColor "RGB(255,255,255)" -BeginArrow 4 -EndArrow 4

# Step 24.
# Draw Line communication from Microsoft System Center
# Virtual Machine Manager Server 2007 to Microsoft SQL Server 2005
# Set Arrow
Draw-VisioLine -BeginX 6.3272 -BeginY 6.2344 -EndX 6.3272 -EndY 6.8802 -LineColor "RGB(255,255,255)" -BeginArrow 4 -EndArrow 0

# Step 25.
# Draw Win-RM Rectangle, Set Size, Set Colour
# Set Text, Align
# Draw Line
Draw-VisioItem -Master "Rectangle" -X 8.4375 -Y 6.9219 -Width 1.5 -Height 6.6563 -FillForegnd "RGB(255,255,255)"`
 -LinePattern 1 -Text "Windows Remote Managemet (Win-RM)" -VerticalAlign '0'`
 -CharSize "14 pt"
Draw-VisioLine -BeginX 7.75 -BeginY 9.1875 -EndX 9.1328 -EndY 9.1875 -LineWeight "0.5 pt" -LineColor "RGB(0,0,0)"

# Step 26.
# Draw Win-RM Icon
# Set Position, Size
Draw-VisioIcon -IconPath "c:\!\Win-RM.png" -Width 1.1563 -Height 1.1563 -PinX 8.4293 -PinY 7

# Step 27.
# Draw Line communication from Win-RM to Microsoft System Center
# Virtual Machine Manager Server 2007
# Set Arrow
Draw-VisioLine -BeginX 7.0781 -BeginY 8.2812 -EndX 7.6753 -EndY 8.2812 -LineColor "RGB(255,255,255)" -BeginArrow 4 -EndArrow 4

# Step 28.
# Draw P2V Source Rectangle, Set Size, Set Colour
# Set Text, Align
# Draw Line
Draw-VisioItem -Master "Rectangle" -X 10.9844 -Y 9.5 -Width 2.7813 -Height 1.5 -FillForegnd "RGB(209,235,241)"`
 -LinePattern 1 -Text "P2V Source" -VerticalAlign '0'`
 -CharSize "14 pt"
Draw-VisioLine -BeginX 9.6485 -BeginY 9.9739 -EndX 12.3021 -EndY 9.9739 -LineWeight "0.5 pt" -LineColor "RGB(0,0,0)"

# Step 29.
# Draw VMM Agent Icon
# Set Position, Size
# Set Text
Draw-VisioIcon -IconPath "c:\!\VMMAgent.png" -Width 0.8438 -Height 0.8438 -PinX 10.2969 -PinY 9.5 `
 -Text "VMM Agent" -CharSize "10 pt"

# Step 30.
# Draw Powershell Icon
# Set Position, Size
# Set Text
Draw-VisioIcon -IconPath "c:\!\powershell.png" -Width 0.7968 -Height 0.7968 -PinX 11.6016 -PinY 9.6016 `
 -Text "Windows Powershell" -CharSize "10 pt"

# Step 31.
# Draw Line communication from P2V Source to Win-RM
# Set Arrow
Draw-VisioLine -BeginX 9.1875 -BeginY 9.487 -EndX 9.599 -EndY 9.487 -LineColor "RGB(255,255,255)" -BeginArrow 4 -EndArrow 4

# Step 32.
# Draw Host Rectangle, Set Size, Set Colour
# Set Text, Align
# Draw Line
Draw-VisioItem -Master "Rectangle" -X 10.9792 -Y 6.9427 -Width 2.7813 -Height 1.5 -FillForegnd "RGB(209,235,241)"`
 -LinePattern 1 -Text "Host" -VerticalAlign '0'`
 -CharSize "14 pt"
Draw-VisioLine -BeginX 9.6472 -BeginY 7.4219 -EndX 12.3008 -EndY 7.4219 -LineWeight "0.5 pt" -LineColor "RGB(0,0,0)"

# Step 33.
# Draw VMM Agent Icon
# Set Position, Size
# Set Text
Draw-VisioIcon -IconPath "c:\!\VMMAgent.png" -Width 0.8438 -Height 0.8438 -PinX 10.2917 -PinY 6.9427 `
 -Text "VMM Agent" -CharSize "10 pt"

# Step 34.
# Draw Microsoft Virtual Server 2005 R2 Icon
# Set Position, Size
# Set Text
Draw-VisioIcon -IconPath "c:\!\WS.jpg" -Width 0.8125 -Height 0.7404 -PinX 11.5938 -PinY 6.9423 `
 -Text "Microsoft Virtual Server 2005 R2" -CharSize "7 pt"

# Step 35.
# Draw Line communication from Host to Win-RM
# Set Arrow
Draw-VisioLine -BeginX 9.1849 -BeginY 6.941 -EndX 9.5964 -EndY 6.941 -LineColor "RGB(255,255,255)" -BeginArrow 4 -EndArrow 4

# Step 36.
# Draw Library Rectangle, Set Size, Set Colour
# Set Text, Align
# Draw Line
Draw-VisioItem -Master "Rectangle" -X 10.9792 -Y 4.3542 -Width 2.7813 -Height 1.5 -FillForegnd "RGB(209,235,241)"`
 -LinePattern 1 -Text "Library" -VerticalAlign '0'`
 -CharSize "14 pt"
Draw-VisioLine -BeginX 9.6419 -BeginY 4.8073 -EndX 12.2955 -EndY 4.8073 -LineWeight "0.5 pt" -LineColor "RGB(0,0,0)"

# Step 37.
# Draw VMM Agent Icon
# Set Position, Size
# Set Text
Draw-VisioIcon -IconPath "c:\!\VMMAgent.png" -Width 0.8438 -Height 0.8438 -PinX 10.2917 -PinY 4.3542 `
 -Text "VMM Agent" -CharSize "10 pt"

# Step 38.
# Draw Windows Server 2003 R2 Icon
# Set Position, Size
# Set Text
Draw-VisioIcon -IconPath "c:\!\WS.jpg" -Width 0.8125 -Height 0.7404 -PinX 11.5625 -PinY 4.3702 `
 -Text "Windows Server 2003 R2" -CharSize "7 pt"

# Step 39.
# Draw Line communication from Library to Win-RM
# Set Arrow
Draw-VisioLine -BeginX 9.1901 -BeginY 4.3611 -EndX 9.6016 -EndY 4.3611 -LineColor "RGB(255,255,255)" -BeginArrow 4 -EndArrow 4

# Step 40.
# Draw BITS Rectangle, Set Size, Set Colour
# Set Text, Align
# Draw Line
Draw-VisioItem -Master "Rectangle" -X 10.9844 -Y 8.2292 -Width 2.75 -Height 0.5625 -FillForegnd "RGB(255,255,0)"`
 -LinePattern 1 -Text "BITS" -ParaHorzAlign '0'`
 -CharSize "14 pt"

# Step 41.
# Draw BITS Icon
# Set Position, Size
# Set Text
Draw-VisioIcon -IconPath "c:\!\BITS.jpg" -Width 0.5417 -Height 0.5417 -PinX 10.974 -PinY 8.2344

# Step 42.
# Draw Line communication from BITS to P2V Source
# Set Arrow
Draw-VisioLine -BeginX 10.9844 -BeginY 8.5104 -EndX 10.9844 -EndY 8.75 -LineColor "RGB(255,255,255)" -BeginArrow 4 -EndArrow 4

# Step 43.
# Draw Line communication from BITS to Host
# Set Arrow
Draw-VisioLine -BeginX 10.9844 -BeginY 7.6849 -EndX 10.9844 -EndY 7.9219 -LineColor "RGB(255,255,255)" -BeginArrow 4 -EndArrow 4

# Step 44.
# Draw BITS Rectangle, Set Size, Set Colour
# Set Text, Align
# Draw Line
Draw-VisioItem -Master "Rectangle" -X 10.9844 -Y 5.6555 -Width 2.75 -Height 0.5625 -FillForegnd "RGB(255,255,0)"`
 -LinePattern 1 -Text "BITS" -ParaHorzAlign '0'`
 -CharSize "14 pt"

# Step 45.
# Draw BITS Icon
# Set Position, Size
# Set Text
Draw-VisioIcon -IconPath "c:\!\BITS.jpg" -Width 0.5417 -Height 0.5417 -PinX 10.974 -PinY 5.6607

# Step 46.
# Draw Line communication from BITS to Host 
# Set Arrow
Draw-VisioLine -BeginX 10.9844 -BeginY 5.9245 -EndX 10.9844 -EndY 6.1901 -LineColor "RGB(255,255,255)" -BeginArrow 4 -EndArrow 4

# Step 47.
# Draw Line communication from BITS to Library
# Set Arrow
Draw-VisioLine -BeginX 10.9792 -BeginY 5.1042 -EndX 10.9792 -EndY 5.375 -LineColor "RGB(255,255,255)" -BeginArrow 4 -EndArrow 4

# Step 48.
# Resise Page To Fit Contents
Resize-VisioPageToFitContents

# Step 49.
# Save Document
# And Quit Application
Save-VisioDocument -File 'C:\!\MsSCVMM2007Arch.vsd'
Close-VisioApplication

The current version of the above code is in the Git repository at this link: MsSCVMM2k7ArchDiagramV1.ps1.

Brief Summary


Therefore, the final result is completely similar to the one described in previous publications, but optimization using functions allowed to reduce the volume of the code from 516 lines to 326. The code became more optimal and readable. The code reuse strategy is also a positive factor.

However, there are still tasks to be implemented: the functions should have a code for checking the input parameters for correctness, and add and expand algorithms for working with more complex shapes.

But that will be discussed in the next publications.

See you.

Sincerely, AIRRA!

Posted in Architecture, Code, Design, Microsoft, Programming | Tagged , , , , , , , , , , , , , , , , | Leave a comment

Microsoft System Center Virtual Machine Manager 2007 – Foundation of Virtualized Data Center. Part 1. First glance. General Features. Integrations. Brief Summary.

First glance


It has been three years since Microsoft acquired Connectix. Finally, Microsoft is releasing a corporate segment management tool for Virtual Server: Virtual Machine Manager 2007, part of the System Center product family.

Microsoft System Center Virtual Machine Manager 2007 is a complete solution for managing a virtualized data center, which allows you to increase the physical utilization of servers and provide centralized management of the virtual machine infrastructure.

General Features


The first edition of System Center Virtual Machine Manager contains the following virtual infrastructure management features:

  • Support for the life cycle of virtual machines;
  • Centralized library for reference images of virtual machines, scripts and ISO images;
  • Fast and reliable conversion of a physical server into a virtual machine (P2V migration);
  • Fast and reliable conversion of a virtual machine into a virtual machine (V2V migration);
  • Providing self-service functionality through a web portal;
  • Enhanced automation scenarios through integration with PowerShell;
  • Integration with System Center Operation Manager 2007 for virtual data center monitoring and capacity planning;
  • Integration with System Center Configuration Manager 2007 to upgrade virtual machines offline;
  • Integration with System Center Manager Data Protection Manager 2007 to backup running virtual machines.
Picture 1: The Virtual Machine Manager Administrator Console.

Integration


The Virtual Machine Manager Administrator Console is built on the familiar Operations Manager 2007 user interface, allowing administrators to quickly and easily manage their virtual machines. Comprehensive monitoring of the health of hosts, virtual machines, library servers, and Virtual Machine Manager components is provided through the Virtualization Management Pack in Operations Manager 2007.

System Center Virtual Machine Manager is also integrated with familiar tools and technologies. For example, Virtual Machine Manager uses a SQL Server database to store performance and configuration data, and reporting capabilities in Virtual Machine Manager use familiar SQL Reporting Services technologies that are actually provided through System Center Operations Manager.

Brief Summary


The first release of Microsoft System Center Virtual Machine Manager 2007 has proven to be a comprehensive solution for managing virtualized environments. Integration with other System Center products and PowerShell support opens wide possibilities for administrators.

However, the main focus in the upcoming posts will be on SCVMM architecture — from design principles to optimal deployment models in enterprise infrastructures.

More details on this will be provided in future materials.

See you in a few days.
Best regards, AIRRA!

 

Posted in Microsoft, Retrospective, Technology, Virtualization | Tagged , , , , , , , , , , , | Leave a comment

Architecture and Design. Code and Programming. Part 2. Introduction. Microsoft Visio and PowerShell. First steps. Brief Summary and Next Steps.

 

Introduction


Hello to all readers of the blog about IT Architecture and Education.

We continue publishing articles under the conceptual title “Architecture and Design. Implementation and Operation. Code and Programming”.

In the previous article, we talked about this concept in general and about creating an environment and setting up tools for developing code.

Today we’ll start writing code to display a Microsoft System Center Virtual Machine Manager 2007 system architecture diagram in Visio format for a related series of articles.

Microsoft Visio and PowerShell. First steps


So let’s start with simple steps.

Let’s create a Visio application object and a new document based on an empty template. Let’s set the active page, on which we will later programmatically draw our architectural scheme.

# Step 1.
# Create Visio Object
# Create Document from Blank Template
# Set Active Page
$Application = New-Object -ComObject Visio.Application
$Application.Visible = $True
$Documents = $Application.Documents
$Document=$Application.Documents.Add('')
$Page=$Application.ActivePage
$Application.ActivePage.PageSheet

We add stencils of basic figures (BASIC_M.vss). First we will need a rectangle template.

# Step 2.
# Add Basic Visio Stensils
# Set Masters Item Rectangle
$Stensil1 = $Application.Documents.Add("BASIC_M.vss")
$Rectangle = $Stensil1.Masters.Item("Rectangle")

We draw a rectangle with color and the inscription “Microsoft Virtual Machine Manager Architecture”. We align the text along the upper edge of the rectangle and to the left. This figure will be the basis of our scheme. To aesthetically emphasize the inscription, draw a line of the appropriate color under it.

# Step 3.
# Draw Main Rectangle, Set Size, Set Colour
# Set Text, Size, Color, Align
# Draw Line, Set Weight, Color
$Shape1 = $Page.Drop($Rectangle, 6.375, 7.125)
$Shape1.Cells('Width').Formula = '12.2501'
$Shape1.Cells('Height').Formula = '7.25'
$Shape1.Cells('FillForegnd').Formula = '=RGB(0,153,204)'
$Shape1.Cells('LinePattern').Formula = 0
$Shape1.Text = "Microsoft Virtual Machine Manager Architecture"
$Shape1.Cells('VerticalAlign') = 0
$Shape1.Cells('Para.HorzAlign') = 0
$Shape1.Cells('Char.Size').Formula = '20 pt'
$Shape1.Cells('Char.Color').Formula = '=RGB(255,255,255)'
$Line1 = $Page.DrawLine(0.3125, 10.3438, 12.4948, 10.3438)
$Line1.Cells('LineWeight').Formula = '1 pt'
$Line1.Cells('LineColor').Formula = '=RGB(255,255,255)'

The intermediate result of the previous steps looks like this:

Figure 1. The result of the execution of the first three fragments of Powershell Code.

Similarly, draw a rectangle that will display the client system.

# Step 4.
# Draw Client Rectangle, Set Size, Set Colour
# Set Text, Align
# Draw Line
$Shape2 = $Page.Drop($Rectangle, 1.7656, 9.2344)
$Shape2.Cells('Width').Formula = '2.7813'
$Shape2.Cells('Height').Formula = '1.9688'
$Shape2.Cells('FillForegnd').Formula = '=RGB(209,235,241)'
$Shape2.Cells('LinePattern').Formula = 1
$Shape2.Text = "Client"
$Shape2.Cells('VerticalAlign') = 0
$Shape2.Cells('Char.Size').Formula = '14 pt'
$Line2 = $Page.DrawLine(0.4297, 9.9427, 3.0833, 9.9427)
$Line2.Cells('LineWeight').Formula = '0.5 pt'
$Line2.Cells('LineColor').Formula = '=RGB(0,0,0)'

There will be several objects within this rectangle. We add stencils of computer-themed figures (COMPS_M.vss), and we will work with the Personal Computer “PC” icon template.

# Step 5.
# Add Computer Items Visio Stensils
# Set Masters item PC
$Stensil2 = $Application.Documents.Add("COMPS_M.vss")
$PC1 = $Stensil2.Masters.Item("PC")

We attach an image of a Personal Computer with the Signature “Administrator Console”.

# Step 6.
# Draw item PC
# Set Text, Size
$Shape3 = $Page.Drop($PC1, 1.1173, 9.1693)
$Shape3.Text = "Administrator Console"
$Shape3.Cells('Char.Size').Formula = '10 pt'

Add a Powershell icon. In this case, we will use a picture prepared in advance in PNG format (PowerShell.png).

# Step 7.
# Draw Powershell Icon
# Set Position, Size
# Set Text
$Picture1 = $Page.Import("c:\!\powershell.png")
$Picture1.Cells('Width').Formula = '0.9843'
$Picture1.Cells('Height').Formula = '0.9843'
$Picture1.Cells('PinX').Formula = '2.5547'
$Picture1.Cells('PinY').Formula = '9.2682'
$Picture1.Text = "Windows Powershell"
$Picture1.Cells('Char.Size').Formula = '10 pt'

We draw a rectangle that will display the software interface of communication between client systems and server systems – Windows Communication Foundation.

# Step 8.
# Draw WCF Rectangle, Set Size, Set Colour
# Set Text, Align
# Draw Line
$Shape4 = $Page.Drop($Rectangle, 4.2682, 6.9063)
$Shape4.Cells('Width').Formula = '1.5'
$Shape4.Cells('Height').Formula = '6.625'
$Shape4.Cells('FillForegnd').Formula = '=RGB(255,255,255)'
$Shape4.Cells('LinePattern').Formula = 1
$Shape4.Text = "Windows Communication Foundation"
$Shape4.Cells('VerticalAlign') = 0
$Shape4.Cells('Char.Size').Formula = '14 pt'
$Line3 = $Page.DrawLine(3.5664, 9.4063, 4.9492, 9.4063)
$Line3.Cells('LineWeight').Formula = '0.5 pt'
$Line3.Cells('LineColor').Formula = '=RGB(0,0,0)'

Add a WCF icon.

# Step 9.
# Draw WCF Icon
# Set Position, Size
$Picture2 = $Page.Import("c:\!\WCF.png")
$Picture2.Cells('Width').Formula = '1.412'
$Picture2.Cells('Height').Formula = '1.0443'
$Picture2.Cells('PinX').Formula = '4.2708'
$Picture2.Cells('PinY').Formula = '6.9779'

We connect two objects with a line – the Client System with the Windows Communication Foundation software interface. This will reflect two-way communication.

# Step 10.
# Draw Line communication from Client to WCF
# Set Arrow
$Line4 = $Page.DrawLine(3.1563, 9.2396, 3.5174, 9.2396)
$Line4.Cells('LineColor').Formula = '=RGB(255,255,255)'
$Line4.Cells('BeginArrow').Formula=4
$Line4.Cells('EndArrow').Formula=4

Add a rectangle that will display the web client.

# Step 11.
# Draw Web Client Rectangle, Set Size, Set Colour
# Set Text, Align
# Draw Line
$Shape5 = $Page.Drop($Rectangle, 1.7656, 6.8776)
$Shape5.Cells('Width').Formula = '2.7813'
$Shape5.Cells('Height').Formula = '2.1094'
$Shape5.Cells('FillForegnd').Formula = '=RGB(209,235,241)'
$Shape5.Cells('LinePattern').Formula = 1
$Shape5.Text = "Web Client"
$Shape5.Cells('VerticalAlign') = 0
$Shape5.Cells('Char.Size').Formula = '14 pt'
$Line5 = $Page.DrawLine(0.4297, 7.6562, 3.0833, 7.6562)
$Line5.Cells('LineWeight').Formula = '0.5 pt'
$Line5.Cells('LineColor').Formula = '=RGB(0,0,0)'

Similarly to the previous steps, we add the Self-Service Web Portal icon (SelfServicePortal.png) and another Powershell icon.

# Step 12.
# Draw Self Service Portal Icon
# Set Position, Size
# Set Text
$Picture3 = $Page.Import("c:\!\SelfServicePortal.png")
$Picture3.Cells('Width').Formula = '0.8438'
$Picture3.Cells('Height').Formula = '0.8438'
$Picture3.Cells('PinX').Formula = '1.1094'
$Picture3.Cells('PinY').Formula = '6.9271'
$Picture3.Text = "Self Service Portal"
$Picture3.Cells('Char.Size').Formula = '10 pt'
# Step 13.
# Draw Powershell Icon
# Set Position, Size
# Set Text
$Picture4 = $Page.Import("c:\!\powershell.png")
$Picture4.Cells('Width').Formula = '0.9843'
$Picture4.Cells('Height').Formula = '0.9843'
$Picture4.Cells('PinX').Formula = '2.4922'
$Picture4.Cells('PinY').Formula = '6.9192'
$Picture4.Text = "Windows Powershell"
$Picture4.Cells('Char.Size').Formula = '10 pt'

Similarly, we again connect two objects with a line – the Web Client with the Windows Communication Foundation software interface. This will also reflect two-way communication.

# Step 14.
# Draw Line communication from Web Client to WCF
# Set Arrow
$Line6 = $Page.DrawLine(3.158, 6.8802, 3.5191, 6.8802)
$Line6.Cells('LineColor').Formula = '=RGB(255,255,255)'
$Line6.Cells('BeginArrow').Formula=4
$Line6.Cells('EndArrow').Formula=4

And the client picture is completed by a rectangle displaying client scripting with another Powershell icon. And, of course, we connect this object with the Windows Communication Foundation software interface by two-way communication.

# Step 15.
# Draw Scripting Client Rectangle, Set Size, Set Colour
# Set Text, Align
# Draw Line
$Shape6 = $Page.Drop($Rectangle, 1.7657, 4.5469)
$Shape6.Cells('Width').Formula = '2.7813'
$Shape6.Cells('Height').Formula = '1.9062'
$Shape6.Cells('FillForegnd').Formula = '=RGB(209,235,241)'
$Shape6.Cells('LinePattern').Formula = 1
$Shape6.Text = "Scripting Client"
$Shape6.Cells('VerticalAlign') = 0
$Shape6.Cells('Char.Size').Formula = '14 pt'
$Line7 = $Page.DrawLine(0.4297, 5.1979, 3.0834, 5.1979)
$Line7.Cells('LineWeight').Formula = '0.5 pt'
$Line7.Cells('LineColor').Formula = '=RGB(0,0,0)'
# Step 16.
# Draw Powershell Icon
# Set Position, Size
# Set Text
$Picture5 = $Page.Import("c:\!\powershell.png")
$Picture5.Cells('Width').Formula = '0.9843'
$Picture5.Cells('Height').Formula = '0.9843'
$Picture5.Cells('PinX').Formula = '1.7631'
$Picture5.Cells('PinY').Formula = '4.6015'
$Picture5.Text = "Windows Powershell"
$Picture5.Cells('Char.Size').Formula = '10 pt'
# Step 17.
# Draw Line communication from Scripting Client to WCF
# Set Arrow
$Line8 = $Page.DrawLine(3.158, 4.5729, 3.5191, 4.5729)
$Line8.Cells('LineColor').Formula = '=RGB(255,255,255)'
$Line8.Cells('BeginArrow').Formula=4
$Line8.Cells('EndArrow').Formula=4

The result of the previous steps looks like this:

Figure 2. Intermediate result of execution of previous fragments of Powershell Code.

Now let’s move on to the main services. To visualize the work of the server part, we will use the stencils of figures of the corresponding topic (SERVER_M.vss), and we will work with the icon templates of the Management Server “Management server” and the Database Server “Database server”. First, we draw a rectangle for visualization of Microsoft System Center Virtual Machine Manager Server 2007 and, accordingly, another one for Microsoft SQL Server 2005. We place the corresponding server icons on top of the rectangles on the upper left. And of course, we connect the “Microsoft System Center Virtual Machine Manager Server 2007” object with the Windows Communication Foundation software interface by two-way communication, and with Microsoft SQL Server 2005 by one-way communication.

# Step 18.
# Draw Microsoft System Center
# Virtual Machine Manager Server 2007 Rectangle
# Set Size, Set Colour
# Set Text, Align
$Shape7 = $Page.Drop($Rectangle, 6.3281, 8.2812)
$Shape7.Cells('Width').Formula = '1.5'
$Shape7.Cells('Height').Formula = '2.8125'
$Shape7.Cells('FillForegnd').Formula = '=RGB(255,192,0)'
$Shape7.Cells('LinePattern').Formula = 1
$Shape7.Text = "Microsoft System Center Virtual Machine Manager Server 2007"
$Shape7.Cells('Char.Size').Formula = '14 pt'
# Step 19.
# Draw Microsoft SQL Server 2005 Rectangle
# Set Size, Set Colour
# Set Text, Align
$Shape8 = $Page.Drop($Rectangle, 6.3281, 4.9219)
$Shape8.Cells('Width').Formula = '1.5'
$Shape8.Cells('Height').Formula = '2.6563'
$Shape8.Cells('FillForegnd').Formula = '=RGB(255,192,0)'
$Shape8.Cells('LinePattern').Formula = 1
$Shape8.Text = "Microsoft SQL Server 2005"
$Shape8.Cells('Char.Size').Formula = '14 pt'
# Step 20.
# Add Server Items Visio Stensils
# Set Masters item Management Server and Database Server
$Stensil3 = $Application.Documents.Add("SERVER_M.vss")
$MS1 = $Stensil3.Masters.Item("Management server")
$DBS1 = $Stensil3.Masters.Item("Database server")
# Step 21.
# Draw item Management Server
$Shape9 = $Page.Drop($MS1, 5.6043, 9.7421)
# Step 22.
# Draw item Management Server
$Shape10 = $Page.Drop($DBS1, 5.5832, 6.3046)
# Step 23.
# Draw Line communication from WCF to Microsoft System Center
# Virtual Machine Manager Server 2007
# Set Arrow
$Line9 = $Page.DrawLine(5.0052, 8.2604, 5.6024, 8.2604)
$Line9.Cells('LineColor').Formula = '=RGB(255,255,255)'
$Line9.Cells('BeginArrow').Formula=4
$Line9.Cells('EndArrow').Formula=4
# Step 24.
# Draw Line communication from Microsoft System Center
# Virtual Machine Manager Server 2007 to Microsoft SQL Server 2005
# Set Arrow
$Line10 = $Page.DrawLine(6.3272, 6.2344, 6.3272, 6.8802)
$Line10.Cells('LineColor').Formula = '=RGB(255,255,255)'
$Line10.Cells('BeginArrow').Formula=4
$Line10.Cells('EndArrow').Formula=0

The result of the previous steps looks like this:

Figure 3. Intermediate result of execution of previous fragments of Powershell Code.

Microsoft System Center Virtual Machine Manager Server 2007 interacts with agent systems using Windows Remote Managemet (Win-RM) technology. So, let’s draw this component of the architecture in the same way as we drew the display of the Windows Communication Foundation software interface. And let’s connect this component with the Microsoft System Center Virtual Machine Manager Server 2007 object by two-way communication.

# Step 25.
# Draw Win-RM Rectangle, Set Size, Set Colour
# Set Text, Align
# Draw Line
$Shape11 = $Page.Drop($Rectangle, 8.4375, 6.9219)
$Shape11.Cells('Width').Formula = '1.5'
$Shape11.Cells('Height').Formula = '6.6563'
$Shape11.Cells('FillForegnd').Formula = '=RGB(255,255,255)'
$Shape11.Cells('LinePattern').Formula = 1
$Shape11.Text = "Windows Remote Managemet (Win-RM)"
$Shape11.Cells('VerticalAlign') = 0
$Shape11.Cells('Char.Size').Formula = '14 pt'
$Line11 = $Page.DrawLine(7.75, 9.1875, 9.1328, 9.1875)
$Line11.Cells('LineWeight').Formula = '0.5 pt'
$Line11.Cells('LineColor').Formula = '=RGB(0,0,0)'
# Step 26.
# Draw Win-RM Icon
# Set Position, Size
$Picture6 = $Page.Import("c:\!\Win-RM.png")
$Picture6.Cells('Width').Formula = '1.1563'
$Picture6.Cells('Height').Formula = '1.1563'
$Picture6.Cells('PinX').Formula = '8.4293'
$Picture6.Cells('PinY').Formula = '7'
# Step 27.
# Draw Line communication from Win-RM to Microsoft System Center
# Virtual Machine Manager Server 2007
# Set Arrow
$Line12 = $Page.DrawLine(7.0781, 8.2812, 7.6753, 8.2812)
$Line12.Cells('LineColor').Formula = '=RGB(255,255,255)'
$Line12.Cells('BeginArrow').Formula=4
$Line12.Cells('EndArrow').Formula=4

Interaction with Virtualization Hosts, Library, etc. is based on VMM Agent. Let’s begin to display these components of the architecture by visualizing the interaction of the processes of migration of services from a physical environment to a virtual one: P2V Source. We will need a rectangle, a line, VMM Agent and Powershell icons. And, of course, display two-way communication with Windows Remote Managemet (Win-RM) technology.

# Step 28.
# Draw P2V Source Rectangle, Set Size, Set Colour
# Set Text, Align
# Draw Line
$Shape12 = $Page.Drop($Rectangle, 10.9844, 9.5)
$Shape12.Cells('Width').Formula = '2.7813'
$Shape12.Cells('Height').Formula = '1.5'
$Shape12.Cells('FillForegnd').Formula = '=RGB(209,235,241)'
$Shape12.Cells('LinePattern').Formula = 1
$Shape12.Text = "P2V Source"
$Shape12.Cells('VerticalAlign') = 0
$Shape12.Cells('Char.Size').Formula = '14 pt'
$Line13 = $Page.DrawLine(9.6485, 9.9739, 12.3021, 9.9739)
$Line13.Cells('LineWeight').Formula = '0.5 pt'
$Line13.Cells('LineColor').Formula = '=RGB(0,0,0)'
# Step 29.
# Draw VMM Agent Icon
# Set Position, Size
# Set Text
$Picture7 = $Page.Import("c:\!\VMMAgent.png")
$Picture7.Cells('Width').Formula = '0.8438'
$Picture7.Cells('Height').Formula = '0.8438'
$Picture7.Cells('PinX').Formula = '10.2969'
$Picture7.Cells('PinY').Formula = '9.5'
$Picture7.Text = "VMM Agent"
$Picture7.Cells('Char.Size').Formula = '10 pt'
# Step 30.
# Draw Powershell Icon
# Set Position, Size
# Set Text
$Picture8 = $Page.Import("c:\!\powershell.png")
$Picture8.Cells('Width').Formula = '0.7968'
$Picture8.Cells('Height').Formula = '0.7968'
$Picture8.Cells('PinX').Formula = '11.6016'
$Picture8.Cells('PinY').Formula = '9.6016'
$Picture8.Text = "Windows Powershell"
$Picture8.Cells('Char.Size').Formula = '10 pt'
# Step 31.
# Draw Line communication from P2V Source to Win-RM
# Set Arrow
$Line14 = $Page.DrawLine(9.1875, 9.487, 9.599, 9.487)
$Line14.Cells('LineColor').Formula = '=RGB(255,255,255)'
$Line14.Cells('BeginArrow').Formula=4
$Line14.Cells('EndArrow').Formula=4

Similarly, we display Virtualization hosts – Microsoft Virtual Server 2005 R2.

# Step 32.
# Draw Host Rectangle, Set Size, Set Colour
# Set Text, Align
# Draw Line
$Shape13 = $Page.Drop($Rectangle, 10.9792, 6.9427)
$Shape13.Cells('Width').Formula = '2.7813'
$Shape13.Cells('Height').Formula = '1.5'
$Shape13.Cells('FillForegnd').Formula = '=RGB(209,235,241)'
$Shape13.Cells('LinePattern').Formula = 1
$Shape13.Text = "Host"
$Shape13.Cells('VerticalAlign') = 0
$Shape13.Cells('Char.Size').Formula = '14 pt'
$Line15 = $Page.DrawLine(9.6472, 7.4219, 12.3008, 7.4219)
$Line15.Cells('LineWeight').Formula = '0.5 pt'
$Line15.Cells('LineColor').Formula = '=RGB(0,0,0)'
# Step 33.
# Draw VMM Agent Icon
# Set Position, Size
# Set Text
$Picture9 = $Page.Import("c:\!\VMMAgent.png")
$Picture9.Cells('Width').Formula = '0.8438'
$Picture9.Cells('Height').Formula = '0.8438'
$Picture9.Cells('PinX').Formula = '10.2917'
$Picture9.Cells('PinY').Formula = '6.9427'
$Picture9.Text = "VMM Agent"
$Picture9.Cells('Char.Size').Formula = '10 pt'
# Step 34.
# Draw Microsoft Virtual Server 2005 R2 Icon
# Set Position, Size
# Set Text
$Picture10 = $Page.Import("c:\!\WS.jpg")
$Picture10.Cells('Width').Formula = '0.8125'
$Picture10.Cells('Height').Formula = '0.7404'
$Picture10.Cells('PinX').Formula = '11.5938'
$Picture10.Cells('PinY').Formula = '6.9423'
$Picture10.Text = "Microsoft Virtual Server 2005 R2"
$Picture10.Cells('Char.Size').Formula = '7 pt'
# Step 35.
# Draw Line communication from Host to Win-RM
# Set Arrow
$Line16 = $Page.DrawLine(9.1849, 6.941, 9.5964, 6.941)
$Line16.Cells('LineColor').Formula = '=RGB(255,255,255)'
$Line16.Cells('BeginArrow').Formula=4
$Line16.Cells('EndArrow').Formula=4

And similar to the previous steps, we display the elements of the Library.

# Step 36.
# Draw Library Rectangle, Set Size, Set Colour
# Set Text, Align
# Draw Line
$Shape14 = $Page.Drop($Rectangle, 10.9792, 4.3542)
$Shape14.Cells('Width').Formula = '2.7813'
$Shape14.Cells('Height').Formula = '1.5'
$Shape14.Cells('FillForegnd').Formula = '=RGB(209,235,241)'
$Shape14.Cells('LinePattern').Formula = 1
$Shape14.Text = "Library"
$Shape14.Cells('VerticalAlign') = 0
$Shape14.Cells('Char.Size').Formula = '14 pt'
$Line17 = $Page.DrawLine(9.6419, 4.8073, 12.2955, 4.8073)
$Line17.Cells('LineWeight').Formula = '0.5 pt'
$Line17.Cells('LineColor').Formula = '=RGB(0,0,0)'
# Step 37.
# Draw VMM Agent Icon
# Set Position, Size
# Set Text
$Picture11 = $Page.Import("c:\!\VMMAgent.png")
$Picture11.Cells('Width').Formula = '0.8438'
$Picture11.Cells('Height').Formula = '0.8438'
$Picture11.Cells('PinX').Formula = '10.2917'
$Picture11.Cells('PinY').Formula = '4.3542'
$Picture11.Text = "VMM Agent"
$Picture11.Cells('Char.Size').Formula = '10 pt'
# Step 38.
# Draw Windows Server 2003 R2 Icon
# Set Position, Size
# Set Text
$Picture12 = $Page.Import("c:\!\WS.jpg")
$Picture12.Cells('Width').Formula = '0.8125'
$Picture12.Cells('Height').Formula = '0.7404'
$Picture12.Cells('PinX').Formula = '11.5625'
$Picture12.Cells('PinY').Formula = '4.3702'
$Picture12.Text = "Windows Server 2003 R2"
$Picture12.Cells('Char.Size').Formula = '7 pt'
# Step 39.
# Draw Line communication from Library to Win-RM
# Set Arrow
$Line18 = $Page.DrawLine(9.1901, 4.3611, 9.6016, 4.3611)
$Line18.Cells('LineColor').Formula = '=RGB(255,255,255)'
$Line18.Cells('BeginArrow').Formula=4
$Line18.Cells('EndArrow').Formula=4

The result of the previous steps looks like this:

Figure 4. Intermediate result of execution of previous fragments of Powershell Code.

Interaction between Virtualization Hosts, the Library and processes of migration of services from a physical environment to a virtual one: P2V Source is carried out using Background Intelligent Transfer Service (BITS) technology. We will display this two-way interaction between the final elements of the architecture.

# Step 40.
# Draw BITS Rectangle, Set Size, Set Colour
# Set Text, Align
# Draw Line
$Shape15 = $Page.Drop($Rectangle, 10.9844, 8.2292)
$Shape15.Cells('Width').Formula = '2.75'
$Shape15.Cells('Height').Formula = '0.5625'
$Shape15.Cells('FillForegnd').Formula = '=RGB(255,255,0)'
$Shape15.Cells('LinePattern').Formula = 1
$Shape15.Text = "BITS"
$Shape15.Cells('Para.HorzAlign') = 0
$Shape15.Cells('Char.Size').Formula = '14 pt'
# Step 41.
# Draw BITS Icon
# Set Position, Size
# Set Text
$Picture13 = $Page.Import("c:\!\BITS.jpg")
$Picture13.Cells('Width').Formula = '0.5417'
$Picture13.Cells('Height').Formula = '0.5417'
$Picture13.Cells('PinX').Formula = '10.974'
$Picture13.Cells('PinY').Formula = '8.2344'
# Step 42.
# Draw Line communication from BITS to P2V Source
# Set Arrow
$Line19 = $Page.DrawLine(10.9844, 8.5104, 10.9844, 8.75)
$Line19.Cells('LineColor').Formula = '=RGB(255,255,255)'
$Line19.Cells('BeginArrow').Formula=4
$Line19.Cells('EndArrow').Formula=4
# Step 43.
# Draw Line communication from BITS to Host
# Set Arrow
$Line20 = $Page.DrawLine(10.9844, 7.6849, 10.9844, 7.9219)
$Line20.Cells('LineColor').Formula = '=RGB(255,255,255)'
$Line20.Cells('BeginArrow').Formula=4
$Line20.Cells('EndArrow').Formula=4
# Step 44.
# Draw BITS Rectangle, Set Size, Set Colour
# Set Text, Align
# Draw Line
$Shape16 = $Page.Drop($Rectangle, 10.9844, 5.6555)
$Shape16.Cells('Width').Formula = '2.75'
$Shape16.Cells('Height').Formula = '0.5625'
$Shape16.Cells('FillForegnd').Formula = '=RGB(255,255,0)'
$Shape16.Cells('LinePattern').Formula = 1
$Shape16.Text = "BITS"
$Shape16.Cells('Para.HorzAlign') = 0
$Shape16.Cells('Char.Size').Formula = '14 pt'
# Step 45.
# Draw BITS Icon
# Set Position, Size
# Set Text
$Picture14 = $Page.Import("c:\!\BITS.jpg")
$Picture14.Cells('Width').Formula = '0.5417'
$Picture14.Cells('Height').Formula = '0.5417'
$Picture14.Cells('PinX').Formula = '10.974'
$Picture14.Cells('PinY').Formula = '5.6607'
# Step 46.
# Draw Line communication from BITS to Host 
# Set Arrow
$Line21 = $Page.DrawLine(10.9844, 5.9245, 10.9844, 6.1901)
$Line21.Cells('LineColor').Formula = '=RGB(255,255,255)'
$Line21.Cells('BeginArrow').Formula=4
$Line21.Cells('EndArrow').Formula=4
# Step 47.
# Draw Line communication from BITS to Library
# Set Arrow
$Line22 = $Page.DrawLine(10.9792, 5.1042, 10.9792, 5.375)
$Line22.Cells('LineColor').Formula = '=RGB(255,255,255)'
$Line22.Cells('BeginArrow').Formula=4
$Line22.Cells('EndArrow').Formula=4

And finally, we will resize the page according to the dimensions of our diagram, save it as a file on disk and close the Visio application.

# Step 48.
# Resise Page To Fit Contents
$Page.ResizeToFitContents()
# Step 49.
# Save Document
# And Quit Application
$Document.SaveAs(“C:\!\MsSCVMM2007Arch.vsd”)
$Application.Quit()

The final result of the scheme is shown in the figure.

Figure 5. Final result of Powershell Code execution.

The current version of the above code is in the Git repository at this link: VisioPowershellv01.ps1.

Brief Summary and Next Steps


Therefore, the final result fully meets our expectations. Microsoft System Center Virtual Machine Manager 2007 architecture diagram was created using Powershell Code.

However, this approach has significant drawbacks.

The total size of this code is more than 500 lines. Therefore, the topic of the next publication is the optimization of this code using Powershell functions.

But that will be discussed in the next publication.

See you in a few days.
Sincerely, AIRRA!

Posted in Architecture, Code, Design, Microsoft, Programming | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , , | Leave a comment

Architecture and Design. Code and Programming. Part1. Introduction. The life cycle of an IT solution. Architecture and Design. Code and Programming. Microsoft Visio and PowerShell. Code development environment and tools. Brief Summary.

 

Introduction


Hello to all readers of the blog about IT Architecture and Education.

The topic of today’s publication will be quite unusual. It will be about “Architecture and Design. Implementation and Operation. Code and Programming”. A strange combination, you note. But don’t make hasty conclusions, get comfortable, because there will be a lot to talk about here! A fairly significant volume of material awaits us.

And we will start by understanding the life cycle of any IT solution.

The life cycle of an IT solution


Any IT solution usually goes through several stages during its existence: Designing – Architecture and Design; Implementation – Deployment of components, Initial settings, Integration with third-party systems; and Operation – Regulations for Monitoring, Backup, etc.

At each of the stages, specialized specialists operate with various input data, documents, schemes. Various document templates from the vendor are often used to standardize this process, but each of them has its own style and approach in this matter. And a completely monovendor IT solution is a very rare case.

Therefore, I would really like to unify the stages of the life cycle of an IT solution using Code. Based on the Code, form the necessary elements of the architecture and design scheme. Next, based on the Code and the parameters obtained at the previous stage, perform the initial deployment of the system, apply the initial settings, integrate with third-party systems. And in the final version, provide Code examples for typical operational tasks.

Well, it is necessary to start this difficult work from the stage of architecture and design.

Architecture and Design. Code and Programming


I recently published the beginning of a series of articles on the technologies of Microsoft System Center Virtual Machine Manager 2007. The next topic of the publication was to talk about the architecture of this product. And here it is worth taking a short break in that series of articles to apply our new conceptual approach.

Various diagrams are usually used to visualize the architectural principle of system operation. In this context, a toolkit in the form of Microsoft Office Visio has become widely used. Microsoft Windows Powershell is gaining popularity for automation tasks. And here a logical idea arises, and if you combine these two technologies, using Powershell code, first create an architectural diagram of the IT solution in Visio format. Why not. Let’s try.

The final version of the system architecture diagram of Microsoft System Center Virtual Machine Manager 2007 looks like this:

Figure 1: The result of visualization of the Microsoft System Center Virtual Machine Manager 2007 architecture using Powershell code and Microsoft Visio.

In this series of articles, we will try to use Powershell code to create a scheme as similar as possible.

Microsoft Visio and PowerShell. Code development environment and tools


To work on code scripts, we will need an Operating System with the following software installed: Microsoft Visio, Powershell, and any code editor.

In my case I used:

  • Operating system: Microsoft Windows Vista Business, x64;
  • A program for automating tasks and managing configurations for Windows: Microsoft Windows PowerShell 1.0 x64;
  • Code editor: Notepad++ 32-bit x86 v.4.2;
  • Diagram editor for Windows: Microsoft Office Visio 2007 Professional x86.

Adhering to the “Anything as Code” strategy, I also used automation and “silent” installation technologies when deploying the development environment and writing the code.

Operating system

The following components and technologies were used for the automatic deployment of the Microsoft Windows Vista Business, x64 Operating System:

  • Image file: en_windows_vista_x64_dvd_x12-40712.iso, which was recorded on a DVD medium;
  • The script file for automatic installation and configuration of the basic image of the Microsoft Windows Vista Business Operating System, x64 – Autounattend.xml, written on a removable USB medium.

The content of the script file for automatic installation and configuration of the basic image of the Microsoft Windows Vista Business Operating System, x64 – Autounattend.xml is given below:

<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
	<settings pass="windowsPE">
		<component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
			<SetupUILanguage>
				<UILanguage>en-US</UILanguage>
			</SetupUILanguage>
			<InputLocale>1033:00000409</InputLocale>
			<SystemLocale>en-US</SystemLocale>
			<UILanguage>en-US</UILanguage>
			<UILanguageFallback>en-US</UILanguageFallback>
			<UserLocale>en-US</UserLocale>
		</component>
		<component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
			<SetupUILanguage>
				<UILanguage>en-US</UILanguage>
			</SetupUILanguage>
			<InputLocale>1033:00000409</InputLocale>
			<SystemLocale>en-US</SystemLocale>
			<UILanguage>en-US</UILanguage>
			<UILanguageFallback>en-US</UILanguageFallback>
			<UserLocale>en-US</UserLocale>
		</component>
		<component name="Microsoft-Windows-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
			<DiskConfiguration>
				<Disk wcm:action="add">
					<DiskID>0</DiskID>
					<CreatePartitions>
						<CreatePartition wcm:action="add">
							<Order>1</Order>
							<Size>100</Size>
							<Type>Primary</Type>
						</CreatePartition>
						<CreatePartition wcm:action="add">
							<Order>2</Order>
							<Extend>true</Extend>
							<Type>Primary</Type>
						</CreatePartition>
					</CreatePartitions>
					<WillWipeDisk>true</WillWipeDisk>
					<ModifyPartitions>
						<ModifyPartition wcm:action="add">
							<Active>true</Active>
							<Format>NTFS</Format>
							<Order>1</Order>
							<PartitionID>1</PartitionID>
							<Label>System Reserved</Label>
						</ModifyPartition>
						<ModifyPartition wcm:action="add">
							<Active>true</Active>
							<Format>NTFS</Format>
							<Label>OS</Label>
							<Letter>C</Letter>
							<Order>2</Order>
							<PartitionID>2</PartitionID>
						</ModifyPartition>
					</ModifyPartitions>
				</Disk>
				<WillShowUI>OnError</WillShowUI>
			</DiskConfiguration>
			<UserData>
				<AcceptEula>true</AcceptEula>
				<FullName></FullName>
				<Organization></Organization>
				<ProductKey>
					<Key>12345-ABCDE-67890-FGHIJ-KLMNO</Key>
				</ProductKey>
			</UserData>
			<ImageInstall>
				<OSImage>
					<InstallFrom>
						<MetaData wcm:action="add">
							<Key>/IMAGE/NAME</Key>
							<Value>Windows Vista BUSINESS</Value>
						</MetaData>
					</InstallFrom>
					<InstallTo>
						<DiskID>0</DiskID>
						<PartitionID>2</PartitionID>
					</InstallTo>
					<WillShowUI>OnError</WillShowUI>
					<InstallToAvailablePartition>false</InstallToAvailablePartition>
				</OSImage>
			</ImageInstall>
		</component>
		<component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
			<DiskConfiguration>
				<Disk wcm:action="add">
					<DiskID>0</DiskID>
					<CreatePartitions>
						<CreatePartition wcm:action="add">
							<Order>1</Order>
							<Size>100</Size>
							<Type>Primary</Type>
						</CreatePartition>
						<CreatePartition wcm:action="add">
							<Order>2</Order>
							<Extend>true</Extend>
							<Type>Primary</Type>
						</CreatePartition>
					</CreatePartitions>
					<WillWipeDisk>true</WillWipeDisk>
					<ModifyPartitions>
						<ModifyPartition wcm:action="add">
							<Active>true</Active>
							<Format>NTFS</Format>
							<Order>1</Order>
							<PartitionID>1</PartitionID>
							<Label>System Reserved</Label>
						</ModifyPartition>
						<ModifyPartition wcm:action="add">
							<Active>true</Active>
							<Format>NTFS</Format>
							<Label>OS</Label>
							<Letter>C</Letter>
							<Order>2</Order>
							<PartitionID>2</PartitionID>
						</ModifyPartition>
					</ModifyPartitions>
				</Disk>
				<WillShowUI>OnError</WillShowUI>
			</DiskConfiguration>
			<UserData>
				<AcceptEula>true</AcceptEula>
				<FullName></FullName>
				<Organization></Organization>
				<ProductKey>
					<Key>12345-ABCDE-67890-FGHIJ-KLMNO</Key>
				</ProductKey>
			</UserData>
			<ImageInstall>
				<OSImage>
					<InstallFrom>
						<MetaData wcm:action="add">
							<Key>/IMAGE/NAME</Key>
							<Value>Windows Vista BUSINESS</Value>
						</MetaData>
					</InstallFrom>
					<InstallTo>
						<DiskID>0</DiskID>
						<PartitionID>2</PartitionID>
					</InstallTo>
					<WillShowUI>OnError</WillShowUI>
					<InstallToAvailablePartition>false</InstallToAvailablePartition>
				</OSImage>
			</ImageInstall>
		</component>
	</settings>
	<settings pass="generalize">
		<component name="Microsoft-Windows-Security-Licensing-SLC" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
			<SkipRearm>1</SkipRearm>
		</component>
		<component name="Microsoft-Windows-Security-Licensing-SLC" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
			<SkipRearm>1</SkipRearm>
		</component>
	</settings>
	<settings pass="specialize">
		<component name="Microsoft-Windows-Security-Licensing-SLC-UX" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
			<SkipAutoActivation>true</SkipAutoActivation>
		</component>
		<component name="Microsoft-Windows-Security-Licensing-SLC-UX" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
			<SkipAutoActivation>true</SkipAutoActivation>
		</component>
		<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
			<ComputerName>ArchDev-PC</ComputerName>
			<ProductKey>12345-ABCDE-67890-FGHIJ-KLMNO</ProductKey>
			<TimeZone>FLE Standard Time</TimeZone>
		</component>
		<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
			<ComputerName>ArchDev-PC</ComputerName>
			<ProductKey>12345-ABCDE-67890-FGHIJ-KLMNO</ProductKey>
			<TimeZone>FLE Standard Time</TimeZone>
		</component>
	</settings>
	<settings pass="oobeSystem">
		<component name="Microsoft-Windows-International-Core" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
			<InputLocale>1033:00000409</InputLocale>
			<UILanguage>en-US</UILanguage>
			<UserLocale>en-US</UserLocale>
		</component>
		<component name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
			<InputLocale>1033:00000409</InputLocale>
			<UILanguage>en-US</UILanguage>
			<UserLocale>en-US</UserLocale>
		</component>
		<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
			<RegisteredOwner></RegisteredOwner>
			<OOBE>
				<HideEULAPage>true</HideEULAPage>
				<NetworkLocation>Other</NetworkLocation>
				<ProtectYourPC>1</ProtectYourPC>
				<SkipMachineOOBE>false</SkipMachineOOBE>
				<SkipUserOOBE>false</SkipUserOOBE>
			</OOBE>
			<UserAccounts>
				<LocalAccounts>
					<LocalAccount wcm:action="add">
						<Password>
							<Value>Pa$$w0rd</Value>
							<PlainText>true</PlainText>
						</Password>
						<Description>ArchDev</Description>
						<DisplayName>ArchDev</DisplayName>
						<Group>Administrators</Group>
						<Name>ArchDev</Name>
					</LocalAccount>
				</LocalAccounts>
			</UserAccounts>
			<AutoLogon>
				<Password>
					<Value>Pa$$w0rd</Value>
					<PlainText>true</PlainText>
				</Password>
				<Enabled>true</Enabled>
				<Username>ArchDev</Username>
			</AutoLogon>
			<DisableAutoDaylightTimeSet>false</DisableAutoDaylightTimeSet>
			<FirstLogonCommands>
				<SynchronousCommand wcm:action="add">
					<Order>1</Order>
					<Description>Disable Auto Updates</Description>
					<CommandLine>reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" /v AUOptions /t REG_DWORD /d 1 /f</CommandLine>
				</SynchronousCommand>
				<SynchronousCommand wcm:action="add">
					<Order>2</Order>
					<Description>Hide Set Network Location</Description>
					<CommandLine>reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\NewNetworks" /v NetworkList /t REG_MULTI_SZ /d "" /f</CommandLine>
				</SynchronousCommand>
				<SynchronousCommand wcm:action="add">
					<Order>3</Order>
					<Description>Hide Set Welcome Center Window</Description>
					<CommandLine>reg delete "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v WindowsWelcomeCenter /f</CommandLine>
				</SynchronousCommand>
			</FirstLogonCommands>
		</component>
		<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
			<RegisteredOwner></RegisteredOwner>
			<OOBE>
				<HideEULAPage>true</HideEULAPage>
				<NetworkLocation>Other</NetworkLocation>
				<ProtectYourPC>1</ProtectYourPC>
				<SkipMachineOOBE>false</SkipMachineOOBE>
				<SkipUserOOBE>false</SkipUserOOBE>
			</OOBE>
			<UserAccounts>
				<LocalAccounts>
					<LocalAccount wcm:action="add">
						<Password>
							<Value>Pa$$w0rd</Value>
							<PlainText>true</PlainText>
						</Password>
						<Description>ArchDev</Description>
						<DisplayName>ArchDev</DisplayName>
						<Group>Administrators</Group>
						<Name>ArchDev</Name>
					</LocalAccount>
				</LocalAccounts>
			</UserAccounts>
			<AutoLogon>
				<Password>
					<Value>Pa$$w0rd</Value>
					<PlainText>true</PlainText>
				</Password>
				<Enabled>true</Enabled>
				<Username>ArchDev</Username>
			</AutoLogon>
			<DisableAutoDaylightTimeSet>false</DisableAutoDaylightTimeSet>
			<FirstLogonCommands>
				<SynchronousCommand wcm:action="add">
					<Order>1</Order>
					<Description>Disable Auto Updates</Description>
					<CommandLine>reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" /v AUOptions /t REG_DWORD /d 1 /f</CommandLine>
				</SynchronousCommand>
				<SynchronousCommand wcm:action="add">
					<Order>2</Order>
					<Description>Hide Set Network Location Window</Description>
					<CommandLine>reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\NewNetworks" /v NetworkList /t REG_MULTI_SZ /d "" /f</CommandLine>
				</SynchronousCommand>
				<SynchronousCommand wcm:action="add">
					<Order>3</Order>
					<Description>Hide Set Welcome Center Window</Description>
					<CommandLine>reg delete "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v WindowsWelcomeCenter /f</CommandLine>
				</SynchronousCommand>
			</FirstLogonCommands>
		</component>
	</settings>
</unattend>

The current version of the above code is in the Git repository at this link: Autounattend.xml.

Microsoft Windows PowerShell

“Silent” deployment of the task automation and configuration management tool for Windows: Microsoft Windows PowerShell 1.0 x64 (Windows6.0-KB928439-x64.msu) is done with the following Command Prompt console command:

wusa.exe Windows6.0-KB928439-x64.msu /quiet

Note: The provided code must be executed with administrator privileges!

Since Microsoft Windows PowerShell 1.0 is already available in our code development environment, we will use this technology for all further steps.

Notepad++ 

Automatic “silent” deployment of the editor for writing code – the Notepad++ 32-bit x86 v.4.2 will be carried out with the following simple PowerShell code:

# Silent Install Notepad++ 4.2 
$Command = ".\4.2_npp.4.2.Installer.exe" 
$Parms = "/S" 
& $Command $Parms 

Note: The provided code must be executed with administrator privileges!

Going forward, we’ll be working with large amounts of PowerShell code in the form of .ps1 script files all the time. By default, PowerShell prevents such artifacts from running. Therefore, to successfully execute such PowerShell code, the following command should be executed:

Set-ExecutionPolicy -ExecutionPolicy Unrestricted 

Notepad++ is a great tool for writing and editing PowerShell code, but the basic installation does not support the syntax of PowerShell command structures: highlighting, formatting, etc.

To eliminate this problem, you should use the possibility of creating and configuring Language rules described by the user (User Defined Languages). To do this, create a file called userDefineLang.xml in the directory “%APPDATA%\Notepad++\” with the required content.

<?xml version="1.0"?>
<NotepadPlus>
  <UserLang name="PowerShell" ext="ps1">
    <Settings>
      <Global caseIgnored="yes" />
      <TreatAsSymbol comment="no" commentLine="yes" />
      <PrefixNode words1="yes" words2="no" words3="no" words4="no" />
    </Settings>
    <KeywordLists>
      <Keywords name="Delimiters">"00"00</Keywords>
      <Keywords name="Folder+">{</Keywords>
      <Keywords name="Folder-">}</Keywords>
      <Keywords name="Operators">! " % & ( ) * , / : ; ? @ [ \ ] ^ ` | ~ + < = ></Keywords>
      <Keywords name="Comment">1 2 0#</Keywords>
      <Keywords name="Words1">Add-Content Add-History Add-Member Add-PSSnapin Clear-Content Clear-Item Clear-ItemProperty Clear-Variable Compare-Object ConvertFrom-SecureString Convert-Path ConvertTo-Html ConvertTo-SecureString Copy-Item Copy-ItemProperty Export-Alias Export-Clixml Export-Console Export-Csv ForEach-Object Format-Custom Format-List Format-Table Format-Wide Get-Acl Get-Alias Get-AuthenticodeSignature Get-ChildItem Get-Command Get-Content Get-Credential Get-Culture Get-Date Get-EventLog Get-ExecutionPolicy Get-Help Get-History Get-Host Get-Item Get-ItemProperty Get-Location Get-Member Get-PfxCertificate Get-Process Get-PSDrive Get-PSProvider Get-PSSnapin Get-Service Get-TraceSource Get-UICulture Get-Unique Get-Variable Get-WmiObject Group-Object Import-Alias Import-Clixml Import-Csv Invoke-Expression Invoke-History Invoke-Item Join-Path Measure-Command Measure-Object Move-Item Move-ItemProperty New-Alias New-Item New-ItemProperty New-Object New-PSDrive New-Service New-TimeSpan New-Variable Out-Default Out-File Out-Host Out-Null Out-Printer Out-String Pop-Location Push-Location Read-Host Remove-Item Remove-ItemProperty Remove-PSDrive Remove-PSSnapin Remove-Variable Rename-Item Rename-ItemProperty Resolve-Path Restart-Service Resume-Service Select-Object Select-String Set-Acl Set-Alias Set-AuthenticodeSignature Set-Content Set-Date Set-ExecutionPolicy Set-Item Set-ItemProperty Set-Location Set-PSDebug Set-Service Set-TraceSource Set-Variable Sort-Object Split-Path Start-Service Start-Sleep Start-Transcript Stop-Process Stop-Service Stop-Transcript Suspend-Service Tee-Object Test-Path Trace-Command Update-FormatData Update-TypeData Where-Object Write-Debug Write-Error Write-Host Write-Output Write-Progress Write-Verbose Write-Warning switch function if throw else while break - $ System. Management.</Keywords>
      <Keywords name="Words2">ac asnp clc cli clp clv cpi cpp cvpa diff epal epcsv fc fl foreach % ft fw gal gc gci gcm gdr ghy gi gl gm gp gps group gsv gsnp gu gv gwmi iex ihy ii ipal ipcsv mi mp nal ndr ni nv oh rdr ri rni rnp rp rsnp rv rvpa sal sasv sc select si sl sleep sort sp spps spsv sv tee where ? write cat cd clear cp h history kill lp ls mount mv popd ps pushd pwd r rm rmdir echo cls chdir copy del dir erase move rd ren set type</Keywords>
      <Keywords name="Words3">CIM_DataFile CIM_DirectoryContainsFile CIM_ProcessExecutable CIM_VideoControllerResolution Msft_Providers Msft_WmiProvider_Counters NetDiagnostics Win32_1394Controller Win32_1394ControllerDevice Win32_AccountSID Win32_ActionCheck Win32_ActiveRoute Win32_AllocatedResource Win32_ApplicationCommandLine Win32_ApplicationService Win32_AssociatedBattery Win32_AssociatedProcessorMemory Win32_AutochkSetting Win32_BaseBoard Win32_Battery Win32_Binary Win32_BindImageAction Win32_BIOS Win32_BootConfiguration Win32_Bus Win32_CacheMemory Win32_CDROMDrive Win32_CheckCheck Win32_CIMLogicalDeviceCIMDataFile Win32_ClassicCOMApplicationClasses Win32_ClassicCOMClass Win32_ClassicCOMClassSetting Win32_ClassicCOMClassSettings Win32_ClassInfoAction Win32_ClientApplicationSetting Win32_CodecFile Win32_COMApplicationSettings Win32_ComClassAutoEmulator Win32_ComClassEmulator Win32_CommandLineAccess Win32_ComponentCategory Win32_ComputerSystem Win32_ComputerSystemProcessor Win32_ComputerSystemProduct Win32_ComputerSystemWindowsProductActivationSetting Win32_Condition Win32_ConnectionShare Win32_ControllerHasHub Win32_CreateFolderAction Win32_CurrentProbe Win32_DCOMApplication Win32_DCOMApplicationAccessAllowedSetting Win32_DCOMApplicationLaunchAllowedSetting Win32_DCOMApplicationSetting Win32_DependentService Win32_Desktop Win32_DesktopMonitor Win32_DeviceBus Win32_DeviceMemoryAddress Win32_DfsNode Win32_DfsNodeTarget Win32_DfsTarget Win32_Directory Win32_DirectorySpecification Win32_DiskDrive Win32_DiskDrivePhysicalMedia Win32_DiskDriveToDiskPartition Win32_DiskPartition Win32_DiskQuota Win32_DisplayConfiguration Win32_DisplayControllerConfiguration Win32_DMAChannel Win32_DriverForDevice Win32_DriverVXD Win32_DuplicateFileAction Win32_Environment Win32_EnvironmentSpecification Win32_ExtensionInfoAction Win32_Fan Win32_FileSpecification Win32_FloppyController Win32_FloppyDrive Win32_FontInfoAction Win32_Group Win32_GroupInDomain Win32_GroupUser Win32_HeatPipe Win32_IDEController Win32_IDEControllerDevice Win32_ImplementedCategory Win32_InfraredDevice Win32_IniFileSpecification Win32_InstalledSoftwareElement Win32_IP4PersistedRouteTable Win32_IP4RouteTable Win32_IRQResource Win32_Keyboard Win32_LaunchCondition Win32_LoadOrderGroup Win32_LoadOrderGroupServiceDependencies Win32_LoadOrderGroupServiceMembers Win32_LocalTime Win32_LoggedOnUser Win32_LogicalDisk Win32_LogicalDiskRootDirectory Win32_LogicalDiskToPartition Win32_LogicalFileAccess Win32_LogicalFileAuditing Win32_LogicalFileGroup Win32_LogicalFileOwner Win32_LogicalFileSecuritySetting Win32_LogicalMemoryConfiguration Win32_LogicalProgramGroup Win32_LogicalProgramGroupDirectory Win32_LogicalProgramGroupItem Win32_LogicalProgramGroupItemDataFile Win32_LogicalShareAccess Win32_LogicalShareAuditing Win32_LogicalShareSecuritySetting Win32_LogonSession Win32_LogonSessionMappedDisk Win32_MappedLogicalDisk Win32_MemoryArray Win32_MemoryArrayLocation Win32_MemoryDevice Win32_MemoryDeviceArray Win32_MemoryDeviceLocation Win32_MIMEInfoAction Win32_MotherboardDevice Win32_MountPoint Win32_MoveFileAction Win32_NamedJobObject Win32_NamedJobObjectActgInfo Win32_NamedJobObjectLimit Win32_NamedJobObjectLimitSetting Win32_NamedJobObjectProcess Win32_NamedJobObjectSecLimit Win32_NamedJobObjectSecLimitSetting Win32_NamedJobObjectStatistics Win32_NetworkAdapter Win32_NetworkAdapterConfiguration Win32_NetworkAdapterSetting Win32_NetworkClient Win32_NetworkConnection Win32_NetworkLoginProfile Win32_NetworkProtocol Win32_NTDomain Win32_NTEventlogFile Win32_NTLogEvent Win32_NTLogEventComputer Win32_NTLogEventLog Win32_NTLogEventUser Win32_ODBCAttribute Win32_ODBCDataSourceAttribute Win32_ODBCDataSourceSpecification Win32_ODBCDriverAttribute Win32_ODBCDriverSoftwareElement Win32_ODBCDriverSpecification Win32_ODBCSourceAttribute Win32_ODBCTranslatorSpecification Win32_OnBoardDevice Win32_OperatingSystem Win32_OperatingSystemAutochkSetting Win32_OperatingSystemQFE Win32_OSRecoveryConfiguration Win32_PageFile Win32_PageFileElementSetting Win32_PageFileSetting Win32_PageFileUsage Win32_ParallelPort Win32_Patch Win32_PatchFile Win32_PatchPackage Win32_PCMCIAController Win32_PerfFormattedData_ContentFilter_IndexingServiceFilter Win32_PerfFormattedData_ContentIndex_IndexingService Win32_PerfFormattedData_Fax_FaxServices Win32_PerfFormattedData_IPSec_IPSecv4Driver Win32_PerfFormattedData_IPSec_IPSecv4IKE Win32_PerfFormattedData_ISAPISearch_HttpIndexingService Win32_PerfFormattedData_MSDTC_DistributedTransactionCoordinator Win32_PerfFormattedData_NETFramework_NETCLRExceptions Win32_PerfFormattedData_NETFramework_NETCLRInterop Win32_PerfFormattedData_NETFramework_NETCLRJit Win32_PerfFormattedData_NETFramework_NETCLRLoading Win32_PerfFormattedData_NETFramework_NETCLRLocksAndThreads Win32_PerfFormattedData_NETFramework_NETCLRMemory Win32_PerfFormattedData_NETFramework_NETCLRRemoting Win32_PerfFormattedData_NETFramework_NETCLRSecurity Win32_PerfFormattedData_NTDS_NTDS Win32_PerfFormattedData_PerfDisk_LogicalDisk Win32_PerfFormattedData_PerfDisk_PhysicalDisk Win32_PerfFormattedData_PerfNet_Browser Win32_PerfFormattedData_PerfNet_Redirector Win32_PerfFormattedData_PerfNet_Server Win32_PerfFormattedData_PerfNet_ServerWorkQueues Win32_PerfFormattedData_PerfOS_Cache Win32_PerfFormattedData_PerfOS_Memory Win32_PerfFormattedData_PerfOS_Objects Win32_PerfFormattedData_PerfOS_PagingFile Win32_PerfFormattedData_PerfOS_Processor Win32_PerfFormattedData_PerfOS_System Win32_PerfFormattedData_PerfProc_FullImage_Costly Win32_PerfFormattedData_PerfProc_Image_Costly Win32_PerfFormattedData_PerfProc_JobObject Win32_PerfFormattedData_PerfProc_JobObjectDetails Win32_PerfFormattedData_PerfProc_Process Win32_PerfFormattedData_PerfProc_ProcessAddressSpace_Costly Win32_PerfFormattedData_PerfProc_Thread Win32_PerfFormattedData_PerfProc_ThreadDetails_Costly Win32_PerfFormattedData_RemoteAccess_RASPort Win32_PerfFormattedData_RemoteAccess_RASTotal Win32_PerfFormattedData_RSVP_ACSRSVPInterfaces Win32_PerfFormattedData_RSVP_ACSRSVPService Win32_PerfFormattedData_Spooler_PrintQueue Win32_PerfFormattedData_TapiSrv_Telephony Win32_PerfFormattedData_Tcpip_ICMP Win32_PerfFormattedData_Tcpip_ICMPv6 Win32_PerfFormattedData_Tcpip_IP Win32_PerfFormattedData_Tcpip_IPv4 Win32_PerfFormattedData_Tcpip_IPv6 Win32_PerfFormattedData_Tcpip_NBTConnection Win32_PerfFormattedData_Tcpip_NetworkInterface Win32_PerfFormattedData_Tcpip_TCP Win32_PerfFormattedData_Tcpip_TCPv4 Win32_PerfFormattedData_Tcpip_TCPv6 Win32_PerfFormattedData_Tcpip_UDP Win32_PerfFormattedData_Tcpip_UDPv4 Win32_PerfFormattedData_Tcpip_UDPv6 Win32_PerfFormattedData_TermService_TerminalServices Win32_PerfFormattedData_TermService_TerminalServicesSession Win32_PerfRawData_ASP_ActiveServerPages Win32_PerfRawData_ContentFilter_IndexingServiceFilter Win32_PerfRawData_ContentIndex_IndexingService Win32_PerfRawData_Fax_FaxServices Win32_PerfRawData_FileReplicaConn_FileReplicaConn Win32_PerfRawData_FileReplicaSet_FileReplicaSet Win32_PerfRawData_IAS_IASAccountingClients Win32_PerfRawData_IAS_IASAccountingServer Win32_PerfRawData_IAS_IASAuthenticationClients Win32_PerfRawData_IAS_IASAuthenticationServer Win32_PerfRawData_InetInfo_InternetInformationServicesGlobal Win32_PerfRawData_IPSec_IPSecv4Driver Win32_PerfRawData_IPSec_IPSecv4IKE Win32_PerfRawData_ISAPISearch_HttpIndexingService Win32_PerfRawData_MSDTC_DistributedTransactionCoordinator Win32_PerfRawData_NETFramework_NETCLRExceptions Win32_PerfRawData_NETFramework_NETCLRInterop Win32_PerfRawData_NETFramework_NETCLRJit Win32_PerfRawData_NETFramework_NETCLRLoading Win32_PerfRawData_NETFramework_NETCLRLocksAndThreads Win32_PerfRawData_NETFramework_NETCLRMemory Win32_PerfRawData_NETFramework_NETCLRRemoting Win32_PerfRawData_NETFramework_NETCLRSecurity Win32_PerfRawData_NTDS_NTDS Win32_PerfRawData_NTFSDRV_SMTPNTFSStoreDriver Win32_PerfRawData_PerfDisk_LogicalDisk Win32_PerfRawData_PerfDisk_PhysicalDisk Win32_PerfRawData_PerfNet_Browser Win32_PerfRawData_PerfNet_Redirector Win32_PerfRawData_PerfNet_Server Win32_PerfRawData_PerfNet_ServerWorkQueues Win32_PerfRawData_PerfOS_Cache Win32_PerfRawData_PerfOS_Memory Win32_PerfRawData_PerfOS_Objects Win32_PerfRawData_PerfOS_PagingFile Win32_PerfRawData_PerfOS_Processor Win32_PerfRawData_PerfOS_System Win32_PerfRawData_PerfProc_FullImage_Costly Win32_PerfRawData_PerfProc_Image_Costly Win32_PerfRawData_PerfProc_JobObject Win32_PerfRawData_PerfProc_JobObjectDetails Win32_PerfRawData_PerfProc_Process Win32_PerfRawData_PerfProc_ProcessAddressSpace_Costly Win32_PerfRawData_PerfProc_Thread Win32_PerfRawData_PerfProc_ThreadDetails_Costly Win32_PerfRawData_RemoteAccess_RASPort Win32_PerfRawData_RemoteAccess_RASTotal Win32_PerfRawData_RSVP_ACSPerRSVPService Win32_PerfRawData_RSVP_ACSRSVPInterfaces Win32_PerfRawData_RSVP_ACSRSVPService Win32_PerfRawData_SMTPSVC_SMTPServer Win32_PerfRawData_Spooler_PrintQueue Win32_PerfRawData_TapiSrv_Telephony Win32_PerfRawData_Tcpip_ICMP Win32_PerfRawData_Tcpip_ICMPv6 Win32_PerfRawData_Tcpip_IP Win32_PerfRawData_Tcpip_IPv4 Win32_PerfRawData_Tcpip_IPv6 Win32_PerfRawData_Tcpip_NBTConnection Win32_PerfRawData_Tcpip_NetworkInterface Win32_PerfRawData_Tcpip_TCP Win32_PerfRawData_Tcpip_TCPv4 Win32_PerfRawData_Tcpip_TCPv6 Win32_PerfRawData_Tcpip_UDP Win32_PerfRawData_Tcpip_UDPv4 Win32_PerfRawData_Tcpip_UDPv6 Win32_PerfRawData_TermService_TerminalServices Win32_PerfRawData_TermService_TerminalServicesSession Win32_PerfRawData_W3SVC_WebService Win32_PhysicalMedia Win32_PhysicalMemory Win32_PhysicalMemoryArray Win32_PhysicalMemoryLocation Win32_PingStatus Win32_PNPAllocatedResource Win32_PnPDevice Win32_PnPEntity Win32_PnPSignedDriver Win32_PnPSignedDriverCIMDataFile Win32_PointingDevice Win32_PortableBattery Win32_PortConnector Win32_PortResource Win32_POTSModem Win32_POTSModemToSerialPort Win32_Printer Win32_PrinterConfiguration Win32_PrinterController Win32_PrinterDriver Win32_PrinterDriverDll Win32_PrinterSetting Win32_PrinterShare Win32_PrintJob Win32_Process Win32_Processor Win32_ProductOptional Win32_ProductCheck Win32_ProductResource Win32_ProductSoftwareFeatures Win32_ProgIDSpecification Win32_ProgramGroup Win32_ProgramGroupContents Win32_Property Win32_ProtocolBinding Win32_Proxy Win32_PublishComponentAction Win32_QuickFixEngineering Win32_QuotaSetting Win32_Refrigeration Win32_Registry Win32_RegistryAction Win32_RemoveFileAction Win32_RemoveIniAction Win32_ReserveCost Win32_ScheduledJob Win32_SCSIController Win32_SCSIControllerDevice Win32_SecuritySettingOfLogicalFile Win32_SecuritySettingOfLogicalShare Win32_SelfRegModuleAction Win32_SerialPort Win32_SerialPortConfiguration Win32_SerialPortSetting Win32_ServerConnection Win32_ServerSession Win32_Service Win32_ServiceControl Win32_ServiceSpecification Win32_ServiceSpecificationService Win32_SessionConnection Win32_SessionProcess Win32_ShadowBy Win32_ShadowCopy Win32_ShadowDiffVolumeSupport Win32_ShadowFor Win32_ShadowOn Win32_ShadowProvider Win32_ShadowStorage Win32_ShadowVolumeSupport Win32_Share Win32_ShareToDirectory Win32_ShortcutAction Win32_ShortcutFile Win32_ShortcutSAP Win32_SID Win32_SoftwareElement Win32_SoftwareElementAction Win32_SoftwareElementCheck Win32_SoftwareElementCondition Win32_SoftwareElementResource Win32_SoftwareFeature Win32_SoftwareFeatureAction Win32_SoftwareFeatureCheck Win32_SoftwareFeatureParent Win32_SoftwareFeatureSoftwareElements Win32_SoundDevice Win32_StartupCommand Win32_SubDirectory Win32_SystemAccount Win32_SystemBIOS Win32_SystemBootConfiguration Win32_SystemDesktop Win32_SystemDevices Win32_SystemDriver Win32_SystemDriverPNPEntity Win32_SystemEnclosure Win32_SystemLoadOrderGroups Win32_SystemLogicalMemoryConfiguration Win32_SystemNetworkConnections Win32_SystemOperatingSystem Win32_SystemPartitions Win32_SystemProcesses Win32_SystemProgramGroups Win32_SystemResources Win32_SystemServices Win32_SystemSlot Win32_SystemSystemDriver Win32_SystemTimeZone Win32_SystemUsers Win32_TapeDrive Win32_TCPIPPrinterPort Win32_TemperatureProbe Win32_Terminal Win32_TerminalService Win32_TerminalServiceSetting Win32_TerminalServiceToSetting Win32_TerminalTerminalSetting Win32_Thread Win32_TimeZone Win32_TSAccount Win32_TSClientSetting Win32_TSEnvironmentSetting Win32_TSGeneralSetting Win32_TSLogonSetting Win32_TSNetworkAdapterListSetting Win32_TSNetworkAdapterSetting Win32_TSPermissionsSetting Win32_TSRemoteControlSetting  Win32_TSSessionDirectory Win32_TSSessionDirectorySetting Win32_TSSessionSetting Win32_TypeLibraryAction Win32_UninterruptiblePowerSupply Win32_USBController Win32_USBControllerDevice Win32_USBHub Win32_UserAccount Win32_UserDesktop Win32_UserInDomain Win32_UTCTime Win32_VideoConfiguration Win32_VideoController Win32_VideoSettings Win32_VoltageProbe Win32_Volume Win32_VolumeQuota Win32_VolumeQuotaSetting Win32_VolumeUserQuota Win32_WindowsProductActivation Win32_WMIElementSetting Win32_WMISetting</Keywords>
      <Keywords name="Words4">$ $$ $? $^ $Args $DebugPreference $Error $ErrorActionPreference $false $foreach $HistorySize $HOME $Host $Input $LastExitCode $Match $MshHome $MyInvocation $null $OFS $PSCommandPath $ShellID $StackTrace $true $_</Keywords>
    </KeywordLists>
    <Styles>
      <WordsStyle name="DEFAULT" fontStyle="0" fontName="" bgColor="FFFFFF" fgColor="000000" styleID="11" />
      <WordsStyle name="FOLDEROPEN" fontStyle="0" fontName="" bgColor="FFFFFF" fgColor="000000" styleID="12" />
      <WordsStyle name="FOLDERCLOSE" fontStyle="0" fontName="" bgColor="FFFFFF" fgColor="000000" styleID="13" />
      <WordsStyle name="KEYWORD1" fontStyle="0" fontName="" bgColor="FFFFFF" fgColor="0000FF" styleID="5" />
      <WordsStyle name="KEYWORD2" fontStyle="0" fontName="" bgColor="FFFFFF" fgColor="8000FF" styleID="6" />
      <WordsStyle name="KEYWORD3" fontStyle="0" fontName="" bgColor="FFFFFF" fgColor="FF00FF" styleID="7" />
      <WordsStyle name="KEYWORD4" fontStyle="0" fontName="" bgColor="FFFFFF" fgColor="FF4500" styleID="8" />
      <WordsStyle name="COMMENT" fontStyle="0" fontName="" bgColor="FFFFFF" fgColor="006400" styleID="1" />
      <WordsStyle name="COMMENT LINE" fontStyle="0" fontName="" bgColor="FFFFFF" fgColor="006400" styleID="2" />
      <WordsStyle name="NUMBER" fontStyle="0" fontName="" bgColor="FFFFFF" fgColor="800080" styleID="4" />
      <WordsStyle name="OPERATOR" fontStyle="0" fontName="" bgColor="FFFFFF" fgColor="a9a9a9" styleID="10" />
      <WordsStyle name="DELIMINER1" fontStyle="0" fontName="" bgColor="FFFFFF" fgColor="8b0000" styleID="14" />
      <WordsStyle name="DELIMINER2" fontStyle="0" fontName="" bgColor="FFFFFF" fgColor="000000" styleID="15" />
      <WordsStyle name="DELIMINER3" fontStyle="0" fontName="" bgColor="FFFFFF" fgColor="000000" styleID="16" />
    </Styles>
  </UserLang>
</NotepadPlus>

The current version of the above code is in the Git repository at this link: userDefineLang.xml.

To do this, we will also use the capabilities of the PowerShell language and generate the contents of this file with the code below:

###################################################################
#
# Powershell script for generate Notepad++ userDefineLang.xml
#
# Script for Notepad++ Powershell User Define Language support.
# Script create xml file User Define Language - userDefineLang.xml 
# in %APPDATA%\Notepad++\ directory.
#  
# Version:        0.1
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  12.09.2007
# Purpose/Change: Initial script development
#
# Run:
#   
# .\NppPowershellLanguageSupport.ps1
#
####################################################################

$ExportFilePath = "$env:APPDATA\Notepad++\userDefineLang.xml"

$XmlDocument = New-Object System.Xml.XmlDocument
$xmlDeclaration = $XmlDocument.CreateXmlDeclaration("1.0",$Null,$Null)
$Null = $XmlDocument.AppendChild($xmlDeclaration)
$RootNode = $XmlDocument.CreateElement("NotepadPlus")


$UserLangNode = $XmlDocument.CreateElement("UserLang")
$UserLangAttribute = $UserLangNode.SetAttribute("name","PowerShell")
$UserLangAttribute = $UserLangNode.SetAttribute("ext","ps1")

$SettingsNode = $XmlDocument.CreateElement("Settings")

$GlobalNode = $XmlDocument.CreateElement("Global")
$GlobalAttribute = $GlobalNode.SetAttribute("caseIgnored","yes")

$TreatAsSymbolNode = $XmlDocument.CreateElement("TreatAsSymbol")
$TreatAsSymbolAttribute = $TreatAsSymbolNode.SetAttribute("comment","no")
$TreatAsSymbolAttribute = $TreatAsSymbolNode.SetAttribute("commentLine","yes")


$PrefixNode = $XmlDocument.CreateElement("PrefixNode")
$PrefixAttribute = $PrefixNode.SetAttribute("words1","yes")
$PrefixAttribute = $PrefixNode.SetAttribute("words2","no")
$PrefixAttribute = $PrefixNode.SetAttribute("words3","no")
$PrefixAttribute = $PrefixNode.SetAttribute("words4","no")


$Null = $SettingsNode.AppendChild($GlobalNode)
$Null = $SettingsNode.AppendChild($TreatAsSymbolNode)
$Null = $SettingsNode.AppendChild($PrefixNode)

$Null = $UserLangNode.AppendChild($SettingsNode)

$KeywordListsNode = $XmlDocument.CreateElement("KeywordLists")

$KeywordsNode1 = $XmlDocument.CreateElement("Keywords")
$KeywordsAttribute = $KeywordsNode1.SetAttribute("name","Delimiters")
$KeywordsTextNode1 = $XmlDocument.CreateTextNode(""00"00")
$Null = $KeywordsNode1.AppendChild($KeywordsTextNode1)

$KeywordsNode2 = $XmlDocument.CreateElement("Keywords")
$KeywordsAttribute = $KeywordsNode2.SetAttribute("name","Folder+")
$KeywordsTextNode2 = $XmlDocument.CreateTextNode("{")
$Null = $KeywordsNode2.AppendChild($KeywordsTextNode2)

$KeywordsNode3 = $XmlDocument.CreateElement("Keywords")
$KeywordsAttribute = $KeywordsNode3.SetAttribute("name","Folder-")
$KeywordsTextNode3 = $XmlDocument.CreateTextNode("}")
$Null = $KeywordsNode3.AppendChild($KeywordsTextNode3)

$KeywordsNode4 = $XmlDocument.CreateElement("Keywords")
$KeywordsAttribute = $KeywordsNode4.SetAttribute("name","Operators")
$OperatorsSymbols = '! " % & ( ) * , / : ; ? @ [ \ ] ^ ` | ~ + < = >'
$KeywordsTextNode4 = $XmlDocument.CreateTextNode($OperatorsSymbols)
$Null = $KeywordsNode4.AppendChild($KeywordsTextNode4)

$KeywordsNode5 = $XmlDocument.CreateElement("Keywords")
$KeywordsAttribute = $KeywordsNode5.SetAttribute("name","Comment")
$KeywordsTextNode5 = $XmlDocument.CreateTextNode("1 2 0#")
$Null = $KeywordsNode5.AppendChild($KeywordsTextNode5)

$KeywordsNode6 = $XmlDocument.CreateElement("Keywords")
$KeywordsAttribute = $KeywordsNode6.SetAttribute("name","Words1")
$KeywordsTextNode6 = $XmlDocument.CreateTextNode("Add-Content Add-History Add-Member Add-PSSnapin Clear-Content Clear-Item Clear-ItemProperty Clear-Variable Compare-Object ConvertFrom-SecureString Convert-Path ConvertTo-Html ConvertTo-SecureString Copy-Item Copy-ItemProperty Export-Alias Export-Clixml Export-Console Export-Csv ForEach-Object Format-Custom Format-List Format-Table Format-Wide Get-Acl Get-Alias Get-AuthenticodeSignature Get-ChildItem Get-Command Get-Content Get-Credential Get-Culture Get-Date Get-EventLog Get-ExecutionPolicy Get-Help Get-History Get-Host Get-Item Get-ItemProperty Get-Location Get-Member Get-PfxCertificate Get-Process Get-PSDrive Get-PSProvider Get-PSSnapin Get-Service Get-TraceSource Get-UICulture Get-Unique Get-Variable Get-WmiObject Group-Object Import-Alias Import-Clixml Import-Csv Invoke-Expression Invoke-History Invoke-Item Join-Path Measure-Command Measure-Object Move-Item Move-ItemProperty New-Alias New-Item New-ItemProperty New-Object New-PSDrive New-Service New-TimeSpan New-Variable Out-Default Out-File Out-Host Out-Null Out-Printer Out-String Pop-Location Push-Location Read-Host Remove-Item Remove-ItemProperty Remove-PSDrive Remove-PSSnapin Remove-Variable Rename-Item Rename-ItemProperty Resolve-Path Restart-Service Resume-Service Select-Object Select-String Set-Acl Set-Alias Set-AuthenticodeSignature Set-Content Set-Date Set-ExecutionPolicy Set-Item Set-ItemProperty Set-Location Set-PSDebug Set-Service Set-TraceSource Set-Variable Sort-Object Split-Path Start-Service Start-Sleep Start-Transcript Stop-Process Stop-Service Stop-Transcript Suspend-Service Tee-Object Test-Path Trace-Command Update-FormatData Update-TypeData Where-Object Write-Debug Write-Error Write-Host Write-Output Write-Progress Write-Verbose Write-Warning switch function if throw else while break - $ System. Management.")
$Null = $KeywordsNode6.AppendChild($KeywordsTextNode6)

$KeywordsNode7 = $XmlDocument.CreateElement("Keywords")
$KeywordsAttribute = $KeywordsNode7.SetAttribute("name","Words2")
$KeywordsTextNode7 = $XmlDocument.CreateTextNode("ac asnp clc cli clp clv cpi cpp cvpa diff epal epcsv fc fl foreach % ft fw gal gc gci gcm gdr ghy gi gl gm gp gps group gsv gsnp gu gv gwmi iex ihy ii ipal ipcsv mi mp nal ndr ni nv oh rdr ri rni rnp rp rsnp rv rvpa sal sasv sc select si sl sleep sort sp spps spsv sv tee where ? write cat cd clear cp h history kill lp ls mount mv popd ps pushd pwd r rm rmdir echo cls chdir copy del dir erase move rd ren set type")
$Null = $KeywordsNode7.AppendChild($KeywordsTextNode7)

$KeywordsNode8 = $XmlDocument.CreateElement("Keywords")
$KeywordsAttribute = $KeywordsNode8.SetAttribute("name","Words3")
$Words3 = "CIM_DataFile CIM_DirectoryContainsFile CIM_ProcessExecutable CIM_VideoControllerResolution Msft_Providers Msft_WmiProvider_Counters NetDiagnostics Win32_1394Controller Win32_1394ControllerDevice Win32_AccountSID Win32_ActionCheck Win32_ActiveRoute Win32_AllocatedResource Win32_ApplicationCommandLine Win32_ApplicationService Win32_AssociatedBattery Win32_AssociatedProcessorMemory Win32_AutochkSetting Win32_BaseBoard Win32_Battery Win32_Binary Win32_BindImageAction Win32_BIOS Win32_BootConfiguration Win32_Bus Win32_CacheMemory Win32_CDROMDrive Win32_CheckCheck Win32_CIMLogicalDeviceCIMDataFile Win32_ClassicCOMApplicationClasses Win32_ClassicCOMClass Win32_ClassicCOMClassSetting Win32_ClassicCOMClassSettings Win32_ClassInfoAction Win32_ClientApplicationSetting Win32_CodecFile Win32_COMApplicationSettings Win32_ComClassAutoEmulator Win32_ComClassEmulator Win32_CommandLineAccess Win32_ComponentCategory Win32_ComputerSystem Win32_ComputerSystemProcessor Win32_ComputerSystemProduct Win32_ComputerSystemWindowsProductActivationSetting Win32_Condition Win32_ConnectionShare Win32_ControllerHasHub Win32_CreateFolderAction Win32_CurrentProbe Win32_DCOMApplication Win32_DCOMApplicationAccessAllowedSetting Win32_DCOMApplicationLaunchAllowedSetting Win32_DCOMApplicationSetting Win32_DependentService Win32_Desktop Win32_DesktopMonitor Win32_DeviceBus Win32_DeviceMemoryAddress Win32_DfsNode Win32_DfsNodeTarget Win32_DfsTarget Win32_Directory Win32_DirectorySpecification Win32_DiskDrive Win32_DiskDrivePhysicalMedia Win32_DiskDriveToDiskPartition Win32_DiskPartition Win32_DiskQuota Win32_DisplayConfiguration Win32_DisplayControllerConfiguration Win32_DMAChannel Win32_DriverForDevice Win32_DriverVXD Win32_DuplicateFileAction Win32_Environment Win32_EnvironmentSpecification Win32_ExtensionInfoAction Win32_Fan Win32_FileSpecification Win32_FloppyController Win32_FloppyDrive Win32_FontInfoAction Win32_Group Win32_GroupInDomain Win32_GroupUser Win32_HeatPipe Win32_IDEController Win32_IDEControllerDevice Win32_ImplementedCategory Win32_InfraredDevice Win32_IniFileSpecification Win32_InstalledSoftwareElement Win32_IP4PersistedRouteTable Win32_IP4RouteTable Win32_IRQResource Win32_Keyboard Win32_LaunchCondition Win32_LoadOrderGroup Win32_LoadOrderGroupServiceDependencies Win32_LoadOrderGroupServiceMembers Win32_LocalTime Win32_LoggedOnUser Win32_LogicalDisk Win32_LogicalDiskRootDirectory Win32_LogicalDiskToPartition Win32_LogicalFileAccess Win32_LogicalFileAuditing Win32_LogicalFileGroup Win32_LogicalFileOwner Win32_LogicalFileSecuritySetting Win32_LogicalMemoryConfiguration Win32_LogicalProgramGroup Win32_LogicalProgramGroupDirectory Win32_LogicalProgramGroupItem Win32_LogicalProgramGroupItemDataFile Win32_LogicalShareAccess Win32_LogicalShareAuditing Win32_LogicalShareSecuritySetting Win32_LogonSession Win32_LogonSessionMappedDisk Win32_MappedLogicalDisk Win32_MemoryArray Win32_MemoryArrayLocation Win32_MemoryDevice Win32_MemoryDeviceArray Win32_MemoryDeviceLocation Win32_MIMEInfoAction Win32_MotherboardDevice Win32_MountPoint Win32_MoveFileAction Win32_NamedJobObject Win32_NamedJobObjectActgInfo Win32_NamedJobObjectLimit Win32_NamedJobObjectLimitSetting Win32_NamedJobObjectProcess Win32_NamedJobObjectSecLimit Win32_NamedJobObjectSecLimitSetting Win32_NamedJobObjectStatistics Win32_NetworkAdapter Win32_NetworkAdapterConfiguration Win32_NetworkAdapterSetting Win32_NetworkClient Win32_NetworkConnection Win32_NetworkLoginProfile Win32_NetworkProtocol Win32_NTDomain Win32_NTEventlogFile Win32_NTLogEvent Win32_NTLogEventComputer Win32_NTLogEventLog Win32_NTLogEventUser Win32_ODBCAttribute Win32_ODBCDataSourceAttribute Win32_ODBCDataSourceSpecification Win32_ODBCDriverAttribute Win32_ODBCDriverSoftwareElement Win32_ODBCDriverSpecification Win32_ODBCSourceAttribute Win32_ODBCTranslatorSpecification Win32_OnBoardDevice Win32_OperatingSystem Win32_OperatingSystemAutochkSetting Win32_OperatingSystemQFE Win32_OSRecoveryConfiguration Win32_PageFile Win32_PageFileElementSetting Win32_PageFileSetting Win32_PageFileUsage Win32_ParallelPort Win32_Patch Win32_PatchFile Win32_PatchPackage Win32_PCMCIAController Win32_PerfFormattedData_ContentFilter_IndexingServiceFilter Win32_PerfFormattedData_ContentIndex_IndexingService Win32_PerfFormattedData_Fax_FaxServices Win32_PerfFormattedData_IPSec_IPSecv4Driver Win32_PerfFormattedData_IPSec_IPSecv4IKE Win32_PerfFormattedData_ISAPISearch_HttpIndexingService Win32_PerfFormattedData_MSDTC_DistributedTransactionCoordinator Win32_PerfFormattedData_NETFramework_NETCLRExceptions Win32_PerfFormattedData_NETFramework_NETCLRInterop Win32_PerfFormattedData_NETFramework_NETCLRJit Win32_PerfFormattedData_NETFramework_NETCLRLoading Win32_PerfFormattedData_NETFramework_NETCLRLocksAndThreads Win32_PerfFormattedData_NETFramework_NETCLRMemory Win32_PerfFormattedData_NETFramework_NETCLRRemoting Win32_PerfFormattedData_NETFramework_NETCLRSecurity Win32_PerfFormattedData_NTDS_NTDS Win32_PerfFormattedData_PerfDisk_LogicalDisk Win32_PerfFormattedData_PerfDisk_PhysicalDisk Win32_PerfFormattedData_PerfNet_Browser Win32_PerfFormattedData_PerfNet_Redirector Win32_PerfFormattedData_PerfNet_Server Win32_PerfFormattedData_PerfNet_ServerWorkQueues Win32_PerfFormattedData_PerfOS_Cache Win32_PerfFormattedData_PerfOS_Memory Win32_PerfFormattedData_PerfOS_Objects Win32_PerfFormattedData_PerfOS_PagingFile Win32_PerfFormattedData_PerfOS_Processor Win32_PerfFormattedData_PerfOS_System Win32_PerfFormattedData_PerfProc_FullImage_Costly Win32_PerfFormattedData_PerfProc_Image_Costly Win32_PerfFormattedData_PerfProc_JobObject Win32_PerfFormattedData_PerfProc_JobObjectDetails Win32_PerfFormattedData_PerfProc_Process Win32_PerfFormattedData_PerfProc_ProcessAddressSpace_Costly Win32_PerfFormattedData_PerfProc_Thread Win32_PerfFormattedData_PerfProc_ThreadDetails_Costly Win32_PerfFormattedData_RemoteAccess_RASPort Win32_PerfFormattedData_RemoteAccess_RASTotal Win32_PerfFormattedData_RSVP_ACSRSVPInterfaces Win32_PerfFormattedData_RSVP_ACSRSVPService Win32_PerfFormattedData_Spooler_PrintQueue Win32_PerfFormattedData_TapiSrv_Telephony Win32_PerfFormattedData_Tcpip_ICMP Win32_PerfFormattedData_Tcpip_ICMPv6 Win32_PerfFormattedData_Tcpip_IP Win32_PerfFormattedData_Tcpip_IPv4 Win32_PerfFormattedData_Tcpip_IPv6 Win32_PerfFormattedData_Tcpip_NBTConnection Win32_PerfFormattedData_Tcpip_NetworkInterface Win32_PerfFormattedData_Tcpip_TCP Win32_PerfFormattedData_Tcpip_TCPv4 Win32_PerfFormattedData_Tcpip_TCPv6 Win32_PerfFormattedData_Tcpip_UDP Win32_PerfFormattedData_Tcpip_UDPv4 Win32_PerfFormattedData_Tcpip_UDPv6 Win32_PerfFormattedData_TermService_TerminalServices Win32_PerfFormattedData_TermService_TerminalServicesSession Win32_PerfRawData_ASP_ActiveServerPages Win32_PerfRawData_ContentFilter_IndexingServiceFilter Win32_PerfRawData_ContentIndex_IndexingService Win32_PerfRawData_Fax_FaxServices Win32_PerfRawData_FileReplicaConn_FileReplicaConn Win32_PerfRawData_FileReplicaSet_FileReplicaSet Win32_PerfRawData_IAS_IASAccountingClients Win32_PerfRawData_IAS_IASAccountingServer Win32_PerfRawData_IAS_IASAuthenticationClients Win32_PerfRawData_IAS_IASAuthenticationServer Win32_PerfRawData_InetInfo_InternetInformationServicesGlobal Win32_PerfRawData_IPSec_IPSecv4Driver Win32_PerfRawData_IPSec_IPSecv4IKE Win32_PerfRawData_ISAPISearch_HttpIndexingService Win32_PerfRawData_MSDTC_DistributedTransactionCoordinator Win32_PerfRawData_NETFramework_NETCLRExceptions Win32_PerfRawData_NETFramework_NETCLRInterop Win32_PerfRawData_NETFramework_NETCLRJit Win32_PerfRawData_NETFramework_NETCLRLoading Win32_PerfRawData_NETFramework_NETCLRLocksAndThreads Win32_PerfRawData_NETFramework_NETCLRMemory Win32_PerfRawData_NETFramework_NETCLRRemoting Win32_PerfRawData_NETFramework_NETCLRSecurity Win32_PerfRawData_NTDS_NTDS Win32_PerfRawData_NTFSDRV_SMTPNTFSStoreDriver Win32_PerfRawData_PerfDisk_LogicalDisk Win32_PerfRawData_PerfDisk_PhysicalDisk Win32_PerfRawData_PerfNet_Browser Win32_PerfRawData_PerfNet_Redirector Win32_PerfRawData_PerfNet_Server Win32_PerfRawData_PerfNet_ServerWorkQueues Win32_PerfRawData_PerfOS_Cache "
$Words3 = $Words3 + "Win32_PerfRawData_PerfOS_Memory Win32_PerfRawData_PerfOS_Objects Win32_PerfRawData_PerfOS_PagingFile Win32_PerfRawData_PerfOS_Processor Win32_PerfRawData_PerfOS_System Win32_PerfRawData_PerfProc_FullImage_Costly Win32_PerfRawData_PerfProc_Image_Costly Win32_PerfRawData_PerfProc_JobObject Win32_PerfRawData_PerfProc_JobObjectDetails Win32_PerfRawData_PerfProc_Process Win32_PerfRawData_PerfProc_ProcessAddressSpace_Costly Win32_PerfRawData_PerfProc_Thread Win32_PerfRawData_PerfProc_ThreadDetails_Costly Win32_PerfRawData_RemoteAccess_RASPort Win32_PerfRawData_RemoteAccess_RASTotal Win32_PerfRawData_RSVP_ACSPerRSVPService Win32_PerfRawData_RSVP_ACSRSVPInterfaces Win32_PerfRawData_RSVP_ACSRSVPService Win32_PerfRawData_SMTPSVC_SMTPServer Win32_PerfRawData_Spooler_PrintQueue Win32_PerfRawData_TapiSrv_Telephony Win32_PerfRawData_Tcpip_ICMP Win32_PerfRawData_Tcpip_ICMPv6 Win32_PerfRawData_Tcpip_IP Win32_PerfRawData_Tcpip_IPv4 Win32_PerfRawData_Tcpip_IPv6 Win32_PerfRawData_Tcpip_NBTConnection Win32_PerfRawData_Tcpip_NetworkInterface Win32_PerfRawData_Tcpip_TCP Win32_PerfRawData_Tcpip_TCPv4 Win32_PerfRawData_Tcpip_TCPv6 Win32_PerfRawData_Tcpip_UDP Win32_PerfRawData_Tcpip_UDPv4 Win32_PerfRawData_Tcpip_UDPv6 Win32_PerfRawData_TermService_TerminalServices Win32_PerfRawData_TermService_TerminalServicesSession Win32_PerfRawData_W3SVC_WebService Win32_PhysicalMedia Win32_PhysicalMemory Win32_PhysicalMemoryArray Win32_PhysicalMemoryLocation Win32_PingStatus Win32_PNPAllocatedResource Win32_PnPDevice Win32_PnPEntity Win32_PnPSignedDriver Win32_PnPSignedDriverCIMDataFile Win32_PointingDevice Win32_PortableBattery Win32_PortConnector Win32_PortResource Win32_POTSModem Win32_POTSModemToSerialPort Win32_Printer Win32_PrinterConfiguration Win32_PrinterController Win32_PrinterDriver Win32_PrinterDriverDll Win32_PrinterSetting Win32_PrinterShare Win32_PrintJob Win32_Process Win32_Processor Win32_ProductOptional Win32_ProductCheck Win32_ProductResource Win32_ProductSoftwareFeatures Win32_ProgIDSpecification Win32_ProgramGroup Win32_ProgramGroupContents Win32_Property Win32_ProtocolBinding Win32_Proxy Win32_PublishComponentAction Win32_QuickFixEngineering Win32_QuotaSetting Win32_Refrigeration Win32_Registry Win32_RegistryAction Win32_RemoveFileAction Win32_RemoveIniAction Win32_ReserveCost Win32_ScheduledJob Win32_SCSIController Win32_SCSIControllerDevice Win32_SecuritySettingOfLogicalFile Win32_SecuritySettingOfLogicalShare Win32_SelfRegModuleAction Win32_SerialPort Win32_SerialPortConfiguration Win32_SerialPortSetting Win32_ServerConnection Win32_ServerSession Win32_Service Win32_ServiceControl Win32_ServiceSpecification Win32_ServiceSpecificationService Win32_SessionConnection Win32_SessionProcess Win32_ShadowBy Win32_ShadowCopy Win32_ShadowDiffVolumeSupport Win32_ShadowFor Win32_ShadowOn Win32_ShadowProvider Win32_ShadowStorage Win32_ShadowVolumeSupport Win32_Share Win32_ShareToDirectory Win32_ShortcutAction Win32_ShortcutFile Win32_ShortcutSAP Win32_SID Win32_SoftwareElement Win32_SoftwareElementAction Win32_SoftwareElementCheck Win32_SoftwareElementCondition Win32_SoftwareElementResource Win32_SoftwareFeature Win32_SoftwareFeatureAction Win32_SoftwareFeatureCheck Win32_SoftwareFeatureParent Win32_SoftwareFeatureSoftwareElements Win32_SoundDevice Win32_StartupCommand Win32_SubDirectory Win32_SystemAccount Win32_SystemBIOS Win32_SystemBootConfiguration Win32_SystemDesktop Win32_SystemDevices Win32_SystemDriver Win32_SystemDriverPNPEntity Win32_SystemEnclosure Win32_SystemLoadOrderGroups Win32_SystemLogicalMemoryConfiguration Win32_SystemNetworkConnections Win32_SystemOperatingSystem Win32_SystemPartitions Win32_SystemProcesses Win32_SystemProgramGroups Win32_SystemResources Win32_SystemServices Win32_SystemSlot Win32_SystemSystemDriver Win32_SystemTimeZone Win32_SystemUsers Win32_TapeDrive Win32_TCPIPPrinterPort Win32_TemperatureProbe Win32_Terminal Win32_TerminalService Win32_TerminalServiceSetting Win32_TerminalServiceToSetting Win32_TerminalTerminalSetting Win32_Thread Win32_TimeZone Win32_TSAccount Win32_TSClientSetting Win32_TSEnvironmentSetting Win32_TSGeneralSetting Win32_TSLogonSetting Win32_TSNetworkAdapterListSetting Win32_TSNetworkAdapterSetting Win32_TSPermissionsSetting Win32_TSRemoteControlSetting  Win32_TSSessionDirectory Win32_TSSessionDirectorySetting Win32_TSSessionSetting Win32_TypeLibraryAction Win32_UninterruptiblePowerSupply Win32_USBController Win32_USBControllerDevice Win32_USBHub Win32_UserAccount Win32_UserDesktop Win32_UserInDomain Win32_UTCTime Win32_VideoConfiguration Win32_VideoController Win32_VideoSettings Win32_VoltageProbe Win32_Volume Win32_VolumeQuota Win32_VolumeQuotaSetting Win32_VolumeUserQuota Win32_WindowsProductActivation Win32_WMIElementSetting Win32_WMISetting"
$KeywordsTextNode8 = $XmlDocument.CreateTextNode($Words3)
$Null = $KeywordsNode8.AppendChild($KeywordsTextNode8)

$KeywordsNode9 = $XmlDocument.CreateElement("Keywords")
$KeywordsAttribute = $KeywordsNode9.SetAttribute("name","Words4")
$Words4 = @'
$ $$ $? $^ $Args $DebugPreference $Error $ErrorActionPreference $false $foreach $HistorySize $HOME $Host $Input $LastExitCode $Match $MshHome $MyInvocation $null $OFS $PSCommandPath $ShellID $StackTrace $true $_
'@
$KeywordsTextNode9 = $XmlDocument.CreateTextNode($Words4)
$Null = $KeywordsNode9.AppendChild($KeywordsTextNode9)

$Null = $KeywordListsNode.AppendChild($KeywordsNode1)
$Null = $KeywordListsNode.AppendChild($KeywordsNode2)
$Null = $KeywordListsNode.AppendChild($KeywordsNode3)
$Null = $KeywordListsNode.AppendChild($KeywordsNode4)
$Null = $KeywordListsNode.AppendChild($KeywordsNode5)
$Null = $KeywordListsNode.AppendChild($KeywordsNode6)
$Null = $KeywordListsNode.AppendChild($KeywordsNode7)
$Null = $KeywordListsNode.AppendChild($KeywordsNode8)
$Null = $KeywordListsNode.AppendChild($KeywordsNode9)
$Null = $UserLangNode.AppendChild($KeywordListsNode)

$StylesNode = $XmlDocument.CreateElement("Styles")

$WordsStyleNode1 = $XmlDocument.CreateElement("WordsStyle")
$WordsStyleAttribute1 = $WordsStyleNode1.SetAttribute("name","DEFAULT")
$WordsStyleAttribute1 = $WordsStyleNode1.SetAttribute("fontStyle","0")
$WordsStyleAttribute1 = $WordsStyleNode1.SetAttribute("fontName","")
$WordsStyleAttribute1 = $WordsStyleNode1.SetAttribute("bgColor","FFFFFF")
$WordsStyleAttribute1 = $WordsStyleNode1.SetAttribute("fgColor","000000")
$WordsStyleAttribute1 = $WordsStyleNode1.SetAttribute("styleID","11")

$WordsStyleNode2 = $XmlDocument.CreateElement("WordsStyle")
$WordsStyleAttribute2 = $WordsStyleNode2.SetAttribute("name","FOLDEROPEN")
$WordsStyleAttribute2 = $WordsStyleNode2.SetAttribute("fontStyle","0")
$WordsStyleAttribute2 = $WordsStyleNode2.SetAttribute("fontName","")
$WordsStyleAttribute2 = $WordsStyleNode2.SetAttribute("bgColor","FFFFFF")
$WordsStyleAttribute2 = $WordsStyleNode2.SetAttribute("fgColor","000000")
$WordsStyleAttribute2 = $WordsStyleNode2.SetAttribute("styleID","12")

$WordsStyleNode3 = $XmlDocument.CreateElement("WordsStyle")
$WordsStyleAttribute3 = $WordsStyleNode3.SetAttribute("name","FOLDERCLOSE")
$WordsStyleAttribute3 = $WordsStyleNode3.SetAttribute("fontStyle","0")
$WordsStyleAttribute3 = $WordsStyleNode3.SetAttribute("fontName","")
$WordsStyleAttribute3 = $WordsStyleNode3.SetAttribute("bgColor","FFFFFF")
$WordsStyleAttribute3 = $WordsStyleNode3.SetAttribute("fgColor","000000")
$WordsStyleAttribute3 = $WordsStyleNode3.SetAttribute("styleID","13")

$WordsStyleNode4 = $XmlDocument.CreateElement("WordsStyle")
$WordsStyleAttribute4 = $WordsStyleNode4.SetAttribute("name","KEYWORD1")
$WordsStyleAttribute4 = $WordsStyleNode4.SetAttribute("fontStyle","0")
$WordsStyleAttribute4 = $WordsStyleNode4.SetAttribute("fontName","")
$WordsStyleAttribute4 = $WordsStyleNode4.SetAttribute("bgColor","FFFFFF")
$WordsStyleAttribute4 = $WordsStyleNode4.SetAttribute("fgColor","0000FF")
$WordsStyleAttribute4 = $WordsStyleNode4.SetAttribute("styleID","5")

$WordsStyleNode5 = $XmlDocument.CreateElement("WordsStyle")
$WordsStyleAttribute5 = $WordsStyleNode5.SetAttribute("name","KEYWORD2")
$WordsStyleAttribute5 = $WordsStyleNode5.SetAttribute("fontStyle","0")
$WordsStyleAttribute5 = $WordsStyleNode5.SetAttribute("fontName","")
$WordsStyleAttribute5 = $WordsStyleNode5.SetAttribute("bgColor","FFFFFF")
$WordsStyleAttribute5 = $WordsStyleNode5.SetAttribute("fgColor","8000FF")
$WordsStyleAttribute5 = $WordsStyleNode5.SetAttribute("styleID","6")

$WordsStyleNode6 = $XmlDocument.CreateElement("WordsStyle")
$WordsStyleAttribute6 = $WordsStyleNode6.SetAttribute("name","KEYWORD3")
$WordsStyleAttribute6 = $WordsStyleNode6.SetAttribute("fontStyle","0")
$WordsStyleAttribute6 = $WordsStyleNode6.SetAttribute("fontName","")
$WordsStyleAttribute6 = $WordsStyleNode6.SetAttribute("bgColor","FFFFFF")
$WordsStyleAttribute6 = $WordsStyleNode6.SetAttribute("fgColor","FF00FF")
$WordsStyleAttribute6 = $WordsStyleNode6.SetAttribute("styleID","7")

$WordsStyleNode7 = $XmlDocument.CreateElement("WordsStyle")
$WordsStyleAttribute7 = $WordsStyleNode7.SetAttribute("name","KEYWORD4")
$WordsStyleAttribute7 = $WordsStyleNode7.SetAttribute("fontStyle","0")
$WordsStyleAttribute7 = $WordsStyleNode7.SetAttribute("fontName","")
$WordsStyleAttribute7 = $WordsStyleNode7.SetAttribute("bgColor","FFFFFF")
$WordsStyleAttribute7 = $WordsStyleNode7.SetAttribute("fgColor","FF4500")
$WordsStyleAttribute7 = $WordsStyleNode7.SetAttribute("styleID","8")

$WordsStyleNode8 = $XmlDocument.CreateElement("WordsStyle")
$WordsStyleAttribute8 = $WordsStyleNode8.SetAttribute("name","COMMENT")
$WordsStyleAttribute8 = $WordsStyleNode8.SetAttribute("fontStyle","0")
$WordsStyleAttribute8 = $WordsStyleNode8.SetAttribute("fontName","")
$WordsStyleAttribute8 = $WordsStyleNode8.SetAttribute("bgColor","FFFFFF")
$WordsStyleAttribute8 = $WordsStyleNode8.SetAttribute("fgColor","006400")
$WordsStyleAttribute8 = $WordsStyleNode8.SetAttribute("styleID","1")

$WordsStyleNode9 = $XmlDocument.CreateElement("WordsStyle")
$WordsStyleAttribute9 = $WordsStyleNode9.SetAttribute("name","COMMENT LINE")
$WordsStyleAttribute9 = $WordsStyleNode9.SetAttribute("fontStyle","0")
$WordsStyleAttribute9 = $WordsStyleNode9.SetAttribute("fontName","")
$WordsStyleAttribute9 = $WordsStyleNode9.SetAttribute("bgColor","FFFFFF")
$WordsStyleAttribute9 = $WordsStyleNode9.SetAttribute("fgColor","006400")
$WordsStyleAttribute9 = $WordsStyleNode9.SetAttribute("styleID","2")

$WordsStyleNode10 = $XmlDocument.CreateElement("WordsStyle")
$WordsStyleAttribute10 = $WordsStyleNode10.SetAttribute("name","NUMBER")
$WordsStyleAttribute10 = $WordsStyleNode10.SetAttribute("fontStyle","0")
$WordsStyleAttribute10 = $WordsStyleNode10.SetAttribute("fontName","")
$WordsStyleAttribute10 = $WordsStyleNode10.SetAttribute("bgColor","FFFFFF")
$WordsStyleAttribute10 = $WordsStyleNode10.SetAttribute("fgColor","800080")
$WordsStyleAttribute10 = $WordsStyleNode10.SetAttribute("styleID","4")

$WordsStyleNode11 = $XmlDocument.CreateElement("WordsStyle")
$WordsStyleAttribute11 = $WordsStyleNode11.SetAttribute("name","OPERATOR")
$WordsStyleAttribute11 = $WordsStyleNode11.SetAttribute("fontStyle","0")
$WordsStyleAttribute11 = $WordsStyleNode11.SetAttribute("fontName","")
$WordsStyleAttribute11 = $WordsStyleNode11.SetAttribute("bgColor","FFFFFF")
$WordsStyleAttribute11 = $WordsStyleNode11.SetAttribute("fgColor","a9a9a9")
$WordsStyleAttribute11 = $WordsStyleNode11.SetAttribute("styleID","10")

$WordsStyleNode12 = $XmlDocument.CreateElement("WordsStyle")
$WordsStyleAttribute12 = $WordsStyleNode12.SetAttribute("name","DELIMINER1")
$WordsStyleAttribute12 = $WordsStyleNode12.SetAttribute("fontStyle","0")
$WordsStyleAttribute12 = $WordsStyleNode12.SetAttribute("fontName","")
$WordsStyleAttribute12 = $WordsStyleNode12.SetAttribute("bgColor","FFFFFF")
$WordsStyleAttribute12 = $WordsStyleNode12.SetAttribute("fgColor","8b0000")
$WordsStyleAttribute12 = $WordsStyleNode12.SetAttribute("styleID","14")

$WordsStyleNode13 = $XmlDocument.CreateElement("WordsStyle")
$WordsStyleAttribute13 = $WordsStyleNode13.SetAttribute("name","DELIMINER2")
$WordsStyleAttribute13 = $WordsStyleNode13.SetAttribute("fontStyle","0")
$WordsStyleAttribute13 = $WordsStyleNode13.SetAttribute("fontName","")
$WordsStyleAttribute13 = $WordsStyleNode13.SetAttribute("bgColor","FFFFFF")
$WordsStyleAttribute13 = $WordsStyleNode13.SetAttribute("fgColor","000000")
$WordsStyleAttribute13 = $WordsStyleNode13.SetAttribute("styleID","15")

$WordsStyleNode14 = $XmlDocument.CreateElement("WordsStyle")
$WordsStyleAttribute14 = $WordsStyleNode14.SetAttribute("name","DELIMINER3")
$WordsStyleAttribute14 = $WordsStyleNode14.SetAttribute("fontStyle","0")
$WordsStyleAttribute14 = $WordsStyleNode14.SetAttribute("fontName","")
$WordsStyleAttribute14 = $WordsStyleNode14.SetAttribute("bgColor","FFFFFF")
$WordsStyleAttribute14 = $WordsStyleNode14.SetAttribute("fgColor","000000")
$WordsStyleAttribute14 = $WordsStyleNode14.SetAttribute("styleID","16")

$Null = $StylesNode.AppendChild($WordsStyleNode1)
$Null = $StylesNode.AppendChild($WordsStyleNode2)
$Null = $StylesNode.AppendChild($WordsStyleNode3)
$Null = $StylesNode.AppendChild($WordsStyleNode4)
$Null = $StylesNode.AppendChild($WordsStyleNode5)
$Null = $StylesNode.AppendChild($WordsStyleNode6)
$Null = $StylesNode.AppendChild($WordsStyleNode7)
$Null = $StylesNode.AppendChild($WordsStyleNode8)
$Null = $StylesNode.AppendChild($WordsStyleNode9)
$Null = $StylesNode.AppendChild($WordsStyleNode10)
$Null = $StylesNode.AppendChild($WordsStyleNode11)
$Null = $StylesNode.AppendChild($WordsStyleNode12)
$Null = $StylesNode.AppendChild($WordsStyleNode13)
$Null = $StylesNode.AppendChild($WordsStyleNode14)

$Null = $UserLangNode.AppendChild($StylesNode)

$Null = $RootNode.AppendChild($UserLangNode)
$Null = $XmlDocument.AppendChild($RootNode)
$XmlDocument.Save($ExportFilePath)

$NewContent = Get-Content $ExportFilePath | Foreach-Object {$_ -replace "&", "&" -replace "<", "<" -replace ">", ">"} 
$NewContent | Set-Content $ExportFilePath

The current version of the above code is in the Git repository at this link: NppPowershellLanguageSupport.ps1.

Microsoft Office Visio 2007

Well, at the end of this preparatory stage, it remains to install the Diagram Editor for Windows: Microsoft Office Visio 2007 Professional x86. This will require an image of this product version: en_office_visio_professional_2007_cd_x12-19212.iso. The image is recorded on a disc and is present in the drive. Automatic installation requires a small .xml file with a few parameters.

<?xml version="1.0"?>
<Configuration Product="Professional">
  <Display Level="None" CompletionNotice="no" SuppressModal="yes" AcceptEula="yes" />
  <PIDKEY Value="12345-ABCDE-67890-FGHIJ-KLMNO" />
</Configuration>

With the help of the following PowerShell code, we will create this file and perform an automatic installation. Also, in the code below, there are settings that disable the appearance of the Welcome dialog when Microsoft Office is first launched.

#######################################################################
#
# Powershell script for Silent Deploy Microsoft Visio 2007 Professional
#
# Script for Silent Deploy Microsoft Visio 2007 Professional.
# Script create xml file Acme.xml in $env:TEMP directory.
# Then script run Microsoft Visio 2007 Professional Setup.exe
# from en_office_visio_professional_2007_cd_x12-19212.iso with 
# parameter /Config $env:TEMP\Acme.xml.
# Afrer Silent Deploy file Acme.xml in $env:TEMP directory will be delete.
#  
# Version:        0.1
# Author:         Andrii Romanenko
# Website:        blogs.airra.net
# Creation Date:  12.09.2007
# Purpose/Change: Initial script development
#
# Run:
#   
# .\MsVisio2007ProSilentDeploy.ps1
#
#######################################################################

# Create Acme.xml in $env:TEMP directory.
$ExportFilePath = "$env:TEMP\Acme.xml"
$ProductKey = "12345-ABCDE-67890-FGHIJ-KLMNO"

$XmlDocument = New-Object System.Xml.XmlDocument
$xmlDeclaration = $XmlDocument.CreateXmlDeclaration("1.0",$Null,$Null)
$Null = $XmlDocument.AppendChild($xmlDeclaration)
$RootNode = $XmlDocument.CreateElement("Configuration")
$RootNodeAttribute = $RootNode.SetAttribute("Product","Professional")

$DisplayNode = $XmlDocument.CreateElement("Display")
$DisplayAttribute = $DisplayNode.SetAttribute("Level","None")
$DisplayAttribute = $DisplayNode.SetAttribute("CompletionNotice","no")
$DisplayAttribute = $DisplayNode.SetAttribute("SuppressModal","yes")
$DisplayAttribute = $DisplayNode.SetAttribute("AcceptEula","yes")

$PIDKEYNode = $XmlDocument.CreateElement("PIDKEY")
$PIDKEYAttribute = $PIDKEYNode.SetAttribute("Value",$ProductKey)

$Null = $RootNode.AppendChild($DisplayNode)
$Null = $RootNode.AppendChild($PIDKEYNode)
$Null = $XmlDocument.AppendChild($RootNode)
$XmlDocument.Save($ExportFilePath)

# Begin Silent Deploy Microsoft Visio 2007 Professional
$Message = "Begin Silent Setup Microsoft Visio 2007 Professional"
Write-Host -ForegroundColor Green $Message

$ISOPath = "E:\" 
$Params = " /config " + $env:TEMP + "\Acme.xml" 
$Command = $ISOPath + "Setup.exe" + $Params

Invoke-Expression $Command 
 
Write-Host "." -NoNewline
Start-Sleep -Seconds 60

# Checking if the application installation was successful 
Do {
         Write-Host "." -NoNewline
         Start-Sleep -Seconds 10
    } Until(Get-EventLog -LogName Application -Newest 10 | Where-Object {$_.Message -Like "*Microsoft Office Visio Professional 2007*Installation*successfully*"})

$Message = "`nSilent Setup Microsoft Visio 2007 Professional Succesfully!"
Write-Host -ForegroundColor Green $Message

# Disable the Office 2007 Welcome screen
Set-Location HKCU:
New-Item -Path "Software\Microsoft\Office\12.0\Common\" -Name "General" | Out-Null
New-ItemProperty -Path "Software\Microsoft\Office\12.0\Common\General" -Name "ShownOptIn" -Value 00000001 -PropertyType DWORD | Out-Null

$Message = "`nDisable the Office 2007 Welcome screen Succesfully!"
Write-Host -ForegroundColor Green $Message

#Removing Acme.xml
Set-Location c:
Remove-Item -Path ($env:TEMP+ "\Acme.xml") -Force

$Message = "`nRemoving Acme.xml Succesfully!"
Write-Host -ForegroundColor Green $Message

The current version of the above code is in the Git repository at this link: MsVisio2007ProSilentDeploy.ps1.

Brief Summary


Since all the necessary tools are already established, you can proceed to the most interesting stage: Working with Visio from the PowerShell environment.

But that will be discussed in the next publication.

See you in a few days.
Sincerely, AIRRA!

Posted in Architecture, Code, Design, Programming | Tagged , , , , , , , , , , , , , , , | Leave a comment