Link - add Powershell script with Primalform

Hi

I have a power shell script that i want to add to PrimalForm. I would like to Browse for csv file submit and generate output in display window.  Since, CSV file is already selected and displayed. i would like to click on second Submit button "Generate Device Count Per Location" and  generate output count per location.

I don't know how to link POWERSHELL with PRIMALFORM

The problem is i am new to PrimalForm and I need help.

Thx, M
Generate-Device-Count-per-location.txt
Primal-Form-table.png
PrimalForm.ps1.txt
TotalpagecountforMarch.csv
New.pff.txt
michalek19Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy LidbetterCommented:
Hi michalek,

Are you still looking for help on this issue?

Regards

Guy
0
michalek19Author Commented:
Yes, perhaps there are some gurus with Visual Basic experience and PS script
0
Guy LidbetterCommented:
Hi Michalek...  

I have had a look and is this the kind of thing you are looking for?

Save it as a PS1 and just run it.

#Generated Form Function
function GenerateForm {
########################################################################
# Code Generated By: SAPIEN Technologies PrimalForms (Community Edition) v1.0.6.0
# Generated On: 6/3/2015 4:03 PM
# Generated By: Microsoft
########################################################################

#region Import the Assemblies
[reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null
[reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null
#endregion

#region Generated Form Objects
$form1 = New-Object System.Windows.Forms.Form
$GenDevSubmit = New-Object System.Windows.Forms.Button
$label3 = New-Object System.Windows.Forms.Label
$OutputWindow = New-Object System.Windows.Forms.RichTextBox
$Filepath = New-Object System.Windows.Forms.RichTextBox
$ReptPreClear = New-Object System.Windows.Forms.Button
$ReptPreSubmit = New-Object System.Windows.Forms.Button
$ReptPreBrowser = New-Object System.Windows.Forms.Button
$label2 = New-Object System.Windows.Forms.Label
$openFileDialog1 = New-Object System.Windows.Forms.OpenFileDialog
$InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState
#endregion Generated Form Objects

#----------------------------------------------
#Generated Event Script Blocks
#----------------------------------------------
#Provide Custom Code for events specified in PrimalForms.
$ReptPreClear_OnClick= 
{
#TODO: Place custom script here
$InputFile = ""
$Filepath.Text = ""
$OutputWindow.Text = ""

}

$handler_openFileDialog1_FileOk= 
{
#TODO: Place custom script here

}

$ReptPreBrowser_OnClick= 
{
$openfiledialog1.ShowDialog()

$script:my_file = $openfiledialog1.FileName
		
$Filepath.Text = $my_file

}

$ReptPreSubmit_OnClick= 
{
#TODO: Place custom script here
$InputFile = $Filepath.Text
$Software = Get-Content $InputFile | Select -Skip 12
$Software[0] = "NullCol" + $Software[0]
$Software = $Software | ConvertFrom-CSV

# Group and display count of printer models
$output = $Software | Group-Object "Device Model" | Where {$_.Name.Trim() -ne ''} | Sort Count -Descending | Select Name, Count | out-string  #| Format-Table -AutoSize
$OutputWindow.Text = $output

}

$GenDevSubmit_OnClick= 
{
#TODO: Place custom script here
$InputFile = $Filepath.Text
$Software = Get-Content $InputFile | Select -Skip 12
$Software[0] = "NullCol" + $Software[0]
$Software = $Software | ConvertFrom-CSV

# List pages groups
$arrRanges = [ordered]@{
    '0 Pages' = '0'
    '1-50 Pages' = '1..50'
    '51-100 Pages' = '5..100'
    '101-1000 Pages' = '101..1000'
    '1001-5000 Pages' = '1001..5000'
    '5001-10000 Pages' = '5001..10000'
    '** Pages' = '**'
    }
$Totals = $null
$arrRanges.GetEnumerator() | ForEach {
    $Name = $_.Name
    If ($_.Value -eq '**') {
        $Expression = "`$Totals += `$Software | Where {`$_.Total -eq '$($_.Value)'} | Select @{n='Name';e={'$Name'}},@{n='PageCount';e={`$_.Total}}"
    } Else {
        $Expression = "`$Totals += `$Software | Where {`$_.Total -ne '**' -and [int]`$_.Total -in $($_.Value)} | Select @{n='Name';e={'$Name'}},@{n='PageCount';e={`$_.Total}}"
    }
    Invoke-Expression $Expression
}
$output = $Totals | Group Name | Select Name,Count | out-string #| Format-Table -AutoSize
$OutputWindow.Text = $output

}

$OnLoadForm_StateCorrection=
{#Correct the initial state of the form to prevent the .Net maximized form issue
	$form1.WindowState = $InitialFormWindowState
}

#----------------------------------------------
#region Generated Form Code
$form1.Text = "Primal Form"
$form1.Name = "form1"
$form1.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 1215
$System_Drawing_Size.Height = 886
$form1.ClientSize = $System_Drawing_Size

$GenDevSubmit.TabIndex = 8
$GenDevSubmit.Name = "GenDevSubmit"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 75
$System_Drawing_Size.Height = 23
$GenDevSubmit.Size = $System_Drawing_Size
$GenDevSubmit.UseVisualStyleBackColor = $True

$GenDevSubmit.Text = "Submit"

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 1
$System_Drawing_Point.Y = 139
$GenDevSubmit.Location = $System_Drawing_Point
$GenDevSubmit.DataBindings.DefaultDataSourceUpdateMode = 0
$GenDevSubmit.add_Click($GenDevSubmit_OnClick)

$form1.Controls.Add($GenDevSubmit)

################################################################################

$label3.TabIndex = 6
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 272
$System_Drawing_Size.Height = 23
$label3.Size = $System_Drawing_Size
$label3.Text = "Generate Device Count per location"

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 1
$System_Drawing_Point.Y = 113
$label3.Location = $System_Drawing_Point
$label3.DataBindings.DefaultDataSourceUpdateMode = 0
$label3.Name = "label3"

$form1.Controls.Add($label3)

################################################################################

$OutputWindow.Name = "Output"
$OutputWindow.Font = "Lucida Console"
$OutputWindow.Text = ""
$OutputWindow.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 309
$System_Drawing_Point.Y = 110
$OutputWindow.Location = $System_Drawing_Point
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 852
$System_Drawing_Size.Height = 666
$OutputWindow.Size = $System_Drawing_Size
$OutputWindow.TabIndex = 5

$form1.Controls.Add($OutputWindow)

################################################################################

$Filepath.Name = "Filepath"
$Filepath.Text = ""
$Filepath.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 309
$System_Drawing_Point.Y = 45
$Filepath.Location = $System_Drawing_Point
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 402
$System_Drawing_Size.Height = 28
$Filepath.Size = $System_Drawing_Size
$Filepath.TabIndex = 4

$form1.Controls.Add($Filepath)

################################################################################

$ReptPreClear.TabIndex = 3
$ReptPreClear.Name = "ReptPreClear"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 75
$System_Drawing_Size.Height = 23
$ReptPreClear.Size = $System_Drawing_Size
$ReptPreClear.UseVisualStyleBackColor = $True

$ReptPreClear.Text = "Clear"

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 198
$System_Drawing_Point.Y = 45
$ReptPreClear.Location = $System_Drawing_Point
$ReptPreClear.DataBindings.DefaultDataSourceUpdateMode = 0
$ReptPreClear.add_Click($ReptPreClear_OnClick)

$form1.Controls.Add($ReptPreClear)

################################################################################

$ReptPreSubmit.TabIndex = 2
$ReptPreSubmit.Name = "ReptPreSubmit"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 75
$System_Drawing_Size.Height = 23
$ReptPreSubmit.Size = $System_Drawing_Size
$ReptPreSubmit.UseVisualStyleBackColor = $True

$ReptPreSubmit.Text = "Submit"

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 98
$System_Drawing_Point.Y = 45
$ReptPreSubmit.Location = $System_Drawing_Point
$ReptPreSubmit.DataBindings.DefaultDataSourceUpdateMode = 0
$ReptPreSubmit.add_Click($ReptPreSubmit_OnClick)

$form1.Controls.Add($ReptPreSubmit)

################################################################################

$ReptPreBrowser.TabIndex = 1
$ReptPreBrowser.Name = "ReptPreBrowser"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 75
$System_Drawing_Size.Height = 23
$ReptPreBrowser.Size = $System_Drawing_Size
$ReptPreBrowser.UseVisualStyleBackColor = $True

$ReptPreBrowser.Text = "Browse"

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 1
$System_Drawing_Point.Y = 45
$ReptPreBrowser.Location = $System_Drawing_Point
$ReptPreBrowser.DataBindings.DefaultDataSourceUpdateMode = 0
$ReptPreBrowser.add_Click($ReptPreBrowser_OnClick)

$form1.Controls.Add($ReptPreBrowser)

###############################################################################

$label2.TabIndex = 0
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 231
$System_Drawing_Size.Height = 23
$label2.Size = $System_Drawing_Size
$label2.Text = "Print Metrics Report Preview"

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 1
$System_Drawing_Point.Y = 19
$label2.Location = $System_Drawing_Point
$label2.DataBindings.DefaultDataSourceUpdateMode = 0
$label2.Name = "label2"

$form1.Controls.Add($label2)

################################################################################


$openFileDialog1.ShowHelp = $True
$openFileDialog1.FileName = "openFileDialog1"
$openFileDialog1.add_FileOk($handler_openFileDialog1_FileOk)

#endregion Generated Form Code

#Save the initial state of the form
$InitialFormWindowState = $form1.WindowState
#Init the OnLoad event to correct the initial state of the form
$form1.add_Load($OnLoadForm_StateCorrection)
#Show the Form
$form1.ShowDialog()| Out-Null

} #End Function

#Call the Function
GenerateForm
    
       #Generated Form Function
function GenerateForm {
########################################################################
# Code Generat
}

Open in new window

0
What were the top attacks of Q1 2018?

The Threat Lab team analyzes data from WatchGuard’s Firebox Feed, internal and partner threat intelligence, and a research honeynet, to provide insightful analysis about the top threats on the Internet. Check out our Q1 2018 report for smart, practical security advice today!

michalek19Author Commented:
This look much much better.
However, i am getting only this "PrimalFormView" - check attachment.

I am not getting any display of this

List pages groups
$arrRanges = [ordered]@{
    '0 Pages' = '0'
    '1-50 Pages' = '1..50'
    '51-100 Pages' = '5..100'
    '101-1000 Pages' = '101..1000'
    '1001-5000 Pages' = '1001..5000'
    '5001-10000 Pages' = '5001..10000'
    '** Pages' = '**'
    }
------------------------------------------------------------
Here is an error:

Unable to find type [ordered]: make sure that the assembly containing this type is loaded.
At C:\Users\adm-rejman\desktop\fr\PrinterMetrics.ps1:80 char:23
+ $arrRanges = [ordered] <<<< @{
    + CategoryInfo          : InvalidOperation: (ordered:String) [], RuntimeException
    + FullyQualifiedErrorId : TypeNotFound

You cannot call a method on a null-valued expression.
At C:\Users\adm-rejman\desktop\fr\PrinterMetrics.ps1:90 char:25
+ $arrRanges.GetEnumerator <<<< () | ForEach {
    + CategoryInfo          : InvalidOperation: (GetEnumerator:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

Unable to find type [ordered]: make sure that the assembly containing this type is loaded.
At C:\Users\adm-rejman\desktop\fr\PrinterMetrics.ps1:80 char:23
+ $arrRanges = [ordered] <<<< @{
    + CategoryInfo          : InvalidOperation: (ordered:String) [], RuntimeException
    + FullyQualifiedErrorId : TypeNotFound

You cannot call a method on a null-valued expression.
At C:\Users\adm-rejman\desktop\fr\PrinterMetrics.ps1:90 char:25
+ $arrRanges.GetEnumerator <<<< () | ForEach {
    + CategoryInfo          : InvalidOperation: (GetEnumerator:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

Unable to find type [ordered]: make sure that the assembly containing this type is loaded.
At C:\Users\adm-rejman\desktop\fr\PrinterMetrics.ps1:80 char:23
+ $arrRanges = [ordered] <<<< @{
    + CategoryInfo          : InvalidOperation: (ordered:String) [], RuntimeException
    + FullyQualifiedErrorId : TypeNotFound

You cannot call a method on a null-valued expression.
At C:\Users\adm-rejman\desktop\fr\PrinterMetrics.ps1:90 char:25
+ $arrRanges.GetEnumerator <<<< () | ForEach {
    + CategoryInfo          : InvalidOperation: (GetEnumerator:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

Unable to find type [ordered]: make sure that the assembly containing this type is loaded.
At C:\Users\adm-rejman\desktop\fr\PrinterMetrics.ps1:80 char:23
+ $arrRanges = [ordered] <<<< @{
    + CategoryInfo          : InvalidOperation: (ordered:String) [], RuntimeException
    + FullyQualifiedErrorId : TypeNotFound

You cannot call a method on a null-valued expression.
At C:\Users\adm-rejman\desktop\fr\PrinterMetrics.ps1:90 char:25
+ $arrRanges.GetEnumerator <<<< () | ForEach {
    + CategoryInfo          : InvalidOperation: (GetEnumerator:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
0
Guy LidbetterCommented:
What version of powershell are you running?

The [ordered] type was only added in V3 with the .NET 4 assembly.

Run this to see which version you are on:

$PSVersionTable

Open in new window

The PSversion is obviously the Powershell version, and the CLRVersion (Common Language Runtime) correlates with the .NET version. It should be 4.xxx
0
michalek19Author Commented:
This what i have

Name                           Value
----                           -----
CLRVersion                     2.0.50727.5472
BuildVersion                   6.1.7601.17514
PSVersion                      2.0
WSManStackVersion              2.0
PSCompatibleVersions           {1.0, 2.0}
SerializationVersion           1.1.0.1
PSRemotingProtocolVersion      2.1
0
Guy LidbetterCommented:
You are on Powershell 2.

Download and install Powershell 3 at a minimum, preferably Powershell 4 as 5 is on its way...

There are quite a lot of changes, especially with the code as the newer versions leverage .net 4 and above which has a lot more functions.

[order] being one of them...
0
michalek19Author Commented:
It works like charm after installing PS V4

Can you help?
I would like to add  two more functions

Function 1:
Total page count (column I)  per regional  (AMER, APAC, EMEA)

Function 2:
Compare two Total page counts from two different  csv files

I know  i didnot create another buttons but would you be able to help me with this.
I will really appreciate

Thx, M
0
Guy LidbetterCommented:
No Problems M,

I'll be happy to help out.

Regards

Guy
0
michalek19Author Commented:
Please let me know if i need to add couple more buttons to primalform
0
Guy LidbetterCommented:
I'll do that with code, no probs.
0
michalek19Author Commented:
Let me know if you need any more information

Thank you
0
Guy LidbetterCommented:
Hi M,

I played around with it a bit, changed some formatting to make it more intuitive and made the code more readable.
I also added some comments so you can understand whats happening as well.

Hows this looking?

#Generated Form Function
function GenerateForm {
########################################################################
# Code Generated By: SAPIEN Technologies PrimalForms (Community Edition) v1.0.6.0
# Generated On: 6/3/2015 4:03 PM
# Generated By: Microsoft
# Modified and Formatted for Readability By: Guy Lidbetter
########################################################################

#region Import the Assemblies
[reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null
[reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null
#endregion

#region Generated Form Objects
$PrintEvalRep = New-Object System.Windows.Forms.Form
$PgCntBrkdwnBut = New-Object System.Windows.Forms.Button
$ReportHeader = New-Object System.Windows.Forms.Label
$OutputWindow = New-Object System.Windows.Forms.RichTextBox
$Filepath = New-Object System.Windows.Forms.RichTextBox
$ReptPreClear = New-Object System.Windows.Forms.Button
$PrintTypeBut = New-Object System.Windows.Forms.Button
$FileBrowseBut = New-Object System.Windows.Forms.Button
$RegPgCntBut = New-Object System.Windows.Forms.Button
$PgCntCompareBut = New-Object System.Windows.Forms.Button
$FileCompareBut = New-Object System.Windows.Forms.Button
$FileSelectHeader = New-Object System.Windows.Forms.Label
$EvalCsvFileSelection = New-Object System.Windows.Forms.OpenFileDialog
$CompCsvFileSelection = New-Object System.Windows.Forms.OpenFileDialog
$CompFilepath = New-Object System.Windows.Forms.Label
$InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState
#endregion Generated Form Objects

#############################################################################
#This section pre defines the functions that occur on pressing buttons.
#############################################################################

#----------------------------------------------
#Generated Event Script Blocks
#----------------------------------------------
#Provide Custom Code for events specified in PrimalForms.
$ReptPreClear_OnClick= 
{
#TODO: Place custom script here
#Clear file selection and output screen Function
$InputFile = ""
$Filepath.Text = ""
$CompFilepath.Text = ""
$OutputWindow.Text = ""

}

$handler_EvalCsvFileSelection_FileOk= 
{
#TODO: Place custom script here

}

$FileBrowseBut_OnClick= 
{
$EvalCsvFileSelection.ShowDialog()

$script:my_file = $EvalCsvFileSelection.FileName
		
$Filepath.Text = $my_file

}

$handler_CompCsvFileSelection_FileOk= 
{
#TODO: Place custom script here

}

$CompFileBrowseBut_OnClick= 
{
$CompCsvFileSelection.ShowDialog()

$script:my_file = $CompCsvFileSelection.FileName
		
$CompFilepath.Text = $my_file

}

$PrintTypeBut_OnClick= {
	#TODO: Place custom script here
	#Printer Type Report Function
	$InputFile = $Filepath.Text
	Try {
		$PathValid = Test-Path $InputFile
	}
	Catch{}
	IF ($PathValid) {
		$WorkingFile = Get-Content $InputFile | Select -Skip 12
		$WorkingFile[0] = "NullCol" + $WorkingFile[0]
		$WorkingFile = $WorkingFile | ConvertFrom-CSV

		# Group and display count of printer models
		$output = $WorkingFile | Group-Object "Device Model" | Where {$_.Name.Trim() -ne ''} | Sort Count -Descending | Select Name, Count | out-string  #| Format-Table -AutoSize
		$OutputWindow.Text = $output
	}
	ELSE {
		$OutputWindow.Text = "Please Select a valid file"
	}
}

$PgCntBrkdwnBut_OnClick= {
	#TODO: Place custom script here
	#Page Count Breakdown Function
	$InputFile = $Filepath.Text
	Try {
		$PathValid = Test-Path $InputFile
	}
	Catch{}
	IF ($PathValid) {
		$WorkingFile = Get-Content $InputFile | Select -Skip 12
		$WorkingFile[0] = "NullCol" + $WorkingFile[0]
		$WorkingFile = $WorkingFile | ConvertFrom-CSV

		# List pages groups
		$arrRanges = [ordered]@{
			'0 Pages' = '0'
			'1-50 Pages' = '1..50'
			'51-100 Pages' = '5..100'
			'101-1000 Pages' = '101..1000'
			'1001-5000 Pages' = '1001..5000'
			'5001-10000 Pages' = '5001..10000'
			'** Pages' = '**'
			}
		$Totals = $null
		$arrRanges.GetEnumerator() | ForEach {
			$Name = $_.Name
			If ($_.Value -eq '**') {
				$Expression = "`$Totals += `$WorkingFile | Where {`$_.Total -eq '$($_.Value)'} | Select @{n='Name';e={'$Name'}},@{n='PageCount';e={`$_.Total}}"
			} Else {
				$Expression = "`$Totals += `$WorkingFile | Where {`$_.Total -ne '**' -and [int]`$_.Total -in $($_.Value)} | Select @{n='Name';e={'$Name'}},@{n='PageCount';e={`$_.Total}}"
			}
			Invoke-Expression $Expression
		}
		$output = $Totals | Group Name | Select Name,Count | out-string #| Format-Table -AutoSize
		$OutputWindow.Text = $output
	}
	ELSE {
		$OutputWindow.Text = "Please Select a valid file"
	}
}

$RegPgCntBut_OnClick= {
	#TODO: Place custom script here
	#Regional Page Count Report Function
	$InputFile = $Filepath.Text
	Try {
		$PathValid = Test-Path $InputFile
	}
	Catch{}
	IF ($PathValid) {
		$WorkingFile = Get-Content $InputFile | Select -Skip 12
		$WorkingFile[0] = "NullCol" + $WorkingFile[0]
		$WorkingFile = $WorkingFile | ConvertFrom-CSV
		$WorkingFile = $WorkingFile | Where-Object {$_.Total -ge 0}
		$Result = @()	
		$groupreport = $WorkingFile | Group-Object -Property "Device Groups" -AsHashTable
		$Array = @{}
		$groupreport.keys | % {$Array += @{$_ = ($groupreport[$_] | measure-object -Property Total -sum)}}
		$Array.keys | Foreach {
			$RegionID = $_
			$RegionCount = $Array["$RegionID"].Sum
			$RegionAdd = New-Object PSObject -Property @{
				Region = $RegionID
				"Page Count" = $RegionCount
			}
		$Result += $RegionAdd
		}
		$Output = $Result | FT * | out-string
		$OutputWindow.Text = $Output
	}
	ELSE {
		$OutputWindow.Text = "Please Select a valid file"
	}
}

$FileCompareBut_OnClick= {
	#TODO: Place custom script here
	#Regional Page Count Report Function
	#Get file to compare
	$CompCsvFileSelection.ShowDialog()
	$script:my_file = $CompCsvFileSelection.FileName
	$CompFilepath.Text = $my_file
	
	#Compare File
	$InputFile = $Filepath.Text
	$CompFile = $CompFilepath.Text
	$CompFilepath.Text = "File Being Compared: " + $Compfile
	Try {
		$PathValid = Test-Path $InputFile
	}
	Catch{}
	IF ($PathValid) {
		$WorkingFile1 = Get-Content $InputFile | Select -Skip 12
		$WorkingFile1[0] = "NullCol" + $WorkingFile1[0]
		$WorkingFile1 = $WorkingFile1 | ConvertFrom-CSV
		$WorkingFile1 = $WorkingFile1 | Where-Object {$_.Total -ge 0}
		$WorkingFile2 = Get-Content $CompFile | Select -Skip 12
		$WorkingFile2[0] = "NullCol" + $WorkingFile2[0]
		$WorkingFile2 = $WorkingFile2 | ConvertFrom-CSV
		$WorkingFile2 = $WorkingFile2 | Where-Object {$_.Total -ge 0}
		
		$FileTotals = @()
		
		[Decimal]$File1Total = 0
		[Decimal]$File2Total = 0
		[Decimal]$Difference = 0
		
		$WorkingFile1 | Foreach {$File1Total = $File1Total + $_.Total}
		$WorkingFile2 | Foreach {$File2Total = $File2Total + $_.Total}
		$Difference = $File1Total - $File2Total
		
		$FileTotals = New-Object PSObject -Property @{
				"File 1 Total Page Count" = $File1Total
				"File 2 Total Page Count" = $File2Total
				"Difference" = $Difference
			}
		
		$Output = $FileTotals | Select "File 1 Total Page Count", "File 2 Total Page Count", "Difference" | out-string
		$OutputWindow.Text = $Output
	}
	ELSE {
		$OutputWindow.Text = "Please Select a valid file"
	}
}
#############################################################################
#Below is the creation of the Form, Buttons, Text and layout
#############################################################################
$OnLoadForm_StateCorrection=
{#Correct the initial state of the form to prevent the .Net maximized form issue
	$PrintEvalRep.WindowState = $InitialFormWindowState
}

#----------------------------------------------
#region Generated Form Code
$PrintEvalRep.Text = "Printer Report Evaluation"
$PrintEvalRep.Name = "PrintEvalRep"
$PrintEvalRep.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 1105
$System_Drawing_Size.Height = 825
$PrintEvalRep.ClientSize = $System_Drawing_Size

##############################################################################
# File Path Text Display Window

$Filepath.Name = "Filepath"
$Filepath.Text = ""
$Filepath.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 200
$System_Drawing_Point.Y = 45
$Filepath.Location = $System_Drawing_Point
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 450
$System_Drawing_Size.Height = 28
$Filepath.Size = $System_Drawing_Size
$Filepath.TabIndex = 4

$PrintEvalRep.Controls.Add($Filepath)

################################################################################
#Clear selection Button

$ReptPreClear.TabIndex = 3
$ReptPreClear.Name = "ReptPreClear"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 75
$System_Drawing_Size.Height = 23
$ReptPreClear.Size = $System_Drawing_Size
$ReptPreClear.UseVisualStyleBackColor = $True

$ReptPreClear.Text = "Clear"

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 90
$System_Drawing_Point.Y = 45
$ReptPreClear.Location = $System_Drawing_Point
$ReptPreClear.DataBindings.DefaultDataSourceUpdateMode = 0
$ReptPreClear.add_Click($ReptPreClear_OnClick)

$PrintEvalRep.Controls.Add($ReptPreClear)

################################################################################
#File Browse Button

$FileBrowseBut.TabIndex = 1
$FileBrowseBut.Name = "FileBrowseBut"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 75
$System_Drawing_Size.Height = 23
$FileBrowseBut.Size = $System_Drawing_Size
$FileBrowseBut.UseVisualStyleBackColor = $True

$FileBrowseBut.Text = "Browse"

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 1
$System_Drawing_Point.Y = 45
$FileBrowseBut.Location = $System_Drawing_Point
$FileBrowseBut.DataBindings.DefaultDataSourceUpdateMode = 0
$FileBrowseBut.add_Click($FileBrowseBut_OnClick)

$PrintEvalRep.Controls.Add($FileBrowseBut)

###############################################################################
#Compare File Selection Header Text above Output Box when selected

$CompFilePath.TabIndex = 0
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 500
$System_Drawing_Size.Height = 23
$CompFilePath.Size = $System_Drawing_Size
$CompFilePath.Text = ""

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 200
$System_Drawing_Point.Y = 85
$CompFilePath.Location = $System_Drawing_Point
$CompFilePath.DataBindings.DefaultDataSourceUpdateMode = 0
$CompFilePath.Name = "CompFilePath"

$PrintEvalRep.Controls.Add($CompFilePath)

###############################################################################
#File Selection Header Text

$FileSelectHeader.TabIndex = 0
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 231
$System_Drawing_Size.Height = 23
$FileSelectHeader.Size = $System_Drawing_Size
$FileSelectHeader.Text = "Please Select a file to evaluate"

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 1
$System_Drawing_Point.Y = 19
$FileSelectHeader.Location = $System_Drawing_Point
$FileSelectHeader.DataBindings.DefaultDataSourceUpdateMode = 0
$FileSelectHeader.Name = "FileSelectHeader"

$PrintEvalRep.Controls.Add($FileSelectHeader)

################################################################################
#Printer Type report button

$PrintTypeBut.TabIndex = 2
$PrintTypeBut.Name = "PrintTypeBut"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 165
$System_Drawing_Size.Height = 23
$PrintTypeBut.Size = $System_Drawing_Size
$PrintTypeBut.UseVisualStyleBackColor = $True

$PrintTypeBut.Text = "Printer Type Breakdown"

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 1
$System_Drawing_Point.Y = 140
$PrintTypeBut.Location = $System_Drawing_Point
$PrintTypeBut.DataBindings.DefaultDataSourceUpdateMode = 0
$PrintTypeBut.add_Click($PrintTypeBut_OnClick)

$PrintEvalRep.Controls.Add($PrintTypeBut)

################################################################################
#Page Count Breakdown Button

$PgCntBrkdwnBut.TabIndex = 8
$PgCntBrkdwnBut.Name = "PgCntBrkdwnBut"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 165
$System_Drawing_Size.Height = 23
$PgCntBrkdwnBut.Size = $System_Drawing_Size
$PgCntBrkdwnBut.UseVisualStyleBackColor = $True

$PgCntBrkdwnBut.Text = "Page Count Breakdown"

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 1
$System_Drawing_Point.Y = 170
$PgCntBrkdwnBut.Location = $System_Drawing_Point
$PgCntBrkdwnBut.DataBindings.DefaultDataSourceUpdateMode = 0
$PgCntBrkdwnBut.add_Click($PgCntBrkdwnBut_OnClick)

$PrintEvalRep.Controls.Add($PgCntBrkdwnBut)

################################################################################
#Regional Page Count Button

$RegPgCntBut.TabIndex = 8
$RegPgCntBut.Name = "RegPgCntBut"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 165
$System_Drawing_Size.Height = 23
$RegPgCntBut.Size = $System_Drawing_Size
$RegPgCntBut.UseVisualStyleBackColor = $True

$RegPgCntBut.Text = "Regional Page Count"

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 1
$System_Drawing_Point.Y = 200
$RegPgCntBut.Location = $System_Drawing_Point
$RegPgCntBut.DataBindings.DefaultDataSourceUpdateMode = 0
$RegPgCntBut.add_Click($RegPgCntBut_OnClick)

$PrintEvalRep.Controls.Add($RegPgCntBut)

################################################################################
#CSV File Compare Button

$FileCompareBut.TabIndex = 8
$FileCompareBut.Name = "FileCompareBut"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 165
$System_Drawing_Size.Height = 23
$FileCompareBut.Size = $System_Drawing_Size
$FileCompareBut.UseVisualStyleBackColor = $True

$FileCompareBut.Text = "Total Page Count Comparison"

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 1
$System_Drawing_Point.Y = 230
$FileCompareBut.Location = $System_Drawing_Point
$FileCompareBut.DataBindings.DefaultDataSourceUpdateMode = 0
$FileCompareBut.add_Click($FileCompareBut_OnClick)

$PrintEvalRep.Controls.Add($FileCompareBut)

################################################################################
#Options to Select Report Header

$ReportHeader.TabIndex = 6
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 180
$System_Drawing_Size.Height = 23
$ReportHeader.Size = $System_Drawing_Size
$ReportHeader.Text = "Please Select Report"

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 1
$System_Drawing_Point.Y = 113
$ReportHeader.Location = $System_Drawing_Point
$ReportHeader.DataBindings.DefaultDataSourceUpdateMode = 0
$ReportHeader.Name = "ReportHeader"

$PrintEvalRep.Controls.Add($ReportHeader)

################################################################################
#Output Text Box Window

$OutputWindow.Name = "Output"
$OutputWindow.Font = "Lucida Console"
$OutputWindow.Text = ""
$OutputWindow.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 200
$System_Drawing_Point.Y = 110
$OutputWindow.Location = $System_Drawing_Point
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 900
$System_Drawing_Size.Height = 700
$OutputWindow.Size = $System_Drawing_Size
$OutputWindow.TabIndex = 5

$PrintEvalRep.Controls.Add($OutputWindow)

################################################################################
#File Browser to locate CSV for evaluation
$EvalCsvFileSelection.ShowHelp = $True
$EvalCsvFileSelection.FileName = ""
$EvalCsvFileSelection.filter = "CSV files (*.csv)| *.csv"
$EvalCsvFileSelection.add_FileOk($handler_EvalCsvFileSelection_FileOk)

################################################################################
#File Browser to locate CSV for evaluation
$CompCsvFileSelection.ShowHelp = $True
$CompCsvFileSelection.FileName = ""
$CompCsvFileSelection.filter = "CSV files (*.csv)| *.csv"
$CompCsvFileSelection.add_FileOk($handler_CompCsvFileSelection_FileOk)

#endregion Generated Form Code

#Save the initial state of the form
$InitialFormWindowState = $PrintEvalRep.WindowState
#Init the OnLoad event to correct the initial state of the form
$PrintEvalRep.add_Load($OnLoadForm_StateCorrection)
#Show the Form
$PrintEvalRep.ShowDialog()| Out-Null

} #End Function

#Call the Function
GenerateForm
    
       #Generated Form Function
function GenerateForm {
########################################################################
# Code Generat
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
michalek19Author Commented:
You are genius
I will recommend you to other users. I will keep in touch with you.

Again, thank you so much
0
michalek19Author Commented:
How hard would be to add additional "graph" to display total count by regional
0
Guy LidbetterCommented:
Hi M,

How do you want to display the info, i.e. what Kind of Chart are you looking for? Bar or Pie chart?
0
michalek19Author Commented:
Hi
I am looking for Bar chart to display total count by regional

Thx
0
Guy LidbetterCommented:
Hi M,

Sorry I got a bit caught up... This kind of thing?

#Generated Form Function
function GenerateForm {
########################################################################
# Code Generated By: SAPIEN Technologies PrimalForms (Community Edition) v1.0.6.0
# Generated On: 6/3/2015 4:03 PM
# Generated By: Microsoft
# Modified and Formatted for Readability By: Guy Lidbetter
########################################################################

#region Import the Assemblies
[reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null
[reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null
[Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms.DataVisualization") | Out-Null
#endregion

#region Generated Form Objects
$PrintEvalRep = New-Object System.Windows.Forms.Form
$PgCntBrkdwnBut = New-Object System.Windows.Forms.Button
$ReportHeader = New-Object System.Windows.Forms.Label
$OutputWindow = New-Object System.Windows.Forms.RichTextBox
$Filepath = New-Object System.Windows.Forms.RichTextBox
$ReptPreClear = New-Object System.Windows.Forms.Button
$PrintTypeBut = New-Object System.Windows.Forms.Button
$FileBrowseBut = New-Object System.Windows.Forms.Button
$RegPgCntBut = New-Object System.Windows.Forms.Button
$PgCntCompareBut = New-Object System.Windows.Forms.Button
$FileCompareBut = New-Object System.Windows.Forms.Button
$FileSelectHeader = New-Object System.Windows.Forms.Label
$EvalCsvFileSelection = New-Object System.Windows.Forms.OpenFileDialog
$CompCsvFileSelection = New-Object System.Windows.Forms.OpenFileDialog
$CompFilepath = New-Object System.Windows.Forms.Label
$InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState
$chart1 = New-object System.Windows.Forms.DataVisualization.Charting.Chart
$chartarea = New-Object System.Windows.Forms.DataVisualization.Charting.ChartArea
#endregion Generated Form Objects

#############################################################################
#This section pre defines the functions that occur on pressing buttons.
#############################################################################

#----------------------------------------------
#Generated Event Script Blocks
#----------------------------------------------
#Provide Custom Code for events specified in PrimalForms.
$ReptPreClear_OnClick= 
{
#TODO: Place custom script here
#Clear file selection and output screen Function
$Chart1.visible = $False
$OutputWindow.visible = $True
$InputFile = ""
$Filepath.Text = ""
$CompFilepath.Text = ""
$OutputWindow.Text = ""

}

$handler_EvalCsvFileSelection_FileOk= 
{
#TODO: Place custom script here

}

$FileBrowseBut_OnClick= 
{
$EvalCsvFileSelection.ShowDialog()

$script:my_file = $EvalCsvFileSelection.FileName
		
$Filepath.Text = $my_file

}

$handler_CompCsvFileSelection_FileOk= 
{
#TODO: Place custom script here

}

$CompFileBrowseBut_OnClick= 
{
$CompCsvFileSelection.ShowDialog()

$script:my_file = $CompCsvFileSelection.FileName
		
$CompFilepath.Text = $my_file

}

$PrintTypeBut_OnClick= {
	#TODO: Place custom script here
	#Printer Type Report Function
	$Chart1.visible = $False
	$OutputWindow.visible = $True
	$CompFilepath.Text = ""
	$InputFile = $Filepath.Text
	Try {
		$PathValid = Test-Path $InputFile
	}
	Catch{}
	IF ($PathValid) {
		$WorkingFile = Get-Content $InputFile | Select -Skip 12
		$WorkingFile[0] = "NullCol" + $WorkingFile[0]
		$WorkingFile = $WorkingFile | ConvertFrom-CSV

		# Group and display count of printer models
		$Output = $WorkingFile | Group-Object "Device Model" | Where {$_.Name.Trim() -ne ''} | Sort Count -Descending | Select Name, Count | Out-String  #| Format-Table -AutoSize
		$OutputWindow.Text = $Output
	}
	ELSE {
		$OutputWindow.Text = "Please Select a valid file"
	}
}

$PgCntBrkdwnBut_OnClick= {
	#TODO: Place custom script here
	#Page Count Breakdown Function
	$Chart1.visible = $False
	$OutputWindow.visible = $True
	$CompFilepath.Text = ""
	$InputFile = $Filepath.Text
	Try {
		$PathValid = Test-Path $InputFile
	}
	Catch{}
	IF ($PathValid) {
		$WorkingFile = Get-Content $InputFile | Select -Skip 12
		$WorkingFile[0] = "NullCol" + $WorkingFile[0]
		$WorkingFile = $WorkingFile | ConvertFrom-CSV

		# List pages groups
		$arrRanges = [ordered]@{
			'0 Pages' = '0'
			'1-50 Pages' = '1..50'
			'51-100 Pages' = '5..100'
			'101-1000 Pages' = '101..1000'
			'1001-5000 Pages' = '1001..5000'
			'5001-10000 Pages' = '5001..10000'
			'** Pages' = '**'
			}
		$Totals = $null
		$arrRanges.GetEnumerator() | ForEach {
			$Name = $_.Name
			If ($_.Value -eq '**') {
				$Expression = "`$Totals += `$WorkingFile | Where {`$_.Total -eq '$($_.Value)'} | Select @{n='Name';e={'$Name'}},@{n='PageCount';e={`$_.Total}}"
			} Else {
				$Expression = "`$Totals += `$WorkingFile | Where {`$_.Total -ne '**' -and [int]`$_.Total -in $($_.Value)} | Select @{n='Name';e={'$Name'}},@{n='PageCount';e={`$_.Total}}"
			}
			Invoke-Expression $Expression
		}
		$Output = $Totals | Group Name | Select Name,Count | Out-String #| Format-Table -AutoSize
		$OutputWindow.Text = $Output
	}
	ELSE {
		$OutputWindow.Text = "Please Select a valid file"
	}
}

$RegPgCntBut_OnClick= {
	#TODO: Place custom script here
	#Regional Page Count Report Function
	$chart1.Series["RegionalPages"].Points.clear()
	$CompFilepath.Text = ""
	$InputFile = $Filepath.Text
	Try {
		$PathValid = Test-Path $InputFile
	}
	Catch{}
	IF ($PathValid) {
		$WorkingFile = Get-Content $InputFile | Select -Skip 12
		$WorkingFile[0] = "NullCol" + $WorkingFile[0]
		$WorkingFile = $WorkingFile | ConvertFrom-CSV
		$WorkingFile = $WorkingFile | Where-Object {$_.Total -ge 0}
		$Result = @()	
		$groupreport = $WorkingFile | Group-Object -Property "Device Groups" -AsHashTable
		$Array = @{}
		$groupreport.keys | % {$Array += @{$_ = ($groupreport[$_] | measure-object -Property Total -sum)}}
		$Array.keys | Foreach {
			$RegionID = $_
			$RegionCount = $Array["$RegionID"].Sum
			$RegionAdd = New-Object PSObject -Property @{
				Region = $RegionID
				"Page Count" = $RegionCount
			}
		$Result += $RegionAdd
		}
		$Output = $Result | FT * | Out-String
		$OutputWindow.Text = $Output
		
		$DataSource = $Result
		$datasource | ForEach-Object {$chart1.Series["RegionalPages"].Points.addxy( $_.Region , ($_."Page Count")) }
		$OutputWindow.visible = $False
		$Chart1.visible = $True
		
	}
	ELSE {
		$OutputWindow.Text = "Please Select a valid file"
	}	
}

$FileCompareBut_OnClick= {
	#TODO: Place custom script here
	#Regional Page Count Report Function
	#Get file to compare
	$Chart1.visible = $False
	$OutputWindow.visible = $True
	$CompCsvFileSelection.ShowDialog()
	$script:my_file = $CompCsvFileSelection.FileName
	$CompFilepath.Text = $my_file
	
	#Compare File
	$InputFile = $Filepath.Text
	$CompFile = $CompFilepath.Text
	$CompFilepath.Text = "File Being Compared: " + $Compfile
	Try {
		$PathValid = Test-Path $InputFile
	}
	Catch{}
	IF ($PathValid) {
		$WorkingFile1 = Get-Content $InputFile | Select -Skip 12
		$WorkingFile1[0] = "NullCol" + $WorkingFile1[0]
		$WorkingFile1 = $WorkingFile1 | ConvertFrom-CSV
		$WorkingFile1 = $WorkingFile1 | Where-Object {$_.Total -ge 0}
		$WorkingFile2 = Get-Content $CompFile | Select -Skip 12
		$WorkingFile2[0] = "NullCol" + $WorkingFile2[0]
		$WorkingFile2 = $WorkingFile2 | ConvertFrom-CSV
		$WorkingFile2 = $WorkingFile2 | Where-Object {$_.Total -ge 0}
		
		$FileTotals = @()
		
		[Decimal]$File1Total = 0
		[Decimal]$File2Total = 0
		[Decimal]$Difference = 0
		
		$WorkingFile1 | Foreach {$File1Total = $File1Total + $_.Total}
		$WorkingFile2 | Foreach {$File2Total = $File2Total + $_.Total}
		$Difference = $File1Total - $File2Total
		
		$FileTotals = New-Object PSObject -Property @{
				"File 1 Total Page Count" = $File1Total
				"File 2 Total Page Count" = $File2Total
				"Difference" = $Difference
			}
		
		$Output = $FileTotals | Select "File 1 Total Page Count", "File 2 Total Page Count", "Difference" | Out-String
		$OutputWindow.Text = $Output
	}
	ELSE {
		$OutputWindow.Text = "Please Select a valid file"
	}
}
#############################################################################
#Below is the creation of the Form, Buttons, Text and layout
#############################################################################
$OnLoadForm_StateCorrection=
{#Correct the initial state of the form to prevent the .Net maximized form issue
	$PrintEvalRep.WindowState = $InitialFormWindowState
}

#----------------------------------------------
#region Generated Form Code
$PrintEvalRep.Text = "Printer Report Evaluation"
$PrintEvalRep.Name = "PrintEvalRep"
$PrintEvalRep.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 1105
$System_Drawing_Size.Height = 825
$PrintEvalRep.ClientSize = $System_Drawing_Size

##############################################################################
# File Path Text Display Window

$Filepath.Name = "Filepath"
$Filepath.Text = ""
$Filepath.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 200
$System_Drawing_Point.Y = 45
$Filepath.Location = $System_Drawing_Point
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 450
$System_Drawing_Size.Height = 28
$Filepath.Size = $System_Drawing_Size
$Filepath.TabIndex = 4

$PrintEvalRep.Controls.Add($Filepath)

################################################################################
#Clear selection Button

$ReptPreClear.TabIndex = 3
$ReptPreClear.Name = "ReptPreClear"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 75
$System_Drawing_Size.Height = 23
$ReptPreClear.Size = $System_Drawing_Size
$ReptPreClear.UseVisualStyleBackColor = $True

$ReptPreClear.Text = "Clear"

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 90
$System_Drawing_Point.Y = 45
$ReptPreClear.Location = $System_Drawing_Point
$ReptPreClear.DataBindings.DefaultDataSourceUpdateMode = 0
$ReptPreClear.add_Click($ReptPreClear_OnClick)

$PrintEvalRep.Controls.Add($ReptPreClear)

################################################################################
#File Browse Button

$FileBrowseBut.TabIndex = 1
$FileBrowseBut.Name = "FileBrowseBut"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 75
$System_Drawing_Size.Height = 23
$FileBrowseBut.Size = $System_Drawing_Size
$FileBrowseBut.UseVisualStyleBackColor = $True

$FileBrowseBut.Text = "Browse"

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 1
$System_Drawing_Point.Y = 45
$FileBrowseBut.Location = $System_Drawing_Point
$FileBrowseBut.DataBindings.DefaultDataSourceUpdateMode = 0
$FileBrowseBut.add_Click($FileBrowseBut_OnClick)

$PrintEvalRep.Controls.Add($FileBrowseBut)

###############################################################################
#Compare File Selection Header Text above Output Box when selected

$CompFilePath.TabIndex = 0
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 500
$System_Drawing_Size.Height = 23
$CompFilePath.Size = $System_Drawing_Size
$CompFilePath.Text = ""

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 200
$System_Drawing_Point.Y = 85
$CompFilePath.Location = $System_Drawing_Point
$CompFilePath.DataBindings.DefaultDataSourceUpdateMode = 0
$CompFilePath.Name = "CompFilePath"

$PrintEvalRep.Controls.Add($CompFilePath)

###############################################################################
#File Selection Header Text

$FileSelectHeader.TabIndex = 0
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 231
$System_Drawing_Size.Height = 23
$FileSelectHeader.Size = $System_Drawing_Size
$FileSelectHeader.Text = "Please Select a file to evaluate"

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 1
$System_Drawing_Point.Y = 19
$FileSelectHeader.Location = $System_Drawing_Point
$FileSelectHeader.DataBindings.DefaultDataSourceUpdateMode = 0
$FileSelectHeader.Name = "FileSelectHeader"

$PrintEvalRep.Controls.Add($FileSelectHeader)

################################################################################
#Printer Type report button

$PrintTypeBut.TabIndex = 2
$PrintTypeBut.Name = "PrintTypeBut"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 165
$System_Drawing_Size.Height = 23
$PrintTypeBut.Size = $System_Drawing_Size
$PrintTypeBut.UseVisualStyleBackColor = $True

$PrintTypeBut.Text = "Printer Type Breakdown"

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 1
$System_Drawing_Point.Y = 140
$PrintTypeBut.Location = $System_Drawing_Point
$PrintTypeBut.DataBindings.DefaultDataSourceUpdateMode = 0
$PrintTypeBut.add_Click($PrintTypeBut_OnClick)

$PrintEvalRep.Controls.Add($PrintTypeBut)

################################################################################
#Page Count Breakdown Button

$PgCntBrkdwnBut.TabIndex = 8
$PgCntBrkdwnBut.Name = "PgCntBrkdwnBut"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 165
$System_Drawing_Size.Height = 23
$PgCntBrkdwnBut.Size = $System_Drawing_Size
$PgCntBrkdwnBut.UseVisualStyleBackColor = $True

$PgCntBrkdwnBut.Text = "Page Count Breakdown"

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 1
$System_Drawing_Point.Y = 170
$PgCntBrkdwnBut.Location = $System_Drawing_Point
$PgCntBrkdwnBut.DataBindings.DefaultDataSourceUpdateMode = 0
$PgCntBrkdwnBut.add_Click($PgCntBrkdwnBut_OnClick)

$PrintEvalRep.Controls.Add($PgCntBrkdwnBut)

################################################################################
#Regional Page Count Button

$RegPgCntBut.TabIndex = 8
$RegPgCntBut.Name = "RegPgCntBut"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 165
$System_Drawing_Size.Height = 23
$RegPgCntBut.Size = $System_Drawing_Size
$RegPgCntBut.UseVisualStyleBackColor = $True

$RegPgCntBut.Text = "Regional Page Count"

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 1
$System_Drawing_Point.Y = 200
$RegPgCntBut.Location = $System_Drawing_Point
$RegPgCntBut.DataBindings.DefaultDataSourceUpdateMode = 0
$RegPgCntBut.add_Click($RegPgCntBut_OnClick)

$PrintEvalRep.Controls.Add($RegPgCntBut)

################################################################################
#CSV File Compare Button

$FileCompareBut.TabIndex = 8
$FileCompareBut.Name = "FileCompareBut"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 165
$System_Drawing_Size.Height = 23
$FileCompareBut.Size = $System_Drawing_Size
$FileCompareBut.UseVisualStyleBackColor = $True

$FileCompareBut.Text = "Total Page Count Comparison"

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 1
$System_Drawing_Point.Y = 230
$FileCompareBut.Location = $System_Drawing_Point
$FileCompareBut.DataBindings.DefaultDataSourceUpdateMode = 0
$FileCompareBut.add_Click($FileCompareBut_OnClick)

$PrintEvalRep.Controls.Add($FileCompareBut)

################################################################################
#Options to Select Report Header

$ReportHeader.TabIndex = 6
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 180
$System_Drawing_Size.Height = 23
$ReportHeader.Size = $System_Drawing_Size
$ReportHeader.Text = "Please Select Report"

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 1
$System_Drawing_Point.Y = 113
$ReportHeader.Location = $System_Drawing_Point
$ReportHeader.DataBindings.DefaultDataSourceUpdateMode = 0
$ReportHeader.Name = "ReportHeader"

$PrintEvalRep.Controls.Add($ReportHeader)

################################################################################
#Output Text Box Window

$OutputWindow.Name = "Output"
$OutputWindow.Font = "Lucida Console"
$OutputWindow.Text = ""
$OutputWindow.SelectionColor = [Drawing.Color]::Green
$OutputWindow.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 200
$System_Drawing_Point.Y = 110
$OutputWindow.Location = $System_Drawing_Point
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 900
$System_Drawing_Size.Height = 700
$OutputWindow.Size = $System_Drawing_Size
$OutputWindow.TabIndex = 5

$PrintEvalRep.Controls.Add($OutputWindow)

################################################################################
#File Browser to locate CSV for evaluation
$EvalCsvFileSelection.ShowHelp = $True
$EvalCsvFileSelection.FileName = ""
$EvalCsvFileSelection.filter = "CSV files (*.csv)| *.csv"
$EvalCsvFileSelection.add_FileOk($handler_EvalCsvFileSelection_FileOk)

################################################################################
#File Browser to locate CSV for evaluation
$CompCsvFileSelection.ShowHelp = $True
$CompCsvFileSelection.FileName = ""
$CompCsvFileSelection.filter = "CSV files (*.csv)| *.csv"
$CompCsvFileSelection.add_FileOk($handler_CompCsvFileSelection_FileOk)

################################################################################
#Regional Page Count Chart Region
$chart1.Width = 600
$chart1.Height = 600
$Chart1.Left = 200
$Chart1.Top = 110
$chart1.BackColor = [System.Drawing.Color]::Transparent
$chart1.Titles.Add("Regional Total Page Count Bar Chart") | Out-Null
$chart1.Titles[0].Font = "Arial,13pt"
$chart1.Titles[0].Alignment = "topLeft"

$chartarea.Name = "ChartArea1"
$chartarea.AxisY.Title = "Total Pages"
$chartarea.AxisX.Title = "Region"
$chartarea.AxisY.Interval = 10000
$chartarea.AxisX.Interval = 1
$chart1.ChartAreas.Add($chartarea)

$chart1.Series.Add("RegionalPages") | Out-Null
$chart1.Series["RegionalPages"].ChartType = "Column"
$chart1.Series["RegionalPages"].BorderWidth  = 3
$chart1.Series["RegionalPages"].IsVisibleInLegend = $true
$chart1.Series["RegionalPages"].chartarea = "ChartArea1"
$chart1.Series["RegionalPages"].color = "#62B5CC"
$Chart1.Series["RegionalPages"]["DrawingStyle"] = "Cylinder"
$Chart1.visible = $False

$PrintEvalRep.Controls.Add($Chart1)

#endregion Generated Form Code

#Save the initial state of the form
$InitialFormWindowState = $PrintEvalRep.WindowState
#Init the OnLoad event to correct the initial state of the form
$PrintEvalRep.add_Load($OnLoadForm_StateCorrection)
#Show the Form
$PrintEvalRep.ShowDialog()| Out-Null

} #End Function

#Call the Function
GenerateForm

Open in new window

0
Guy LidbetterCommented:
Hi M,

Any joy with that last script?
0
michalek19Author Commented:
Super thank you so much
0
Guy LidbetterCommented:
Pleasure!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.