QAToolModule.psm1
###########Functions Required for the Pre-Check############## Function Check-Prereq($enModPath) { $i=0 #$enModPath="D:\PowerShell\Pacjaging\QA_TOOL\Modules" #"C:\Users\"+$env:USERNAME+"\Documents\WindowsPowerShell\Modules" Write-Host "Testing HTML Module" if(Test-Path "$enModPath\PSWriteHTML") { Write-Host "Found the module in the local Path." try { Import-Module "$enModPath\PSWriteHTML" Write-Host "HTML Module loaded successfully." $i++ } catch { Write-Host "Failed to load DLL files with error $($Error[0].Exception.Message)" } } else { Write-Host "ERROR: HTML Module not present on the path $enModPath" } Write-Host "Testing Word Files" if(Test-Path "$enModPath\PSWriteWord" ) { try { Write-Host "Found the Word Module " Import-Module "$enModPath\PSWriteWord" Write-Host "Successfully loaded Word Module Files" $i++ } catch { Write-Host "Failed to load the Word Module Files with error $($Error[0].Exception.Message)" } } else { Write-Host "ERROR: Word Module not present on the path $enModPath" }#> <#if((Test-Path "$enModPath\Xceed.Document.NET.dll") -and (Test-Path "$enModPath\Xceed.Words.NET.dll") ) { try { Write-Host "Found DLL Files " Add-Type -Path $enModPath\Xceed.Document.NET.dll Add-Type -Path $enModPath\Xceed.Words.NET.dll Write-Host "Successfully loaded DLL Files" $i++ } catch { Write-Host "Failed to load DLL files with error $($Error[0].Exception.Message)" } } else { Write-Host "ERROR: Word Module not present on the path $enModPath" }#> Write-Host "Testing Custom Modules" if(Test-Path "$enModPath\CustomModule_V1.psm1" ) { Write-Host "Found custom Module" try { Import-Module "$enModPath\CustomModule_V1.psm1" Write-Host "Custome Module loaded successfully " $i++ } catch { Write-Host "Failed to load Custom module with error $($Error[0].Exception.Message)" } } else { Write-Host "ERROR: Custom Module not present on the path $enModPath" } return $i } Function Get-FileName($initialDirectory,[ValidateSet('MSI','MST','CSV','DOCX')]$FileType) { [System.Reflection.Assembly]::LoadWithPartialName(“System.windows.forms”) | Out-Null if($FileType -eq "MSI") { $Filter="MSI(.msi)|*.msi" } elseif($FileType -eq "MST"){ $Filter="MST(.mst)|*.mst" } elseif($FileType -eq "csv"){ $Filter="CSV(.csv)|*.csv" } elseif($FileType -eq "docx") { $Filter="docx(.docx)|*.docx" } $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog $OpenFileDialog.initialDirectory = $initialDirectory $OpenFileDialog.filter = $Filter $OpenFileDialog.ShowDialog() | Out-Null $OpenFileDialog.filename } Function Check-Readiness { $enModPath="C:\Users\"+$env:USERNAME+"\Documents\WindowsPowerShell\Modules" Write-Host "Testing HTML Module" $enModPath if(Test-Path "$enModPath\PSWriteHTML") { Write-Host "HTML Module present on the path. Importing" try { Import-Module "$enModPath\PSWriteHTML" Write-Host "HTML Module Loaded Successfully" } catch { Write-Host $Error[0] } } else { Write-Host "HTML Module not present. Copy on the path: $enModPath" return } Write-Host "Testing Custom Module" if(Test-Path "$enModPath\CustomModule_V1.psm1") { Write-Host "Custom Module present on the path. Importing." try { Import-Module "$enModPath\CustomModule_V1.psm1" Write-Host "Custom Module Loaded Successfully" } catch { Write-Host $Error[0] } } else { Write-Host "Custom Module not present. Copy on the path: $enModPath" return } } Function Check-HTMLFolder { param ($ScriptPath) If(Test-Path "$ScriptPath\HTML") { Write-Host "HTML folder already Exist" } else { Write-Host "HTML folder do not Exist. Creating." New-Item -Path $ScriptPath -Name HTML -ItemType Directory -Force } } Function Check-LogFolder { param ($ScriptPath) If(Test-Path "$ScriptPath\LOGS") { Write-Host "LOG folder already Exist" } else { Write-Host "LOG folder do not Exist. Creating." New-Item -Path $ScriptPath -Name LOGS -ItemType Directory -Force } } ###########Functions Required for the Pre-Check############## ############Function for Install/Uninstall############## Function Load-ActionBox1 { # Load Windows Forms & Drawing classes. [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") # Create base form. $objForm = New-Object System.Windows.Forms.Form $objForm.Text = "Select Action" $objForm.Size = New-Object System.Drawing.Size(300,170) $objForm.StartPosition = "CenterScreen" # Configure keyboard intercepts for ESC & ENTER. $objForm.KeyPreview = $True $objForm.Add_KeyDown({ if ($_.KeyCode -eq "Enter") { $x=$objListBox.SelectedItem $objForm.Close() } }) $objForm.Add_KeyDown({ if ($_.KeyCode -eq "Escape") {$objForm.Close() } }) # Create OK button. $OKButton = New-Object System.Windows.Forms.Button $OKButton.Location = New-Object System.Drawing.Size(75,90) $OKButton.Size = New-Object System.Drawing.Size(75,23) $OKButton.Text = "OK" $OKButton.Add_Click({$global:x=$objListBox.SelectedItem;$objForm.Close()}) #$OKButton.Add_Click({$x=$objListBox.SelectedItem;$objForm.Close()}) $objForm.Controls.Add($OKButton) $CancelButton = New-Object System.Windows.Forms.Button $CancelButton.Location = New-Object System.Drawing.Size(150,90) $CancelButton.Size = New-Object System.Drawing.Size(75,23) $CancelButton.Text = "Cancel" $CancelButton.Add_Click({$objForm.Close()}) $objForm.Controls.Add($CancelButton) $objLabel = New-Object System.Windows.Forms.Label $objLabel.Location = New-Object System.Drawing.Size(10,20) $objLabel.Size = New-Object System.Drawing.Size(280,20) $objLabel.Text = "Please select an action:" $objForm.Controls.Add($objLabel) $objListBox = New-Object System.Windows.Forms.ListBox $objListBox.Location = New-Object System.Drawing.Size(10,40) $objListBox.Size = New-Object System.Drawing.Size(260,20) $objListBox.Height = 50 [void] $objListBox.Items.Add("Install") [void] $objListBox.Items.Add("Uninstall") $objForm.Controls.Add($objListBox) # Force list box to display on top of other windows. $objForm.TopMost = $true $objForm.Add_Shown({$objForm.Activate()}) [void] $objForm.ShowDialog() return $objListBox.SelectedItem } Function Check-InstallUninstall1 { param($MainFolderPath) $INterPath= Split-Path $MainFolderPath $SorurceDirectory=Split-Path $INterPath if(Test-Path "$SorurceDirectory\Deploy-Application.exe") { Write-Host "Deploy-Application.exe found successfully" } else { Write-Host "Deploy-Application.exe was not found.Exiting" return } $ps1Files=Get-ChildItem $SorurceDirectory | where {$_.name -match ".ps1"} | select -ExpandProperty Name if($ps1Files.count -eq 1) { Write-Host "Ps1 file count is 1. Can proceed further" } else { Write-Host "Ps1 file count is more than one or no file present. Cannot proceed further" return } $Action=Load-ActionBox1 if($Action -eq "Install") { cd $SorurceDirectory try { .\Deploy-Application.exe .\$ps1Files -DeploymentType 'Install' -DeployMode 'Silent' Write-Host "Successfully initiated the Installation of the Package" } catch { Write-Host "Error in Installing" Write-Host $Error[0].Exception.Message } } elseif($Action -eq "UnInstall") { cd $SorurceDirectory try { .\Deploy-Application.exe .\$ps1Files -DeploymentType 'Uninstall' -DeployMode 'Silent' Write-Host "Successfully initiated the Uninstalltion of the Package" } catch { Write-Host "Error in Uninstalling" Write-Host $Error[0].Exception.Message } } else { Write-Host "Wrong Action Selected" } } ############Function for Install/Uninstall############## #####Additional Function########## Function Write-Log { param([ValidateSet("ERROR","INFO","WARNING")]$LogType, $LogFilePath,$Content ) $nl = "`r`n" $Log=(Get-Date -Format "dd/MM/yyyy hh:mm:ss")+" "+$LogType+":"+$Content+$nl Write-Host $Log $Log | Out-File -FilePath $LogFilePath -Append -Force -Encoding ascii } #####Additional Function########## #####Used in Equated-Transform_8########## Function Get-MSIProperties($Field,$MSIFile) { $fobj=@() $WindowsInstaller = New-Object -ComObject WindowsInstaller.Installer $MSIDatabase = $WindowsInstaller.GetType().InvokeMember('OpenDatabase', 'InvokeMethod', $Null, $WindowsInstaller, @($msifile, 0)) $Query = "SELECT * FROM $Field" $View = $MSIDatabase.GetType().InvokeMember('OpenView', 'InvokeMethod', $null, $MSIDatabase, ($Query)) $View.GetType().InvokeMember('Execute', 'InvokeMethod', $null, $View, $null) $hash = @{} $MSIResult = while ($Record = $View.GetType().InvokeMember('Fetch', 'InvokeMethod', $null, $View, $null)) { $name = $Record.GetType().InvokeMember('StringData', 'GetProperty', $null, $Record, 1) $value = $hashMSIValue = $Record.GetType().InvokeMember('StringData', 'GetProperty', $null, $Record, 2) $obj=New-Object PSObject $obj | Add-Member -MemberType NoteProperty -Name DBTable -Value $Field $obj | Add-Member -MemberType NoteProperty -Name Name -Value $name $obj | Add-Member -MemberType NoteProperty -Name Value -Value $value $fobj += $obj #$hash.Add($name,$value) } return $fobj } #####Used in Equated-Transform_8########## #####Used in Equated-Transform_8########## Function Apply-Transforms { Param($SourceMSI,$SourceMST,$DBTable,$Table1,$Table2) $fobj=@() $TempMSI = "$SourceMSI.tmp" $TempMST = "$SourceMST.tmp" Copy-Item $SourceMSI $TempMSI -Force Copy-Item $SourceMST $TempMST -Force $WindowsInstaller = New-Object -ComObject WindowsInstaller.Installer #Open the database in Direct read/write without Transaction (2) $MSIDatabase1 = $WindowsInstaller.GetType().InvokeMember('OpenDatabase' , 'InvokeMethod' , $Null, $WindowsInstaller, @($TempMSI, 2)) $MSIDatabase1.GetType().InvokeMember('ApplyTransform' , 'InvokeMethod' , $Null , $MSIDatabase1 , @($TempMST, 0)) $Query = ("SELECT * FROM $DBTable") #Opens a data view to the MSI based on the query created. $View = $MSIDatabase1.GetType().InvokeMember('OpenView', 'InvokeMethod', $null, $MSIDatabase1, ($Query)) $null = $View.GetType().InvokeMember('Execute', 'InvokeMethod', $null, $View, $null) #$hash = @{} # Add File information (Note this adds the full File information Porperties so can call with <Var>.File |Select * #$hash.Add('File',$TempMSI) WHILE ($Record = $View.GetType().InvokeMember('Fetch', 'InvokeMethod', $null, $View, $null)) { $name = $Record.GetType().InvokeMember('StringData', 'GetProperty', $null, $Record, $Table1) $value = $hashMSIValue = $Record.GetType().InvokeMember('StringData', 'GetProperty', $null, $Record, $Table2) $obj=New-Object PSObject $obj | Add-Member -MemberType NoteProperty -Name DBTable -Value $DBTable $obj | Add-Member -MemberType NoteProperty -Name Name -Value $name $obj | Add-Member -MemberType NoteProperty -Name Value -Value $value $fobj += $obj #$hash.Add($name,$value) } # Push Hash table into a PSCustom object #$msiProperties = [pscustomobject]$hash # I'm not sure If I have everything required to close out here properly from applying the transform. $null = $MSIDatabase1.GetType().InvokeMember('Commit' , 'InvokeMethod' , $Null , $MSIDatabase1 , $Null) $null = $view.GetType().InvokeMember('Close', 'InvokeMethod', $null, $view, $null) # Really important part to be able to release the opened files and delete $null = [Runtime.Interopservices.Marshal]::ReleaseComObject($view) $null = [Runtime.Interopservices.Marshal]::ReleaseComObject($MSIDatabase1) $null = [Runtime.Interopservices.Marshal]::ReleaseComObject($WindowsInstaller) [GC]::Collect() return $fobj } #####Used in Equated-Transform_8########## #############Main Function################ Function Equated-Transforms_8 { param($InputMSIFile,$InputMSTFile,$InWordFile) $finobj=@() $FinValObj=@() $obj=@() $ExpValues=get-ValueInnEw -wordDocPath $InWordFile #$ExpValues if($InputMSTFile) { $PropTable=Apply-Transforms -SourceMSI $InputMSIFile -SourceMST $InputMSTFile -DBTable Property -Table1 1 -table2 2 $RegTable=Apply-Transforms -SourceMSI $InputMSIFile -SourceMST $InputMSTFile -DBTable Registry -Table1 6 -table2 3 $obj+=$PropTable $obj+=$RegTable } else { $PropTable=Get-MSIProperties -Field Property -MSIFile $InputMSIFile $RegTable=Get-MSIProperties -Field Registry -MSIFile $InputMSIFile $obj+=$PropTable $obj+=$RegTable } #$obj $AllUsers=$obj | where{$_.DBTable -match "Property" -and $_.Name -match "Allusers"} if(!$AllUsers) { $AllUsers=New-Object Psobject $AllUsers | Add-Member -MemberType NoteProperty -Name DBTable -Value Property $AllUsers | Add-Member -MemberType NoteProperty -Name Name -Value AllUsers $AllUsers | Add-Member -MemberType NoteProperty -Name Value -Value "Not Found" $finobj+=$AllUsers } else { $finobj+=$AllUsers } $ARPNOREPAIR=$obj | where{$_.DBTable -match "Property" -and $_.Name -match "ARPNOREPAIR"} if(!$ARPNOREPAIR) { $ARPNOREPAIR=New-Object Psobject $ARPNOREPAIR | Add-Member -MemberType NoteProperty -Name DBTable -Value Property $ARPNOREPAIR | Add-Member -MemberType NoteProperty -Name Name -Value ARPNOREPAIR $ARPNOREPAIR | Add-Member -MemberType NoteProperty -Name Value -Value "Not Found" $finobj+=$ARPNOREPAIR } else { $finobj+=$ARPNOREPAIR } $ARPNOMODIFY=$obj | where{$_.DBTable -match "Property" -and $_.Name -match "ARPNOMODIFY"} if(!$ARPNOMODIFY) { $ARPNOMODIFY=New-Object Psobject $ARPNOMODIFY | Add-Member -MemberType NoteProperty -Name DBTable -Value Property $ARPNOMODIFY | Add-Member -MemberType NoteProperty -Name Name -Value ARPNOMODIFY $ARPNOMODIFY | Add-Member -MemberType NoteProperty -Name Value -Value "Not Found" $finobj+=$ARPNOMODIFY } else { $finobj+=$ARPNOMODIFY } $ARPNOREMOVE=$obj | where{$_.DBTable -match "Property" -and $_.Name -match "ARPNOREMOVE"} if(!$ARPNOREMOVE) { $ARPNOREMOVE=New-Object Psobject $ARPNOREMOVE | Add-Member -MemberType NoteProperty -Name DBTable -Value Property $ARPNOREMOVE | Add-Member -MemberType NoteProperty -Name Name -Value ARPNOREMOVE $ARPNOREMOVE | Add-Member -MemberType NoteProperty -Name Value -Value "Not Found" $finobj+=$ARPNOREMOVE } else { $finobj+=$ARPNOREMOVE } $USERNAME=$obj | where{$_.DBTable -match "Property" -and $_.Name -match "USERNAME"} if(!$USERNAME) { $USERNAME=New-Object Psobject $USERNAME | Add-Member -MemberType NoteProperty -Name DBTable -Value Property $USERNAME | Add-Member -MemberType NoteProperty -Name Name -Value USERNAME $USERNAME | Add-Member -MemberType NoteProperty -Name Value -Value "Not Found" $finobj+=$USERNAME } else { $finobj+=$USERNAME } $ProductLanguage=$obj | where{$_.DBTable -match "Property" -and $_.Name -match "ProductLanguage"} if(!$ProductLanguage) { $ProductLanguage=New-Object Psobject $ProductLanguage | Add-Member -MemberType NoteProperty -Name DBTable -Value Property $ProductLanguage | Add-Member -MemberType NoteProperty -Name Name -Value ProductLanguage $ProductLanguage | Add-Member -MemberType NoteProperty -Name Value -Value "Not Found" $finobj+=$ProductLanguage } else { $finobj+=$ProductLanguage } $REBOOT=$obj | where{$_.DBTable -match "Property" -and $_.Name -eq "REBOOT"} if(!$REBOOT) { $REBOOT=New-Object Psobject $REBOOT | Add-Member -MemberType NoteProperty -Name DBTable -Value Property $REBOOT | Add-Member -MemberType NoteProperty -Name Name -Value REBOOT $REBOOT | Add-Member -MemberType NoteProperty -Name Value -Value "Not Found" $finobj+=$REBOOT } else { $finobj+=$REBOOT } $ROOTDRIVE=$obj | where{$_.DBTable -match "Property" -and $_.Name -match "ROOTDRIVE"} if(!$ROOTDRIVE) { $ROOTDRIVE=New-Object Psobject $ROOTDRIVE | Add-Member -MemberType NoteProperty -Name DBTable -Value Property $ROOTDRIVE | Add-Member -MemberType NoteProperty -Name Name -Value ROOTDRIVE $ROOTDRIVE | Add-Member -MemberType NoteProperty -Name Value -Value "Not Found" $finobj+=$ROOTDRIVE } else { $finobj+=$ROOTDRIVE } $Author=$obj | where{$_.DBTable -match "Property" -and $_.Name -match "Author"} if(!$Author) { $Author=New-Object Psobject $Author | Add-Member -MemberType NoteProperty -Name DBTable -Value Property $Author | Add-Member -MemberType NoteProperty -Name Name -Value Author $Author | Add-Member -MemberType NoteProperty -Name Value -Value "Not Found" $finobj+=$Author } else { $finobj+=$Author } $Manufacturer=$obj | where{$_.DBTable -match "Property" -and $_.Name -match "Manufacturer"} if(!$Manufacturer) { $Manufacturer=New-Object Psobject $Manufacturer | Add-Member -MemberType NoteProperty -Name DBTable -Value Property $Manufacturer | Add-Member -MemberType NoteProperty -Name Name -Value Manufacturer $Manufacturer | Add-Member -MemberType NoteProperty -Name Value -Value "Not Found" $finobj+=$Manufacturer } else { $finobj+=$Manufacturer } $ProductName=$obj | where{$_.DBTable -match "Property" -and $_.Name -match "ProductName"} if(!$ProductName) { $ProductName=New-Object Psobject $ProductName | Add-Member -MemberType NoteProperty -Name DBTable -Value Property $ProductName | Add-Member -MemberType NoteProperty -Name Name -Value ProductName $ProductName | Add-Member -MemberType NoteProperty -Name Value -Value "Not Found" $finobj+=$ProductName } else { $finobj+=$ProductName } $ProductVersion=$obj | where{$_.DBTable -match "Property" -and $_.Name -match "ProductVersion"} if(!$ProductVersion) { $ProductVersion=New-Object Psobject $ProductVersion | Add-Member -MemberType NoteProperty -Name DBTable -Value Property $ProductVersion | Add-Member -MemberType NoteProperty -Name Name -Value ProductVersion $ProductVersion | Add-Member -MemberType NoteProperty -Name Value -Value "Not Found" $finobj+=$ProductVersion } else { $finobj+=$ProductVersion } $ProductCode=$obj | where{$_.DBTable -match "Property" -and $_.Name -match "ProductCode"} if(!$ProductCode) { $ProductCode=New-Object Psobject $ProductCode | Add-Member -MemberType NoteProperty -Name DBTable -Value Property $ProductCode | Add-Member -MemberType NoteProperty -Name Name -Value ProductCode $ProductCode | Add-Member -MemberType NoteProperty -Name Value -Value "Not Found" $finobj+=$ProductCode } else { $finobj+=$ProductCode } $UpgradeCode=$obj | where{$_.DBTable -match "Property" -and $_.Name -match "UpgradeCode"} if(!$UpgradeCode) { $UpgradeCode=New-Object Psobject $UpgradeCode | Add-Member -MemberType NoteProperty -Name DBTable -Value Property $UpgradeCode | Add-Member -MemberType NoteProperty -Name Name -Value UpgradeCode $UpgradeCode | Add-Member -MemberType NoteProperty -Name Value -Value "Not Found" $finobj+=$UpgradeCode } else { $finobj+=$UpgradeCode } $FJREF=$obj | where{$_.DBTable -match "Property" -and $_.Name -match "FJREF"} if(!$FJREF) { $FJREF=New-Object Psobject $FJREF | Add-Member -MemberType NoteProperty -Name DBTable -Value Property $FJREF | Add-Member -MemberType NoteProperty -Name Name -Value FJREF $FJREF | Add-Member -MemberType NoteProperty -Name Value -Value "Not Found" $finobj+=$FJREF } else { $finobj+=$FJREF } $PackageCode=$obj | where{$_.DBTable -match "Property" -and $_.Name -match "PackageCode"} if(!$PackageCode) { $PackageCode=New-Object Psobject $PackageCode | Add-Member -MemberType NoteProperty -Name DBTable -Value Property $PackageCode | Add-Member -MemberType NoteProperty -Name Name -Value PackageCode $PackageCode | Add-Member -MemberType NoteProperty -Name Value -Value "Not Found" $finobj+=$PackageCode } else { $finobj+=$PackageCode } $objAK=$obj | where{$_.DBTable -match "Registry" -and $_.Name -eq "Audit_Key"} if(!$objAK) { $objAK=New-Object Psobject $objAK | Add-Member -MemberType NoteProperty -Name DBTable -Value Registry $objAK | Add-Member -MemberType NoteProperty -Name Name -Value Audit_key $objAK | Add-Member -MemberType NoteProperty -Name Value -Value "Not Found" $finobj+=$objAK } else { $finobj+=$objAK } $objInstallDIR=$obj | where{$_.DBTable -match "Registry" -and $_.Name -eq "INSTALLDIR"} if(!$objInstallDIR) { $objInstallDIR=New-Object Psobject $objInstallDIR | Add-Member -MemberType NoteProperty -Name DBTable -Value Registry $objInstallDIR | Add-Member -MemberType NoteProperty -Name Name -Value INSTALLDIR $objInstallDIR | Add-Member -MemberType NoteProperty -Name Value -Value "Not Found" $finobj+=$objInstallDIR } else { $finobj+=$objInstallDIR } #$finobj foreach($ExpValue in $ExpValues) { $ExpectedValue=$ExpValue.value $CurrentValue=$finobj | where{$_.Name -eq $ExpValue.Property} | select -ExpandProperty Value #$CurrentValue if($ExpectedValue -eq $CurrentValue) { $OutObj=New-Object PSObject $OutObj | Add-Member -MemberType NoteProperty -Name Property -Value $ExpValue.Property $OutObj | Add-Member -MemberType NoteProperty -Name Current_Value -Value $CurrentValue $OutObj | Add-Member -MemberType NoteProperty -Name Expected_Value -Value $ExpectedValue $OutObj | Add-Member -MemberType NoteProperty -Name Match_Status -Value Matched $FinValObj += $OutObj } Else { $OutObj=New-Object PSObject $OutObj | Add-Member -MemberType NoteProperty -Name Property -Value $ExpValue.Property $OutObj | Add-Member -MemberType NoteProperty -Name Current_Value -Value $CurrentValue $OutObj | Add-Member -MemberType NoteProperty -Name Expected_Value -Value $ExpectedValue $OutObj | Add-Member -MemberType NoteProperty -Name Match_Status -Value "Not Matched" $FinValObj += $OutObj } } return $FinValObj } #############Main Function################ #####Used in Equated-Transform_8########## function get-ValueIntheBox($formTitle, $textTitle,$wordDocPath) { $global:AllValues=@() $global:AllValues += New-Object -TypeName psobject -Property @{Property="ALLUSERS"; Value="1"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="ARPNOREPAIR"; Value="1"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="ARPNOMODIFY"; Value="1"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="ARPNOREMOVE"; Value="1"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="USERNAME"; Value="Authorised User"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="ProductLanguage"; Value="1033"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="REBOOT"; Value="ReallySuppress"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="ROOTDRIVE"; Value="C:\"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="ALLUSERS"; Value="1"} $ValuesFromWord=Extract-FromWord $wordDocPath $manuFacturer=($ValuesFromWord | where{$_.Property -match "Application Vendor"} | select -ExpandProperty Value) $val=($ValuesFromWord | where{$_.Property -eq "Detection Method"} | select -ExpandProperty Value).Split("`r`n")[1] $productName=($ValuesFromWord | where{$_.Property -match "Application Name"} | select -ExpandProperty Value) $Version=($ValuesFromWord | where{$_.Property -match "Application Version"} | select -ExpandProperty Value) $PackageName=($ValuesFromWord | where{$_.Property -match "Package Name"} | select -ExpandProperty Value) $fjref=($ValuesFromWord | where{$_.Property -match "APS Reference"} | select -ExpandProperty Value) $tempKey=($ValuesFromWord | where{$_.Property -match "Detection Method "} | select -ExpandProperty Value) $AuditKey=($ValuesFromWord | where{$_.Property -eq "Detection Method"} | select -ExpandProperty Value).Split("`r`n")[0] $AuditKey=$AuditKey+"\"+$val.Replace("Value: ","") $ProdCode=($ValuesFromWord | where{$_.Property -match "Product Code"} | select -ExpandProperty Value) $installPath=$ValuesFromWord | where{$_.Property -match "Installation Path"} | select -ExpandProperty Value $RegVal=$ValuesFromWord | where{$_.Property -match "RegVal"} | select -ExpandProperty Value [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") $objForm = New-Object System.Windows.Forms.Form $objForm.Text = $formTitle $objForm.Size = New-Object System.Drawing.Size(300,450) $objForm.StartPosition = "CenterScreen" $objForm.AutoSize=$True $objForm.AutoScale=$True $objForm.KeyPreview = $True $objForm.Add_KeyDown({if ($_.KeyCode -eq "Enter") {$x=$objTextBox.Text;$objForm.Close()}}) $objForm.Add_KeyDown({if ($_.KeyCode -eq "Escape") {$objForm.Close()}}) $OKButton = New-Object System.Windows.Forms.Button $OKButton.Location = New-Object System.Drawing.Size(75,370) $OKButton.Size = New-Object System.Drawing.Size(75,23) $OKButton.Text = "OK" $OKButton.Add_Click({$Script:userInput=$objTextBox.Text;$objForm.Close()}) $objForm.Controls.Add($OKButton) $CANCELButton = New-Object System.Windows.Forms.Button $CANCELButton.Location = New-Object System.Drawing.Size(150,370) $CANCELButton.Size = New-Object System.Drawing.Size(75,23) $CANCELButton.Text = "CANCEL" $CANCELButton.Add_Click({$objForm.Close()}) $objForm.Controls.Add($CANCELButton) $objTextBox = New-Object System.Windows.Forms.TextBox $objTextBox.Location = New-Object System.Drawing.Size(120,50) $objTextBox.Size = New-Object System.Drawing.Size(230,20) $objTextBox.Text=$env:USERNAME $objTextBox.AutoSize=$True $objForm.Controls.Add($objTextBox) $objTextBox1 = New-Object System.Windows.Forms.TextBox $objTextBox1.Location = New-Object System.Drawing.Size(120,80) $objTextBox1.Size = New-Object System.Drawing.Size(230,20) $objTextBox1.Text=$manuFacturer $objTextBox1.AutoSize=$True $objForm.Controls.Add($objTextBox1) $objTextBox2 = New-Object System.Windows.Forms.TextBox $objTextBox2.Location = New-Object System.Drawing.Size(120,110) $objTextBox2.Size = New-Object System.Drawing.Size(230,20) $objTextBox2.AutoSize=$True $objTextBox2.Text=$productName $objForm.Controls.Add($objTextBox2) $objTextBox3 = New-Object System.Windows.Forms.TextBox $objTextBox3.Location = New-Object System.Drawing.Size(120,140) $objTextBox3.Size = New-Object System.Drawing.Size(230,20) $objTextBox3.AutoSize=$True $objTextBox3.Text=$Version $objForm.Controls.Add($objTextBox3) $objTextBox4 = New-Object System.Windows.Forms.TextBox $objTextBox4.Location = New-Object System.Drawing.Size(120,170) $objTextBox4.Size = New-Object System.Drawing.Size(230,20) $objTextBox4.AutoSize=$True $objTextBox4.Text=$ProdCode $objForm.Controls.Add($objTextBox4) $objTextBox5 = New-Object System.Windows.Forms.TextBox $objTextBox5.Location = New-Object System.Drawing.Size(120,200) $objTextBox5.Size = New-Object System.Drawing.Size(230,20) $objTextBox5.AutoSize=$True $objForm.Controls.Add($objTextBox5) $objTextBox6 = New-Object System.Windows.Forms.TextBox $objTextBox6.Location = New-Object System.Drawing.Size(120,230) $objTextBox6.Size = New-Object System.Drawing.Size(230,20) $objTextBox6.AutoSize=$True $objTextBox6.Text=$fjref $objForm.Controls.Add($objTextBox6) $objTextBox7 = New-Object System.Windows.Forms.TextBox $objTextBox7.Location = New-Object System.Drawing.Size(120,260) $objTextBox7.AutoSize=$True $objTextBox7.Size = New-Object System.Drawing.Size(230,20) $objTextBox7.Text=$RegVal $objForm.Controls.Add($objTextBox7) $objTextBox8 = New-Object System.Windows.Forms.TextBox $objTextBox8.Location = New-Object System.Drawing.Size(120,290) $objTextBox8.Size = New-Object System.Drawing.Size(230,20) $objTextBox8.AutoSize=$True $objTextBox8.Text=$installPath $objForm.Controls.Add($objTextBox8) $objTextBox9 = New-Object System.Windows.Forms.TextBox $objTextBox9.Location = New-Object System.Drawing.Size(120,320) $objTextBox9.Size = New-Object System.Drawing.Size(230,20) $objTextBox9.AutoSize=$True $objTextBox9.Text=$AuditKey $objForm.Controls.Add($objTextBox9) $objLabelMain = New-Object System.Windows.Forms.Label $objLabelMain.Location = New-Object System.Drawing.Size(180,20) $objLabelMain.Size = New-Object System.Drawing.Size(280,30) $objLabelMain.Text = "Validate Input" $objForm.Controls.Add($objLabelMain) $objLabel = New-Object System.Windows.Forms.Label $objLabel.Location = New-Object System.Drawing.Size(20,50) $objLabel.Size = New-Object System.Drawing.Size(280,30) $objLabel.Text = "Engineer Name" $objForm.Controls.Add($objLabel) $objLabel1 = New-Object System.Windows.Forms.Label $objLabel1.Location = New-Object System.Drawing.Size(20,80) $objLabel1.Size = New-Object System.Drawing.Size(280,30) $objLabel1.Text = "Manufacturer" $objForm.Controls.Add($objLabel1) $objLabel2 = New-Object System.Windows.Forms.Label $objLabel2.Location = New-Object System.Drawing.Size(20,110) $objLabel2.Size = New-Object System.Drawing.Size(280,30) $objLabel2.Text = "ProductName" $objForm.Controls.Add($objLabel2) $objLabel3 = New-Object System.Windows.Forms.Label $objLabel3.Location = New-Object System.Drawing.Size(20,140) $objLabel3.Size = New-Object System.Drawing.Size(280,30) $objLabel3.Text = "ProductVersion" $objForm.Controls.Add($objLabel3) $objLabel4 = New-Object System.Windows.Forms.Label $objLabel4.Location = New-Object System.Drawing.Size(20,170) $objLabel4.Size = New-Object System.Drawing.Size(280,30) $objLabel4.Text = "ProductCode" $objForm.Controls.Add($objLabel4) $objLabel5 = New-Object System.Windows.Forms.Label $objLabel5.Location = New-Object System.Drawing.Size(20,200) $objLabel5.Size = New-Object System.Drawing.Size(280,30) $objLabel5.Text = "UpgradeCode" $objForm.Controls.Add($objLabel5) $objLabel6 = New-Object System.Windows.Forms.Label $objLabel6.Location = New-Object System.Drawing.Size(20,230) $objLabel6.Size = New-Object System.Drawing.Size(280,30) $objLabel6.Text = "FJREF" $objForm.Controls.Add($objLabel6) $objLabel7 = New-Object System.Windows.Forms.Label $objLabel7.Location = New-Object System.Drawing.Size(20,260) $objLabel7.Size = New-Object System.Drawing.Size(280,30) $objLabel7.Text = "Package Code" $objForm.Controls.Add($objLabel7) $objLabel8 = New-Object System.Windows.Forms.Label $objLabel8.Location = New-Object System.Drawing.Size(20,290) $objLabel8.Size = New-Object System.Drawing.Size(280,30) $objLabel8.Text = "INSTALLDIR" $objForm.Controls.Add($objLabel8) $objLabel9 = New-Object System.Windows.Forms.Label $objLabel9.Location = New-Object System.Drawing.Size(20,320) $objLabel9.Size = New-Object System.Drawing.Size(280,30) $objLabel9.Text = "Audit_Key" $objForm.Controls.Add($objLabel9) $objForm.Topmost = $True $OKButton.add_click({ $global:AllValues += New-Object -TypeName psobject -Property @{Property="Author"; Value="Fujitsu - $($objTextBox.Text)"} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$($objLabel1.Text); Value=$($objTextBox1.Text)} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel2.Text; Value=$objTextBox2.Text} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel3.Text; Value=$objTextBox3.Text} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel4.Text; Value=$objTextBox4.Text} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel5.Text; Value=$objTextBox5.Text} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel6.Text; Value=$objTextBox6.Text} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel7.Text; Value=$objTextBox7.Text} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel8.Text; Value=$objTextBox8.Text} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel9.Text; Value=$objTextBox9.Text} }) $objForm.Add_Shown({$objForm.Activate()}) [void] $objForm.ShowDialog() return $global:AllValues } #####Used in Equated-Transform_8########## #############used in get-ValueIn############# Function Get-DataFromWord($DocFilePath) { $fin=@() if(Test-Path $DocFilePath) { Write-Host "Path $DocFilePath exist" } else { Write-Host "Path $DocFilePath not exist" } $cusobj=New-Object PSObject $TempTXTFile=(Split-Path $DocFilePath)+"\TempTXT.txt" if(Test-Path $TempTXTFile -ErrorAction SilentlyContinue) { Remove-Item $TempTXTFile -Force } if(Get-Process -name WINWORD -ErrorAction SilentlyContinue) { Stop-Process -Name WINWORD -ErrorAction SilentlyContinue -Force } $WordDocument = [Xceed.Words.NET.DocX]::Load($DocFilePath) $WordDocument | Out-File $TempTXTFile $allcontent=Get-Content $TempTXTFile $PackageName=(((Get-Content $TempTXTFile | where{$_ -match "Package Name"})| select -First 1).Replace("Package Name ","")).trim() #(Get-Content $TempTXTFile | where{$_ -match "Package Name"}).Replace("Package Name ","").Replace(" <w:t>Package Name</w:t>","").Trim() $ProdCode=(((Get-Content $TempTXTFile | where{$_ -match "Product Code"})| select -First 1).Replace("Product Code ","")).trim() #$ProdCode=(Get-Content $TempTXTFile | where{$_ -match "Product Code"}).Replace("Product Code ","").Replace("<w:t>Product Code</w:t>","").Trim() $ApplicationVendor=(((Get-Content $TempTXTFile | where{$_ -match "Application Vendor"}).Replace("Application Vendor ","").Trim() | select -First 1).split("(")[0]).trim() $ApplicationName=(((Get-Content $TempTXTFile | where{$_ -match "Application Name"}).Replace("Application Name ","").Trim() | select -First 1).split("(")[0]).trim() $Version=(((Get-Content $TempTXTFile | where{$_ -match "Application Version"}).Replace("Application Version ","").Trim() | select -First 1).split("(")[0]).trim() $APSReference=(((Get-Content $TempTXTFile | where{$_ -match "APS Reference"}).Replace("APS Reference ","").Trim() | select -First 1).split("(")[0]).trim() $InstallationPath=(((Get-Content $TempTXTFile | where{$_ -match "Installation Path"}).Replace("Installation Path ","").Trim() | select -First 1)).trim() $a=Get-Content $TempTXTFile for($i=0;$i -le $a.Count;$i++) { if($a[$i] -match "Detection" -and ($a[$i] -match "HKLM" -or $a[$i] -match "HKEY_LOCAL_MACHINE") ) { $AuditKey=($a[$i+1] -replace ".*[:]","").Trim() } if($a[$i] -match "Detection" ) { if($a[$i+1] -match "HKLM" -or $a[$i+1] -match "HKEY_LOCAL_MACHINE") { $AuditKey=($a[$i+1] -replace ".*[:]","").Trim() } } } $AuditKey $RegVal $cusobj=New-Object PSObject $cusobj | Add-Member -MemberType NoteProperty -Name Property -Value PackageName $cusobj | Add-Member -MemberType NoteProperty -Name Value -Value $PackageName $fin += $cusobj $cusobj1=New-Object PSObject $cusobj1 | Add-Member -MemberType NoteProperty -Name Property -Value ProdCode $cusobj1 | Add-Member -MemberType NoteProperty -Name Value -Value $ProdCode $fin += $cusobj1 $cusobj2=New-Object PSObject $cusobj2 | Add-Member -MemberType NoteProperty -Name Property -Value ApplicationVendor $cusobj2 | Add-Member -MemberType NoteProperty -Name Value -Value $ApplicationVendor $fin += $cusobj2 $cusobj3=New-Object PSObject $cusobj3 | Add-Member -MemberType NoteProperty -Name Property -Value ApplicationName $cusobj3 | Add-Member -MemberType NoteProperty -Name Value -Value $ApplicationName $fin += $cusobj3 $cusobj4=New-Object PSObject $cusobj4 | Add-Member -MemberType NoteProperty -Name Property -Value Version $cusobj4 | Add-Member -MemberType NoteProperty -Name Value -Value $Version $fin += $cusobj4 $cusobj5=New-Object PSObject $cusobj5 | Add-Member -MemberType NoteProperty -Name Property -Value APSReference $cusobj5 | Add-Member -MemberType NoteProperty -Name Value -Value $APSReference $fin += $cusobj5 $cusobj6=New-Object PSObject $cusobj6 | Add-Member -MemberType NoteProperty -Name Property -Value AuditKey $cusobj6 | Add-Member -MemberType NoteProperty -Name Value -Value $AuditKey $fin += $cusobj6 $cusobj7=New-Object PSObject $cusobj7 | Add-Member -MemberType NoteProperty -Name Property -Value RegVal $cusobj7 | Add-Member -MemberType NoteProperty -Name Value -Value $RegVal $fin += $cusobj7 $cusobj8=New-Object PSObject $cusobj8 | Add-Member -MemberType NoteProperty -Name Property -Value INSTALLDIR $cusobj8 | Add-Member -MemberType NoteProperty -Name Value -Value $InstallationPath $fin += $cusobj8 return $fin } Function Get-DataFromWordNew { Param($WordDocPath) $word=Get-WordDocument -FilePath $WordDocPath $fin=@() $tempFile="C:\Windows\Temp\tempTxt.txt" if(Test-Path $tempFile) { Remove-Item $tempFile -Force } Get-WordParagraphs -WordDocument $word | Out-File $tempFile -Append -Force $a=Get-Content $tempFile | where{$_ -match "Text : "} $a for($i=0;$i -le $a.Count;$i++) { if($a[$i] -eq "Text : Package Name") { $PackageName=$a[$i+1] $PackageName=$PackageName.Replace("Text : ","").Trim() } if($a[$i] -eq "Text : Product Code") { $Prodcode=$a[$i+1] $Prodcode=$Prodcode.Replace("Text : ","").Trim() } if($a[$i] -eq "Text : Application Vendor") { $ApplicationVendor=$a[$i+1] $ApplicationVendor=$ApplicationVendor.Replace("Text : ","").Trim() if($fin.Property -match "ApplicationVendor") { } else { $cusobj2=New-Object PSObject $cusobj2 | Add-Member -MemberType NoteProperty -Name Property -Value ApplicationVendor $cusobj2 | Add-Member -MemberType NoteProperty -Name Value -Value $ApplicationVendor $fin += $cusobj2 } } if($a[$i] -eq "Text : Application Name") { $ApplicationName=$a[$i+1] $ApplicationName=$ApplicationName.Replace("Text : ","").Trim() if($fin.Property -match "ApplicationName") { } else { $cusobj3=New-Object PSObject $cusobj3 | Add-Member -MemberType NoteProperty -Name Property -Value ApplicationName $cusobj3 | Add-Member -MemberType NoteProperty -Name Value -Value $ApplicationName $fin += $cusobj3 } } if($a[$i] -eq "Text : Packaged By") { $Packager=$a[$i+1] $Packager=$Packager.Replace("Text : ","").Trim() } if($a[$i] -eq "Text : Quality Assured By") { $QAAss=$a[$i+1] $QAAss=$QAAss.Replace("Text : ","").Trim() } if($a[$i] -eq "Text : Application Version") { $Version=$a[$i+1] $Version=$Version.Replace("Text : ","").Trim() if($fin.Property -match "Version") { } else { $cusobj4=New-Object PSObject $cusobj4 | Add-Member -MemberType NoteProperty -Name Property -Value Version $cusobj4 | Add-Member -MemberType NoteProperty -Name Value -Value $Version $fin += $cusobj4 } } if($a[$i] -eq "Text : Installation Path") { $InstallationPath=$a[$i+1] $InstallationPath=$InstallationPath.Replace("Text : ","").Trim() } if($a[$i] -eq "Text : APS Reference") { $APSReference=$a[$i+1] $APSReference=$APSReference.Replace("Text : ","").Trim() } if($a[$i] -eq "Text : Detection Method") { $AuditKey=$a[$i+1] $AuditKey=$AuditKey.Replace("Text : ","").Trim().Replace("Key: ","") } } $cusobj=New-Object PSObject $cusobj | Add-Member -MemberType NoteProperty -Name Property -Value PackageName $cusobj | Add-Member -MemberType NoteProperty -Name Value -Value $PackageName $fin += $cusobj $cusobj1=New-Object PSObject $cusobj1 | Add-Member -MemberType NoteProperty -Name Property -Value ProdCode $cusobj1 | Add-Member -MemberType NoteProperty -Name Value -Value $ProdCode $fin += $cusobj1 $cusobj5=New-Object PSObject $cusobj5 | Add-Member -MemberType NoteProperty -Name Property -Value APSReference $cusobj5 | Add-Member -MemberType NoteProperty -Name Value -Value $APSReference $fin += $cusobj5 $cusobj6=New-Object PSObject $cusobj6 | Add-Member -MemberType NoteProperty -Name Property -Value AuditKey $cusobj6 | Add-Member -MemberType NoteProperty -Name Value -Value $AuditKey $fin += $cusobj6 $cusobj8=New-Object PSObject $cusobj8 | Add-Member -MemberType NoteProperty -Name Property -Value INSTALLDIR $cusobj8 | Add-Member -MemberType NoteProperty -Name Value -Value $InstallationPath $fin += $cusobj8 return $fin } #############used in get-ValueIn############# ########################## ###############Functions that can be discarded if not required############ <# Function Install-Prereq { $enModPath="D:\PowerShell\Pacjaging\QA_TOOL\Modules" $precheck=Check-Prereq -enModPath $enModPath if($precheck -eq 3) { "All modules present" } else { $wshell = New-Object -ComObject Wscript.Shell $pop=$wshell.Popup("There are Missing Modules. Please copy and rerun.",0,"Install Module",0x1) } } Function Import-CustomModules { param($SourcePath) $enModPath="C:\Users\"+$env:USERNAME+"\Documents\WindowsPowerShell\Modules" Write-Host "Testing HTML Module" if(Test-Path "$SourcePath\PSWriteHTML") { Write-Host "Already Present HTML Module" Import-Module "$SourcePath\PSWriteHTML" Write-Host "HTML Module Loaded Successfully" } else { Copy-Item "$SourcePath\CustomModule_V1.psm1" -Destination $enModPath -Force -Recurse try { Import-Module "$SourcePath\PSWriteHTML" Write-Host "HTML Module Loaded Successfully" } catch { Write-Host "Failed to load HTML Module" $Error[0] } } Write-Host "Testing Custom Module" if(Test-Path "$SourcePath\CustomModule_V1.psm1") { Write-Host "Already Present Custom Module" Import-Module "$SourcePath\CustomModule_V1.psm1" Write-Host "Custom Module Loaded Successfully" } Else { try { Copy-Item "$SourcePath\CustomModule_V1.psm1" -Destination $enModPath -Force -Recurse try { Import-Module "$SourcePath\CustomModule_V1.psm1" Write-Host "Custom Module Loaded Successfully" } catch { Write-Host "Failed to load Custom Module" $Error[0] } } catch { Write-Host $Error[0] } } } Function Compare-Transforms { param($ExpectedCSVFile,$InputMSIFile,$InputMSTFile) $finobj=@() $obj=@() $ExpValues=Import-Csv $ExpectedCSVFile #$A=Get-MSIProperties -Field Property -MSIFile $InputMSIFile $PropTable=Apply-Transforms -SourceMSI $InputMSIFile -SourceMST $InputMSTFile -DBTable Property -Table1 1 -table2 2 $RegTable=Apply-Transforms -SourceMSI $InputMSIFile -SourceMST $InputMSTFile -DBTable Registry -Table1 6 -table2 3 $obj+=$PropTable $obj+=$RegTable foreach($1obj in $obj) { $Prop=$1obj.Name $CurPropVal=$1obj.Value $ExpValues = Import-Csv $ExpectedCSVFile | where{$_.Property -eq $Prop} if($ExpValues) { if($CurPropVal -eq $ExpValues.Value) { $properties = [ordered]@{ Property = $Prop ExpectedValue = $ExpValues.value CurrentValue = $CurPropVal Match_Status = "Matched" } $obj=New-Object PSObject -Property $properties $finobj+=$obj } else { $properties = [ordered]@{ Property = $Prop ExpectedValue = $ExpValues.value CurrentValue = $CurPropVal Match_Status = "Not Matched" } $obj=New-Object PSObject -Property $properties $finobj+=$obj } } } return $finobj } Function Compare-Transform { param($ExpectedCSVFile,$InputMSIFile,$InputMSTFile,$DBTable) $finobj=@() $ExpValues=Import-Csv $ExpectedCSVFile #$A=Get-MSIProperties -Field Property -MSIFile $InputMSIFile $a=Apply-Transform -SourceMSI $InputMSIFile -SourceMST $InputMSTFile -DBTable Property foreach($ExpValue in $ExpValues) { $Curval=$a.($ExpValue.Property) if($Curval -eq $expValue.value) { $properties = [ordered]@{ Property = $ExpValue.Property ExpectedValue = $ExpValue.value CurrentValue = $Curval Match_Status = "Matched" } $obj=New-Object PSObject -Property $properties $finobj+=$obj } Else { $properties = [ordered]@{ Property = $ExpValue.Property ExpectedValue = $ExpValue.value CurrentValue = $Curval Match_Status = "Not Matched" } $obj=New-Object PSObject -Property $properties $finobj+=$obj } } return $finobj } Function Equated-Transforms { param($InputMSIFile,$InputMSTFile) $finobj=@() $obj=@() $ExpValues=getValue $PropTable=Apply-Transforms -SourceMSI $InputMSIFile -SourceMST $InputMSTFile -DBTable Property -Table1 1 -table2 2 $RegTable=Apply-Transforms -SourceMSI $InputMSIFile -SourceMST $InputMSTFile -DBTable Registry -Table1 6 -table2 3 $obj+=$PropTable $obj+=$RegTable #$obj foreach($ExpValue in $ExpValues) { #$ExpValue.Property $curVal=$obj | where{$_.Name -match $ExpValue.Property} | select -ExpandProperty Value $ExpVal=$ExpValue.Value $Prop=$ExpValue.Property if($ExpVal -eq $curVal) { $OutObj=New-Object PSObject $OutObj | Add-Member -MemberType NoteProperty -Name Property -Value $Prop $OutObj | Add-Member -MemberType NoteProperty -Name Current_Value -Value $curVal $OutObj | Add-Member -MemberType NoteProperty -Name Expected_Value -Value $ExpVal $OutObj | Add-Member -MemberType NoteProperty -Name Match_Status -Value Matched $finobj += $OutObj } else { $OutObj=New-Object PSObject $OutObj | Add-Member -MemberType NoteProperty -Name Property -Value $Prop $OutObj | Add-Member -MemberType NoteProperty -Name Current_Value -Value $curVal $OutObj | Add-Member -MemberType NoteProperty -Name Expected_Value -Value $ExpVal $OutObj | Add-Member -MemberType NoteProperty -Name Match_Status -Value "Not Matched" $finobj += $OutObj } } return $finobj } Function Apply-Transform { Param($SourceMSI,$SourceMST,$DBTable) $TempMSI = "$SourceMSI.tmp" $TempMST = "$SourceMST.tmp" Copy-Item $SourceMSI $TempMSI -Force Copy-Item $SourceMST $TempMST -Force $WindowsInstaller = New-Object -ComObject WindowsInstaller.Installer #Open the database in Direct read/write without Transaction (2) $MSIDatabase1 = $WindowsInstaller.GetType().InvokeMember('OpenDatabase' , 'InvokeMethod' , $Null, $WindowsInstaller, @($TempMSI, 2)) $MSIDatabase1.GetType().InvokeMember('ApplyTransform' , 'InvokeMethod' , $Null , $MSIDatabase1 , @($TempMST, 0)) $Query = ("SELECT * FROM $DBTable") #Opens a data view to the MSI based on the query created. $View = $MSIDatabase1.GetType().InvokeMember('OpenView', 'InvokeMethod', $null, $MSIDatabase1, ($Query)) $null = $View.GetType().InvokeMember('Execute', 'InvokeMethod', $null, $View, $null) $hash = @{} # Add File information (Note this adds the full File information Porperties so can call with <Var>.File |Select * $hash.Add('File',$TempMSI) WHILE ($Record = $View.GetType().InvokeMember('Fetch', 'InvokeMethod', $null, $View, $null)) { $name = $Record.GetType().InvokeMember('StringData', 'GetProperty', $null, $Record, 1) $value = $hashMSIValue = $Record.GetType().InvokeMember('StringData', 'GetProperty', $null, $Record, 2) $hash.Add($name,$value) } # Push Hash table into a PSCustom object $msiProperties = [pscustomobject]$hash # I'm not sure If I have everything required to close out here properly from applying the transform. $null = $MSIDatabase1.GetType().InvokeMember('Commit' , 'InvokeMethod' , $Null , $MSIDatabase1 , $Null) $null = $view.GetType().InvokeMember('Close', 'InvokeMethod', $null, $view, $null) # Really important part to be able to release the opened files and delete $null = [Runtime.Interopservices.Marshal]::ReleaseComObject($view) $null = [Runtime.Interopservices.Marshal]::ReleaseComObject($MSIDatabase1) $null = [Runtime.Interopservices.Marshal]::ReleaseComObject($WindowsInstaller) [GC]::Collect() return $hash } function getValue($formTitle, $textTitle){ $global:AllValues=@() $global:AllValues += New-Object -TypeName psobject -Property @{Property="ALLUSERS"; Value="1"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="ARPNOREPAIR"; Value="1"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="ARPNOMODIFY"; Value="1"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="ARPNOREMOVE"; Value="1"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="USERNAME"; Value="Authorised User"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="ProductLanguage"; Value="1033"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="REBOOT"; Value="ReallySuppress"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="ROOTDRIVE"; Value="C:\"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="ALLUSERS"; Value="1"} [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") $objForm = New-Object System.Windows.Forms.Form $objForm.Text = $formTitle $objForm.Size = New-Object System.Drawing.Size(300,450) $objForm.StartPosition = "CenterScreen" $objForm.KeyPreview = $True $objForm.Add_KeyDown({if ($_.KeyCode -eq "Enter") {$x=$objTextBox.Text;$objForm.Close()}}) $objForm.Add_KeyDown({if ($_.KeyCode -eq "Escape") {$objForm.Close()}}) $OKButton = New-Object System.Windows.Forms.Button $OKButton.Location = New-Object System.Drawing.Size(75,370) $OKButton.Size = New-Object System.Drawing.Size(75,23) $OKButton.Text = "OK" $OKButton.Add_Click({$Script:userInput=$objTextBox.Text;$objForm.Close()}) $objForm.Controls.Add($OKButton) $CANCELButton = New-Object System.Windows.Forms.Button $CANCELButton.Location = New-Object System.Drawing.Size(150,370) $CANCELButton.Size = New-Object System.Drawing.Size(75,23) $CANCELButton.Text = "CANCEL" $CANCELButton.Add_Click({$objForm.Close()}) $objForm.Controls.Add($CANCELButton) $objTextBox = New-Object System.Windows.Forms.TextBox $objTextBox.Location = New-Object System.Drawing.Size(120,50) $objTextBox.Size = New-Object System.Drawing.Size(160,20) $objTextBox.Text=$env:USERNAME $objForm.Controls.Add($objTextBox) $objTextBox1 = New-Object System.Windows.Forms.TextBox $objTextBox1.Location = New-Object System.Drawing.Size(120,80) $objTextBox1.Size = New-Object System.Drawing.Size(160,20) $objForm.Controls.Add($objTextBox1) $objTextBox2 = New-Object System.Windows.Forms.TextBox $objTextBox2.Location = New-Object System.Drawing.Size(120,110) $objTextBox2.Size = New-Object System.Drawing.Size(160,20) $objForm.Controls.Add($objTextBox2) $objTextBox3 = New-Object System.Windows.Forms.TextBox $objTextBox3.Location = New-Object System.Drawing.Size(120,140) $objTextBox3.Size = New-Object System.Drawing.Size(160,20) $objForm.Controls.Add($objTextBox3) $objTextBox4 = New-Object System.Windows.Forms.TextBox $objTextBox4.Location = New-Object System.Drawing.Size(120,170) $objTextBox4.Size = New-Object System.Drawing.Size(160,20) $objForm.Controls.Add($objTextBox4) $objTextBox5 = New-Object System.Windows.Forms.TextBox $objTextBox5.Location = New-Object System.Drawing.Size(120,200) $objTextBox5.Size = New-Object System.Drawing.Size(160,20) $objForm.Controls.Add($objTextBox5) $objTextBox6 = New-Object System.Windows.Forms.TextBox $objTextBox6.Location = New-Object System.Drawing.Size(120,230) $objTextBox6.Size = New-Object System.Drawing.Size(160,20) $objForm.Controls.Add($objTextBox6) $objTextBox7 = New-Object System.Windows.Forms.TextBox $objTextBox7.Location = New-Object System.Drawing.Size(120,260) $objTextBox7.Size = New-Object System.Drawing.Size(160,20) $objForm.Controls.Add($objTextBox7) $objTextBox8 = New-Object System.Windows.Forms.TextBox $objTextBox8.Location = New-Object System.Drawing.Size(120,290) $objTextBox8.Size = New-Object System.Drawing.Size(160,20) $objForm.Controls.Add($objTextBox8) $objTextBox9 = New-Object System.Windows.Forms.TextBox $objTextBox9.Location = New-Object System.Drawing.Size(120,320) $objTextBox9.Size = New-Object System.Drawing.Size(160,20) $objForm.Controls.Add($objTextBox9) $objLabelMain = New-Object System.Windows.Forms.Label $objLabelMain.Location = New-Object System.Drawing.Size(100,20) $objLabelMain.Size = New-Object System.Drawing.Size(280,30) $objLabelMain.Text = "Enter your Input" $objForm.Controls.Add($objLabelMain) $objLabel = New-Object System.Windows.Forms.Label $objLabel.Location = New-Object System.Drawing.Size(20,50) $objLabel.Size = New-Object System.Drawing.Size(280,30) $objLabel.Text = "Engineer Name" $objForm.Controls.Add($objLabel) $objLabel1 = New-Object System.Windows.Forms.Label $objLabel1.Location = New-Object System.Drawing.Size(20,80) $objLabel1.Size = New-Object System.Drawing.Size(280,30) $objLabel1.Text = "Manufacturer" $objForm.Controls.Add($objLabel1) $objLabel2 = New-Object System.Windows.Forms.Label $objLabel2.Location = New-Object System.Drawing.Size(20,110) $objLabel2.Size = New-Object System.Drawing.Size(280,30) $objLabel2.Text = "Product Name" $objForm.Controls.Add($objLabel2) $objLabel3 = New-Object System.Windows.Forms.Label $objLabel3.Location = New-Object System.Drawing.Size(20,140) $objLabel3.Size = New-Object System.Drawing.Size(280,30) $objLabel3.Text = "Version" $objForm.Controls.Add($objLabel3) $objLabel4 = New-Object System.Windows.Forms.Label $objLabel4.Location = New-Object System.Drawing.Size(20,170) $objLabel4.Size = New-Object System.Drawing.Size(280,30) $objLabel4.Text = "ProductCode" $objForm.Controls.Add($objLabel4) $objLabel5 = New-Object System.Windows.Forms.Label $objLabel5.Location = New-Object System.Drawing.Size(20,200) $objLabel5.Size = New-Object System.Drawing.Size(280,30) $objLabel5.Text = "UpgradeCode" $objForm.Controls.Add($objLabel5) $objLabel6 = New-Object System.Windows.Forms.Label $objLabel6.Location = New-Object System.Drawing.Size(20,230) $objLabel6.Size = New-Object System.Drawing.Size(280,30) $objLabel6.Text = "FJREF" $objForm.Controls.Add($objLabel6) $objLabel7 = New-Object System.Windows.Forms.Label $objLabel7.Location = New-Object System.Drawing.Size(20,260) $objLabel7.Size = New-Object System.Drawing.Size(280,30) $objLabel7.Text = "Company" $objForm.Controls.Add($objLabel7) $objLabel8 = New-Object System.Windows.Forms.Label $objLabel8.Location = New-Object System.Drawing.Size(20,290) $objLabel8.Size = New-Object System.Drawing.Size(280,30) $objLabel8.Text = "INSTALLDIR" $objForm.Controls.Add($objLabel8) $objLabel9 = New-Object System.Windows.Forms.Label $objLabel9.Location = New-Object System.Drawing.Size(20,320) $objLabel9.Size = New-Object System.Drawing.Size(280,30) $objLabel9.Text = "Audit Key" $objForm.Controls.Add($objLabel9) $objForm.Topmost = $True $OKButton.add_click({ $global:AllValues += New-Object -TypeName psobject -Property @{Property="Author"; Value="Fujitsu - $($objTextBox.Text)"} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$($objLabel1.Text); Value=$($objTextBox2.Text)} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel2.Text; Value=$objTextBox2.Text} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel3.Text; Value=$objTextBox3.Text} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel4.Text; Value=$objTextBox4.Text} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel5.Text; Value=$objTextBox5.Text} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel6.Text; Value=$objTextBox6.Text} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel7.Text; Value=$objTextBox7.Text} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel8.Text; Value=$objTextBox8.Text} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel9.Text; Value=$objTextBox9.Text} }) $objForm.Add_Shown({$objForm.Activate()}) [void] $objForm.ShowDialog() return $global:AllValues } Function Equated-Transforms { param($InputMSIFile,$InputMSTFile) $finobj=@() $obj=@() $ExpValues=getValue $PropTable=Apply-Transforms -SourceMSI $InputMSIFile -SourceMST $InputMSTFile -DBTable Property -Table1 1 -table2 2 $RegTable=Apply-Transforms -SourceMSI $InputMSIFile -SourceMST $InputMSTFile -DBTable Registry -Table1 6 -table2 3 $obj+=$PropTable $obj+=$RegTable #$obj foreach($ExpValue in $ExpValues) { #$ExpValue.Property $curVal=$obj | where{$_.Name -match $ExpValue.Property} | select -ExpandProperty Value $ExpVal=$ExpValue.Value $Prop=$ExpValue.Property if($ExpVal -eq $curVal) { $OutObj=New-Object PSObject $OutObj | Add-Member -MemberType NoteProperty -Name Property -Value $Prop $OutObj | Add-Member -MemberType NoteProperty -Name Current_Value -Value $curVal $OutObj | Add-Member -MemberType NoteProperty -Name Expected_Value -Value $ExpVal $OutObj | Add-Member -MemberType NoteProperty -Name Match_Status -Value Matched $finobj += $OutObj } else { $OutObj=New-Object PSObject $OutObj | Add-Member -MemberType NoteProperty -Name Property -Value $Prop $OutObj | Add-Member -MemberType NoteProperty -Name Current_Value -Value $curVal $OutObj | Add-Member -MemberType NoteProperty -Name Expected_Value -Value $ExpVal $OutObj | Add-Member -MemberType NoteProperty -Name Match_Status -Value "Not Matched" $finobj += $OutObj } } return $finobj } Function Get-DetailsFromWord1($DocumentPath) { if(Get-Process -Name WINWORD -ErrorAction SilentlyContinue) { Stop-Process -Name WINWORD -Force } $CusObj=New-Object PSObject $finObj=@() $word = New-Object -ComObject Word.application $document = $word.Documents.Open($documentPath) $word.Visible=$false #$document.Tables | Get-Member $Vendor = $document.Tables[4].Cell(1,2).range.text $Appname = $document.Tables[4].Cell(2,2).range.text $Version =$document.Tables[4].Cell(3,2).range.text $PKGRef =$document.Tables[3].Cell(1,2).range.text $Packagname =$document.Tables[11].Cell(2,2).range.text $Packagname $document.close() $CusObj | Add-Member -MemberType NoteProperty -Name Name -Value Vendor $CusObj | Add-Member -MemberType NoteProperty -Name Value -Value $Vendor $finObj += $CusObj $CusObj1=New-Object PSObject $CusObj1 | Add-Member -MemberType NoteProperty -Name Name -Value AppName $CusObj1 | Add-Member -MemberType NoteProperty -Name Value -Value $Appname $finObj += $CusObj1 $CusObj2=New-Object PSObject $CusObj2 | Add-Member -MemberType NoteProperty -Name Name -Value Version $CusObj2 | Add-Member -MemberType NoteProperty -Name Value -Value $Version $finObj += $CusObj2 $CusObj3=New-Object PSObject $CusObj3 | Add-Member -MemberType NoteProperty -Name Name -Value PKGRef $CusObj3 | Add-Member -MemberType NoteProperty -Name Value -Value $PKGRef $finObj += $CusObj3 $CusObj4=New-Object PSObject $CusObj4 | Add-Member -MemberType NoteProperty -Name Name -Value Packagname $CusObj4 | Add-Member -MemberType NoteProperty -Name Value -Value $Packagname $finObj += $CusObj4 $word.Quit() return $finObj } Function Compare-CurrentandExpected { param($ExpectedCSVFile,$InputMSIFile) $finobj=@() $ExpValues=Import-Csv $ExpectedCSVFile $A=Get-MSIProperties -Field Property -MSIFile $InputMSIFile foreach($ExpValue in $ExpValues) { $Curval=$a.($ExpValue.Property) if($Curval -eq $expValue.value) { $properties = [ordered]@{ Property = $ExpValue.Property ExpectedValue = $ExpValue.value CurrentValue = $Curval Match_Status = "Matched" } $obj=New-Object PSObject -Property $properties $finobj+=$obj } Else { $properties = [ordered]@{ Property = $ExpValue.Property ExpectedValue = $ExpValue.value CurrentValue = $Curval Match_Status = "Not Matched" } $obj=New-Object PSObject -Property $properties $finobj+=$obj } } return $finobj } function getValue($formTitle, $textTitle){ $global:AllValues=@() $global:AllValues += New-Object -TypeName psobject -Property @{Property="ALLUSERS"; Value="1"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="ARPNOREPAIR"; Value="1"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="ARPNOMODIFY"; Value="1"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="ARPNOREMOVE"; Value="1"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="USERNAME"; Value="Authorised User"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="ProductLanguage"; Value="1033"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="REBOOT"; Value="ReallySuppress"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="ROOTDRIVE"; Value="C:\"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="ALLUSERS"; Value="1"} [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") $objForm = New-Object System.Windows.Forms.Form $objForm.Text = $formTitle $objForm.Size = New-Object System.Drawing.Size(300,450) $objForm.StartPosition = "CenterScreen" $objForm.KeyPreview = $True $objForm.Add_KeyDown({if ($_.KeyCode -eq "Enter") {$x=$objTextBox.Text;$objForm.Close()}}) $objForm.Add_KeyDown({if ($_.KeyCode -eq "Escape") {$objForm.Close()}}) $OKButton = New-Object System.Windows.Forms.Button $OKButton.Location = New-Object System.Drawing.Size(75,370) $OKButton.Size = New-Object System.Drawing.Size(75,23) $OKButton.Text = "OK" $OKButton.Add_Click({$Script:userInput=$objTextBox.Text;$objForm.Close()}) $objForm.Controls.Add($OKButton) $CANCELButton = New-Object System.Windows.Forms.Button $CANCELButton.Location = New-Object System.Drawing.Size(150,370) $CANCELButton.Size = New-Object System.Drawing.Size(75,23) $CANCELButton.Text = "CANCEL" $CANCELButton.Add_Click({$objForm.Close()}) $objForm.Controls.Add($CANCELButton) $objTextBox = New-Object System.Windows.Forms.TextBox $objTextBox.Location = New-Object System.Drawing.Size(120,50) $objTextBox.Size = New-Object System.Drawing.Size(160,20) $objTextBox.Text=$env:USERNAME $objForm.Controls.Add($objTextBox) $objTextBox1 = New-Object System.Windows.Forms.TextBox $objTextBox1.Location = New-Object System.Drawing.Size(120,80) $objTextBox1.Size = New-Object System.Drawing.Size(160,20) $objForm.Controls.Add($objTextBox1) $objTextBox2 = New-Object System.Windows.Forms.TextBox $objTextBox2.Location = New-Object System.Drawing.Size(120,110) $objTextBox2.Size = New-Object System.Drawing.Size(160,20) $objForm.Controls.Add($objTextBox2) $objTextBox3 = New-Object System.Windows.Forms.TextBox $objTextBox3.Location = New-Object System.Drawing.Size(120,140) $objTextBox3.Size = New-Object System.Drawing.Size(160,20) $objForm.Controls.Add($objTextBox3) $objTextBox4 = New-Object System.Windows.Forms.TextBox $objTextBox4.Location = New-Object System.Drawing.Size(120,170) $objTextBox4.Size = New-Object System.Drawing.Size(160,20) $objForm.Controls.Add($objTextBox4) $objTextBox5 = New-Object System.Windows.Forms.TextBox $objTextBox5.Location = New-Object System.Drawing.Size(120,200) $objTextBox5.Size = New-Object System.Drawing.Size(160,20) $objForm.Controls.Add($objTextBox5) $objTextBox6 = New-Object System.Windows.Forms.TextBox $objTextBox6.Location = New-Object System.Drawing.Size(120,230) $objTextBox6.Size = New-Object System.Drawing.Size(160,20) $objForm.Controls.Add($objTextBox6) $objTextBox7 = New-Object System.Windows.Forms.TextBox $objTextBox7.Location = New-Object System.Drawing.Size(120,260) $objTextBox7.Size = New-Object System.Drawing.Size(160,20) $objForm.Controls.Add($objTextBox7) $objTextBox8 = New-Object System.Windows.Forms.TextBox $objTextBox8.Location = New-Object System.Drawing.Size(120,290) $objTextBox8.Size = New-Object System.Drawing.Size(160,20) $objForm.Controls.Add($objTextBox8) $objTextBox9 = New-Object System.Windows.Forms.TextBox $objTextBox9.Location = New-Object System.Drawing.Size(120,320) $objTextBox9.Size = New-Object System.Drawing.Size(160,20) $objForm.Controls.Add($objTextBox9) $objLabelMain = New-Object System.Windows.Forms.Label $objLabelMain.Location = New-Object System.Drawing.Size(100,20) $objLabelMain.Size = New-Object System.Drawing.Size(280,30) $objLabelMain.Text = "Enter your Input" $objForm.Controls.Add($objLabelMain) $objLabel = New-Object System.Windows.Forms.Label $objLabel.Location = New-Object System.Drawing.Size(20,50) $objLabel.Size = New-Object System.Drawing.Size(280,30) $objLabel.Text = "Engineer Name" $objForm.Controls.Add($objLabel) $objLabel1 = New-Object System.Windows.Forms.Label $objLabel1.Location = New-Object System.Drawing.Size(20,80) $objLabel1.Size = New-Object System.Drawing.Size(280,30) $objLabel1.Text = "Manufacturer" $objForm.Controls.Add($objLabel1) $objLabel2 = New-Object System.Windows.Forms.Label $objLabel2.Location = New-Object System.Drawing.Size(20,110) $objLabel2.Size = New-Object System.Drawing.Size(280,30) $objLabel2.Text = "Product Name" $objForm.Controls.Add($objLabel2) $objLabel3 = New-Object System.Windows.Forms.Label $objLabel3.Location = New-Object System.Drawing.Size(20,140) $objLabel3.Size = New-Object System.Drawing.Size(280,30) $objLabel3.Text = "Version" $objForm.Controls.Add($objLabel3) $objLabel4 = New-Object System.Windows.Forms.Label $objLabel4.Location = New-Object System.Drawing.Size(20,170) $objLabel4.Size = New-Object System.Drawing.Size(280,30) $objLabel4.Text = "ProductCode" $objForm.Controls.Add($objLabel4) $objLabel5 = New-Object System.Windows.Forms.Label $objLabel5.Location = New-Object System.Drawing.Size(20,200) $objLabel5.Size = New-Object System.Drawing.Size(280,30) $objLabel5.Text = "UpgradeCode" $objForm.Controls.Add($objLabel5) $objLabel6 = New-Object System.Windows.Forms.Label $objLabel6.Location = New-Object System.Drawing.Size(20,230) $objLabel6.Size = New-Object System.Drawing.Size(280,30) $objLabel6.Text = "FJREF" $objForm.Controls.Add($objLabel6) $objLabel7 = New-Object System.Windows.Forms.Label $objLabel7.Location = New-Object System.Drawing.Size(20,260) $objLabel7.Size = New-Object System.Drawing.Size(280,30) $objLabel7.Text = "Company" $objForm.Controls.Add($objLabel7) $objLabel8 = New-Object System.Windows.Forms.Label $objLabel8.Location = New-Object System.Drawing.Size(20,290) $objLabel8.Size = New-Object System.Drawing.Size(280,30) $objLabel8.Text = "INSTALLDIR" $objForm.Controls.Add($objLabel8) $objLabel9 = New-Object System.Windows.Forms.Label $objLabel9.Location = New-Object System.Drawing.Size(20,320) $objLabel9.Size = New-Object System.Drawing.Size(280,30) $objLabel9.Text = "Audit Key" $objForm.Controls.Add($objLabel9) $objForm.Topmost = $True $OKButton.add_click({ $global:AllValues += New-Object -TypeName psobject -Property @{Property="Author"; Value="Fujitsu - $($objTextBox.Text)"} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$($objLabel1.Text); Value=$($objTextBox2.Text)} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel2.Text; Value=$objTextBox2.Text} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel3.Text; Value=$objTextBox3.Text} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel4.Text; Value=$objTextBox4.Text} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel5.Text; Value=$objTextBox5.Text} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel6.Text; Value=$objTextBox6.Text} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel7.Text; Value=$objTextBox7.Text} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel8.Text; Value=$objTextBox8.Text} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel9.Text; Value=$objTextBox9.Text} }) $objForm.Add_Shown({$objForm.Activate()}) [void] $objForm.ShowDialog() return $global:AllValues } Function Compare-Transform { param($ExpectedCSVFile,$InputMSIFile,$InputMSTFile,$DBTable) $finobj=@() $ExpValues=Import-Csv $ExpectedCSVFile $A=Apply-Transform -SourceMSI $InputMSIFile -SourceMST $InputMSTFile -DBTable Property foreach($ExpValue in $ExpValues) { $Curval=$a.($ExpValue.Property) if($Curval -eq $expValue.value) { $properties = [ordered]@{ Property = $ExpValue.Property ExpectedValue = $ExpValue.value CurrentValue = $Curval Match_Status = "Matched" } $obj=New-Object PSObject -Property $properties $finobj+=$obj } Else { $properties = [ordered]@{ Property = $ExpValue.Property ExpectedValue = $ExpValue.value CurrentValue = $Curval Match_Status = "Not Matched" } $obj=New-Object PSObject -Property $properties $finobj+=$obj } } return $finobj } Function Install-Prereq { $enModPath="D:\PowerShell\Pacjaging\QA_TOOL\Modules" $precheck=Check-Prereq -enModPath $enModPath if($precheck -eq 3) { "All modules present" } else { $wshell = New-Object -ComObject Wscript.Shell $pop=$wshell.Popup("There are Missing Modules. Please copy and rerun.",0,"Install Module",0x1) } } Function Load-ActionBox { # Load Windows Forms & Drawing classes. [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") # Create base form. $objForm = New-Object System.Windows.Forms.Form $objForm.Text = "Select Action" $objForm.Size = New-Object System.Drawing.Size(300,170) $objForm.StartPosition = "CenterScreen" # Configure keyboard intercepts for ESC & ENTER. $objForm.KeyPreview = $True $objForm.Add_KeyDown({ if ($_.KeyCode -eq "Enter") { $x=$objListBox.SelectedItem $objForm.Close() } }) $objForm.Add_KeyDown({ if ($_.KeyCode -eq "Escape") {$objForm.Close() } }) # Create OK button. $OKButton = New-Object System.Windows.Forms.Button $OKButton.Location = New-Object System.Drawing.Size(75,90) $OKButton.Size = New-Object System.Drawing.Size(75,23) $OKButton.Text = "OK" $OKButton.Add_Click({$global:x=$objListBox.SelectedItem;$objForm.Close()}) #$OKButton.Add_Click({$x=$objListBox.SelectedItem;$objForm.Close()}) $objForm.Controls.Add($OKButton) $CancelButton = New-Object System.Windows.Forms.Button $CancelButton.Location = New-Object System.Drawing.Size(150,90) $CancelButton.Size = New-Object System.Drawing.Size(75,23) $CancelButton.Text = "Cancel" $CancelButton.Add_Click({$objForm.Close()}) $objForm.Controls.Add($CancelButton) $objLabel = New-Object System.Windows.Forms.Label $objLabel.Location = New-Object System.Drawing.Size(10,20) $objLabel.Size = New-Object System.Drawing.Size(280,20) $objLabel.Text = "Please select an action:" $objForm.Controls.Add($objLabel) $objListBox = New-Object System.Windows.Forms.ListBox $objListBox.Location = New-Object System.Drawing.Size(10,40) $objListBox.Size = New-Object System.Drawing.Size(260,20) $objListBox.Height = 50 [void] $objListBox.Items.Add("Install") [void] $objListBox.Items.Add("Uninstall") $objForm.Controls.Add($objListBox) # Force list box to display on top of other windows. $objForm.TopMost = $true $objForm.Add_Shown({$objForm.Activate()}) [void] $objForm.ShowDialog() return $x } Function Check-InstallUninstall { param($MainFolderPath) $INterPath= Split-Path $MainFolderPath $SorurceDirectory=Split-Path $INterPath if(Test-Path "$SorurceDirectory\Deploy-Application.exe") { Write-Host "Deploy-Application.exe found successfully" } else { Write-Host "Deploy-Application.exe was not found.Exiting" return } $ps1Files=Get-ChildItem $SorurceDirectory | where {$_.name -match ".ps1"} | select -ExpandProperty Name if($ps1Files.count -eq 1) { Write-Host "Ps1 file count is 1. Can proceed further" } else { Write-Host "Ps1 file count is more than one or no file present. Cannot proceed further" return } if($Action -eq "Install") { cd $SorurceDirectory try { .\Deploy-Application.exe .\Google_Chrome_116.0.5845.188_x64_1.ps1 -DeploymentType 'Install' -DeployMode 'Silent' Write-Host "Successfully initiated the Installation of the Package" } catch { Write-Host "Error in Installing" Write-Host $Error[0].Exception.Message } } elseif($Action -eq "UnInstall") { cd $SorurceDirectory try { .\Deploy-Application.exe .\Google_Chrome_116.0.5845.188_x64_1.ps1 -DeploymentType 'Uninstall' -DeployMode 'Silent' Write-Host "Successfully initiated the Uninstalltion of the Package" } catch { Write-Host "Error in Uninstalling" Write-Host $Error[0].Exception.Message } } else { Write-Host "Wrong Action Selected" } } Function Install-Prereq { $enModPath="D:\PowerShell\Pacjaging\QA_TOOL\Modules" $precheck=Check-Prereq -enModPath $enModPath if($precheck -eq 3) { "All modules present" } else { $wshell = New-Object -ComObject Wscript.Shell $pop=$wshell.Popup("There are Missing Modules. Please copy and rerun.",0,"Install Module",0x1) } } function get-ValueIn($formTitle, $textTitle,$wordDocPath){ $global:AllValues=@() $global:AllValues += New-Object -TypeName psobject -Property @{Property="ALLUSERS"; Value="1"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="ARPNOREPAIR"; Value="1"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="ARPNOMODIFY"; Value="1"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="ARPNOREMOVE"; Value="1"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="USERNAME"; Value="Authorised User"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="ProductLanguage"; Value="1033"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="REBOOT"; Value="ReallySuppress"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="ROOTDRIVE"; Value="C:\"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="ALLUSERS"; Value="1"} $ValuesFromWord=Get-DataFromWord -DocFilePath $wordDocPath $manuFacturer=($ValuesFromWord | where{$_.Property -match "ApplicationVendor"} | select -ExpandProperty Value) $productName=($ValuesFromWord | where{$_.Property -match "ApplicationName"} | select -ExpandProperty Value) $Version=($ValuesFromWord | where{$_.Property -match "Version"} | select -ExpandProperty Value) $PackageName=($ValuesFromWord | where{$_.Property -match "PackageName"} | select -ExpandProperty Value) $fjref=($ValuesFromWord | where{$_.Property -match "APSReference"} | select -ExpandProperty Value) $AuditKey=($ValuesFromWord | where{$_.Property -match "AuditKey"} | select -ExpandProperty Value) $ProdCode=($ValuesFromWord | where{$_.Property -match "ProdCode"} | select -ExpandProperty Value) $installPath=$ValuesFromWord | where{$_.Property -match "INSTALLDIR"} | select -ExpandProperty Value $RegVal=$ValuesFromWord | where{$_.Property -match "RegVal"} | select -ExpandProperty Value [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") $objForm = New-Object System.Windows.Forms.Form $objForm.Text = $formTitle $objForm.Size = New-Object System.Drawing.Size(300,450) $objForm.StartPosition = "CenterScreen" $objForm.AutoSize=$True $objForm.AutoScale=$True $objForm.KeyPreview = $True $objForm.Add_KeyDown({if ($_.KeyCode -eq "Enter") {$x=$objTextBox.Text;$objForm.Close()}}) $objForm.Add_KeyDown({if ($_.KeyCode -eq "Escape") {$objForm.Close()}}) $OKButton = New-Object System.Windows.Forms.Button $OKButton.Location = New-Object System.Drawing.Size(75,370) $OKButton.Size = New-Object System.Drawing.Size(75,23) $OKButton.Text = "OK" $OKButton.Add_Click({$Script:userInput=$objTextBox.Text;$objForm.Close()}) $objForm.Controls.Add($OKButton) $CANCELButton = New-Object System.Windows.Forms.Button $CANCELButton.Location = New-Object System.Drawing.Size(150,370) $CANCELButton.Size = New-Object System.Drawing.Size(75,23) $CANCELButton.Text = "CANCEL" $CANCELButton.Add_Click({$objForm.Close()}) $objForm.Controls.Add($CANCELButton) $objTextBox = New-Object System.Windows.Forms.TextBox $objTextBox.Location = New-Object System.Drawing.Size(120,50) $objTextBox.Size = New-Object System.Drawing.Size(230,20) $objTextBox.Text=$env:USERNAME $objTextBox.AutoSize=$True $objForm.Controls.Add($objTextBox) $objTextBox1 = New-Object System.Windows.Forms.TextBox $objTextBox1.Location = New-Object System.Drawing.Size(120,80) $objTextBox1.Size = New-Object System.Drawing.Size(230,20) $objTextBox1.Text=$manuFacturer $objTextBox1.AutoSize=$True $objForm.Controls.Add($objTextBox1) $objTextBox2 = New-Object System.Windows.Forms.TextBox $objTextBox2.Location = New-Object System.Drawing.Size(120,110) $objTextBox2.Size = New-Object System.Drawing.Size(230,20) $objTextBox2.AutoSize=$True $objTextBox2.Text=$productName $objForm.Controls.Add($objTextBox2) $objTextBox3 = New-Object System.Windows.Forms.TextBox $objTextBox3.Location = New-Object System.Drawing.Size(120,140) $objTextBox3.Size = New-Object System.Drawing.Size(230,20) $objTextBox3.AutoSize=$True $objTextBox3.Text=$Version $objForm.Controls.Add($objTextBox3) $objTextBox4 = New-Object System.Windows.Forms.TextBox $objTextBox4.Location = New-Object System.Drawing.Size(120,170) $objTextBox4.Size = New-Object System.Drawing.Size(230,20) $objTextBox4.AutoSize=$True $objTextBox4.Text=$ProdCode $objForm.Controls.Add($objTextBox4) $objTextBox5 = New-Object System.Windows.Forms.TextBox $objTextBox5.Location = New-Object System.Drawing.Size(120,200) $objTextBox5.Size = New-Object System.Drawing.Size(230,20) $objTextBox5.AutoSize=$True $objForm.Controls.Add($objTextBox5) $objTextBox6 = New-Object System.Windows.Forms.TextBox $objTextBox6.Location = New-Object System.Drawing.Size(120,230) $objTextBox6.Size = New-Object System.Drawing.Size(230,20) $objTextBox6.AutoSize=$True $objTextBox6.Text=$fjref $objForm.Controls.Add($objTextBox6) $objTextBox7 = New-Object System.Windows.Forms.TextBox $objTextBox7.Location = New-Object System.Drawing.Size(120,260) $objTextBox7.AutoSize=$True $objTextBox7.Size = New-Object System.Drawing.Size(230,20) $objTextBox7.Text=$RegVal $objForm.Controls.Add($objTextBox7) $objTextBox8 = New-Object System.Windows.Forms.TextBox $objTextBox8.Location = New-Object System.Drawing.Size(120,290) $objTextBox8.Size = New-Object System.Drawing.Size(230,20) $objTextBox8.AutoSize=$True $objTextBox8.Text=$installPath $objForm.Controls.Add($objTextBox8) $objTextBox9 = New-Object System.Windows.Forms.TextBox $objTextBox9.Location = New-Object System.Drawing.Size(120,320) $objTextBox9.Size = New-Object System.Drawing.Size(230,20) $objTextBox9.AutoSize=$True $objTextBox9.Text=$AuditKey $objForm.Controls.Add($objTextBox9) $objLabelMain = New-Object System.Windows.Forms.Label $objLabelMain.Location = New-Object System.Drawing.Size(180,20) $objLabelMain.Size = New-Object System.Drawing.Size(280,30) $objLabelMain.Text = "Validate Input" $objForm.Controls.Add($objLabelMain) $objLabel = New-Object System.Windows.Forms.Label $objLabel.Location = New-Object System.Drawing.Size(20,50) $objLabel.Size = New-Object System.Drawing.Size(280,30) $objLabel.Text = "Engineer Name" $objForm.Controls.Add($objLabel) $objLabel1 = New-Object System.Windows.Forms.Label $objLabel1.Location = New-Object System.Drawing.Size(20,80) $objLabel1.Size = New-Object System.Drawing.Size(280,30) $objLabel1.Text = "Manufacturer" $objForm.Controls.Add($objLabel1) $objLabel2 = New-Object System.Windows.Forms.Label $objLabel2.Location = New-Object System.Drawing.Size(20,110) $objLabel2.Size = New-Object System.Drawing.Size(280,30) $objLabel2.Text = "ProductName" $objForm.Controls.Add($objLabel2) $objLabel3 = New-Object System.Windows.Forms.Label $objLabel3.Location = New-Object System.Drawing.Size(20,140) $objLabel3.Size = New-Object System.Drawing.Size(280,30) $objLabel3.Text = "ProductVersion" $objForm.Controls.Add($objLabel3) $objLabel4 = New-Object System.Windows.Forms.Label $objLabel4.Location = New-Object System.Drawing.Size(20,170) $objLabel4.Size = New-Object System.Drawing.Size(280,30) $objLabel4.Text = "ProductCode" $objForm.Controls.Add($objLabel4) $objLabel5 = New-Object System.Windows.Forms.Label $objLabel5.Location = New-Object System.Drawing.Size(20,200) $objLabel5.Size = New-Object System.Drawing.Size(280,30) $objLabel5.Text = "UpgradeCode" $objForm.Controls.Add($objLabel5) $objLabel6 = New-Object System.Windows.Forms.Label $objLabel6.Location = New-Object System.Drawing.Size(20,230) $objLabel6.Size = New-Object System.Drawing.Size(280,30) $objLabel6.Text = "FJREF" $objForm.Controls.Add($objLabel6) $objLabel7 = New-Object System.Windows.Forms.Label $objLabel7.Location = New-Object System.Drawing.Size(20,260) $objLabel7.Size = New-Object System.Drawing.Size(280,30) $objLabel7.Text = "Package Code" $objForm.Controls.Add($objLabel7) $objLabel8 = New-Object System.Windows.Forms.Label $objLabel8.Location = New-Object System.Drawing.Size(20,290) $objLabel8.Size = New-Object System.Drawing.Size(280,30) $objLabel8.Text = "INSTALLDIR" $objForm.Controls.Add($objLabel8) $objLabel9 = New-Object System.Windows.Forms.Label $objLabel9.Location = New-Object System.Drawing.Size(20,320) $objLabel9.Size = New-Object System.Drawing.Size(280,30) $objLabel9.Text = "Audit_Key" $objForm.Controls.Add($objLabel9) $objForm.Topmost = $True $OKButton.add_click({ $global:AllValues += New-Object -TypeName psobject -Property @{Property="Author"; Value="Fujitsu - $($objTextBox.Text)"} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$($objLabel1.Text); Value=$($objTextBox1.Text)} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel2.Text; Value=$objTextBox2.Text} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel3.Text; Value=$objTextBox3.Text} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel4.Text; Value=$objTextBox4.Text} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel5.Text; Value=$objTextBox5.Text} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel6.Text; Value=$objTextBox6.Text} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel7.Text; Value=$objTextBox7.Text} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel8.Text; Value=$objTextBox8.Text} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel9.Text; Value=$objTextBox9.Text} }) $objForm.Add_Shown({$objForm.Activate()}) [void] $objForm.ShowDialog() return $global:AllValues } function get-ValueInnEw($formTitle, $textTitle,$wordDocPath) { $global:AllValues=@() $global:AllValues += New-Object -TypeName psobject -Property @{Property="ALLUSERS"; Value="1"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="ARPNOREPAIR"; Value="1"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="ARPNOMODIFY"; Value="1"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="ARPNOREMOVE"; Value="1"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="USERNAME"; Value="Authorised User"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="ProductLanguage"; Value="1033"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="REBOOT"; Value="ReallySuppress"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="ROOTDRIVE"; Value="C:\"} $global:AllValues += New-Object -TypeName psobject -Property @{Property="ALLUSERS"; Value="1"} $ValuesFromWord=Get-DataFromWordNew -DocFilePath $wordDocPath $manuFacturer=($ValuesFromWord | where{$_.Property -match "ApplicationVendor"} | select -ExpandProperty Value) $productName=($ValuesFromWord | where{$_.Property -match "ApplicationName"} | select -ExpandProperty Value) $Version=($ValuesFromWord | where{$_.Property -match "Version"} | select -ExpandProperty Value) $PackageName=($ValuesFromWord | where{$_.Property -match "PackageName"} | select -ExpandProperty Value) $fjref=($ValuesFromWord | where{$_.Property -match "APSReference"} | select -ExpandProperty Value) $AuditKey=($ValuesFromWord | where{$_.Property -match "AuditKey"} | select -ExpandProperty Value) $ProdCode=($ValuesFromWord | where{$_.Property -match "ProdCode"} | select -ExpandProperty Value) $installPath=$ValuesFromWord | where{$_.Property -match "INSTALLDIR"} | select -ExpandProperty Value $RegVal=$ValuesFromWord | where{$_.Property -match "RegVal"} | select -ExpandProperty Value [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") $objForm = New-Object System.Windows.Forms.Form $objForm.Text = $formTitle $objForm.Size = New-Object System.Drawing.Size(300,450) $objForm.StartPosition = "CenterScreen" $objForm.AutoSize=$True $objForm.AutoScale=$True $objForm.KeyPreview = $True $objForm.Add_KeyDown({if ($_.KeyCode -eq "Enter") {$x=$objTextBox.Text;$objForm.Close()}}) $objForm.Add_KeyDown({if ($_.KeyCode -eq "Escape") {$objForm.Close()}}) $OKButton = New-Object System.Windows.Forms.Button $OKButton.Location = New-Object System.Drawing.Size(75,370) $OKButton.Size = New-Object System.Drawing.Size(75,23) $OKButton.Text = "OK" $OKButton.Add_Click({$Script:userInput=$objTextBox.Text;$objForm.Close()}) $objForm.Controls.Add($OKButton) $CANCELButton = New-Object System.Windows.Forms.Button $CANCELButton.Location = New-Object System.Drawing.Size(150,370) $CANCELButton.Size = New-Object System.Drawing.Size(75,23) $CANCELButton.Text = "CANCEL" $CANCELButton.Add_Click({$objForm.Close()}) $objForm.Controls.Add($CANCELButton) $objTextBox = New-Object System.Windows.Forms.TextBox $objTextBox.Location = New-Object System.Drawing.Size(120,50) $objTextBox.Size = New-Object System.Drawing.Size(230,20) $objTextBox.Text=$env:USERNAME $objTextBox.AutoSize=$True $objForm.Controls.Add($objTextBox) $objTextBox1 = New-Object System.Windows.Forms.TextBox $objTextBox1.Location = New-Object System.Drawing.Size(120,80) $objTextBox1.Size = New-Object System.Drawing.Size(230,20) $objTextBox1.Text=$manuFacturer $objTextBox1.AutoSize=$True $objForm.Controls.Add($objTextBox1) $objTextBox2 = New-Object System.Windows.Forms.TextBox $objTextBox2.Location = New-Object System.Drawing.Size(120,110) $objTextBox2.Size = New-Object System.Drawing.Size(230,20) $objTextBox2.AutoSize=$True $objTextBox2.Text=$productName $objForm.Controls.Add($objTextBox2) $objTextBox3 = New-Object System.Windows.Forms.TextBox $objTextBox3.Location = New-Object System.Drawing.Size(120,140) $objTextBox3.Size = New-Object System.Drawing.Size(230,20) $objTextBox3.AutoSize=$True $objTextBox3.Text=$Version $objForm.Controls.Add($objTextBox3) $objTextBox4 = New-Object System.Windows.Forms.TextBox $objTextBox4.Location = New-Object System.Drawing.Size(120,170) $objTextBox4.Size = New-Object System.Drawing.Size(230,20) $objTextBox4.AutoSize=$True $objTextBox4.Text=$ProdCode $objForm.Controls.Add($objTextBox4) $objTextBox5 = New-Object System.Windows.Forms.TextBox $objTextBox5.Location = New-Object System.Drawing.Size(120,200) $objTextBox5.Size = New-Object System.Drawing.Size(230,20) $objTextBox5.AutoSize=$True $objForm.Controls.Add($objTextBox5) $objTextBox6 = New-Object System.Windows.Forms.TextBox $objTextBox6.Location = New-Object System.Drawing.Size(120,230) $objTextBox6.Size = New-Object System.Drawing.Size(230,20) $objTextBox6.AutoSize=$True $objTextBox6.Text=$fjref $objForm.Controls.Add($objTextBox6) $objTextBox7 = New-Object System.Windows.Forms.TextBox $objTextBox7.Location = New-Object System.Drawing.Size(120,260) $objTextBox7.AutoSize=$True $objTextBox7.Size = New-Object System.Drawing.Size(230,20) $objTextBox7.Text=$RegVal $objForm.Controls.Add($objTextBox7) $objTextBox8 = New-Object System.Windows.Forms.TextBox $objTextBox8.Location = New-Object System.Drawing.Size(120,290) $objTextBox8.Size = New-Object System.Drawing.Size(230,20) $objTextBox8.AutoSize=$True $objTextBox8.Text=$installPath $objForm.Controls.Add($objTextBox8) $objTextBox9 = New-Object System.Windows.Forms.TextBox $objTextBox9.Location = New-Object System.Drawing.Size(120,320) $objTextBox9.Size = New-Object System.Drawing.Size(230,20) $objTextBox9.AutoSize=$True $objTextBox9.Text=$AuditKey $objForm.Controls.Add($objTextBox9) $objLabelMain = New-Object System.Windows.Forms.Label $objLabelMain.Location = New-Object System.Drawing.Size(180,20) $objLabelMain.Size = New-Object System.Drawing.Size(280,30) $objLabelMain.Text = "Validate Input" $objForm.Controls.Add($objLabelMain) $objLabel = New-Object System.Windows.Forms.Label $objLabel.Location = New-Object System.Drawing.Size(20,50) $objLabel.Size = New-Object System.Drawing.Size(280,30) $objLabel.Text = "Engineer Name" $objForm.Controls.Add($objLabel) $objLabel1 = New-Object System.Windows.Forms.Label $objLabel1.Location = New-Object System.Drawing.Size(20,80) $objLabel1.Size = New-Object System.Drawing.Size(280,30) $objLabel1.Text = "Manufacturer" $objForm.Controls.Add($objLabel1) $objLabel2 = New-Object System.Windows.Forms.Label $objLabel2.Location = New-Object System.Drawing.Size(20,110) $objLabel2.Size = New-Object System.Drawing.Size(280,30) $objLabel2.Text = "ProductName" $objForm.Controls.Add($objLabel2) $objLabel3 = New-Object System.Windows.Forms.Label $objLabel3.Location = New-Object System.Drawing.Size(20,140) $objLabel3.Size = New-Object System.Drawing.Size(280,30) $objLabel3.Text = "ProductVersion" $objForm.Controls.Add($objLabel3) $objLabel4 = New-Object System.Windows.Forms.Label $objLabel4.Location = New-Object System.Drawing.Size(20,170) $objLabel4.Size = New-Object System.Drawing.Size(280,30) $objLabel4.Text = "ProductCode" $objForm.Controls.Add($objLabel4) $objLabel5 = New-Object System.Windows.Forms.Label $objLabel5.Location = New-Object System.Drawing.Size(20,200) $objLabel5.Size = New-Object System.Drawing.Size(280,30) $objLabel5.Text = "UpgradeCode" $objForm.Controls.Add($objLabel5) $objLabel6 = New-Object System.Windows.Forms.Label $objLabel6.Location = New-Object System.Drawing.Size(20,230) $objLabel6.Size = New-Object System.Drawing.Size(280,30) $objLabel6.Text = "FJREF" $objForm.Controls.Add($objLabel6) $objLabel7 = New-Object System.Windows.Forms.Label $objLabel7.Location = New-Object System.Drawing.Size(20,260) $objLabel7.Size = New-Object System.Drawing.Size(280,30) $objLabel7.Text = "Package Code" $objForm.Controls.Add($objLabel7) $objLabel8 = New-Object System.Windows.Forms.Label $objLabel8.Location = New-Object System.Drawing.Size(20,290) $objLabel8.Size = New-Object System.Drawing.Size(280,30) $objLabel8.Text = "INSTALLDIR" $objForm.Controls.Add($objLabel8) $objLabel9 = New-Object System.Windows.Forms.Label $objLabel9.Location = New-Object System.Drawing.Size(20,320) $objLabel9.Size = New-Object System.Drawing.Size(280,30) $objLabel9.Text = "Audit_Key" $objForm.Controls.Add($objLabel9) $objForm.Topmost = $True $OKButton.add_click({ $global:AllValues += New-Object -TypeName psobject -Property @{Property="Author"; Value="Fujitsu - $($objTextBox.Text)"} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$($objLabel1.Text); Value=$($objTextBox1.Text)} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel2.Text; Value=$objTextBox2.Text} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel3.Text; Value=$objTextBox3.Text} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel4.Text; Value=$objTextBox4.Text} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel5.Text; Value=$objTextBox5.Text} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel6.Text; Value=$objTextBox6.Text} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel7.Text; Value=$objTextBox7.Text} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel8.Text; Value=$objTextBox8.Text} $global:AllValues += New-Object -TypeName psobject -Property @{Property=$objLabel9.Text; Value=$objTextBox9.Text} }) $objForm.Add_Shown({$objForm.Activate()}) [void] $objForm.ShowDialog() return $global:AllValues } #> |