Quantcast
Channel: TechNet Blogs
Viewing all articles
Browse latest Browse all 36188

App-V 5.0 – Legacy Package Conversion Report Creation

$
0
0

Hi all,

Imagine the scenario, you have 200 packages created with 4.5+ and you want to test that they will work with App-V 5.0, how do we accomplish this?

As part of the App-V 5.0 beta 2 release it offers the ability to automatically test legacy packages to see if they are compatible for package conversion. To complete this you need to use the following Powershell cmdlet.

Test-AppvLegacyPackage

The Test-AppvLegacyPackage cmdlet will take as an input a single or set of legacy packages and perform basic pre-validation on the legacy package to test if it is compatible for package conversion to the new App-V package format.

The cmdlet only performs basic validation, such as ensuring that all files are present, or that it is a supported package version. A test that does not yield any errors does not necessarily guarantee success of a package.

Example: Test-AppvLegacyPackage –SourcePath c:\packages\4.6\7Zip915.001

What we’re going to do run this command against a specific directory. First we need to locate this directory within the Powershell console. The following can be used:

Cd c:\packages\4.6

Once the console window is in that location then we can run our test of legacy packages.

Get-ChildItem | ForEach-Object {Test-AppvLegacyPackage $_.FullName}

Notice when you run this against several hundred packages the output is only displayed in the Powershell console, you may be asking how do I output this to a useable format???

clip_image002

To make it more readable we’re going to format the output as a table and then export this data to a text file.

Get-childitem | ForEach-Object {Test-AppvLegacyPackage $_.FullName} | Format-Table -Wrap | Out-File c:\output.txt

When you open the output you get something similar to the below. It’s a great improvement from just showing it in the console window but we can make it better.

clip_image004

The next command we are going to use is Export-CliXml. The description is below:

Export-Clixml

The Export-Clixml cmdlet creates an XML-based representation of an object or objects and stores it in a file. You can then use the Import-CLIXML cmdlet to re-create the saved object based on the contents of that file.

This cmdlet is similar to ConvertTo-XML, except that Export-Clixml stores the resulting XML in a file.

ConvertTo-XML returns the XML, so you can continue to process it in Windows PowerShell.

The following command is used:

Get-childitem | ForEach-Object {Test-AppvLegacyPackage $_.FullName} | Export-Clixml -Path c:\TAL.xml

We can then open this XML file for review.

clip_image006

Once the XML has been reviewed you can see it’s not in a format which is very readable, so let’s make it more readable.

Now were going to import the XML file we created and then use the inbuilt Powershell cmdlet “Convertto-html”.

Import-Clixml -Path C:\TAL.xml | Select-Object Source, Errors, Warnings, Information | convertto-html | Out-File C:\TAL.html

clip_image008

Now that’s in a format we like but there’s no table formatting or sorting of objects. Imagine having 100 packages tested and having to scroll through and find which packages had errors or warning.

The final example is solving this problem, firstly we need to define some CSS to make the table look better.

$a = "<style>"
$a = $a + "BODY{background-color:white;font-family:Arial;}"
$a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse; font-family:Arial; font-size:12px;}"
$a = $a + "TH{height: 20px;border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:darkblue; color:white; font-size:12px;}"
$a = $a + "TD{border-width: 1px;padding: 4px;border-style: solid;border-color: black; vertical-align:top;}"
$a = $a + "</style>"

Now we have some styling we need to run a similar command with some switches, the switches of interest is the sort switch and the extra parameters in the convertto-html where we reference the style created above.

Import-Clixml -Path C:\TAL.xml | sort @{expression="Errors";Descending=$true},@{expression="Warnings";descending=$true} | Select-Object Source, Errors, Warnings, Information | convertto-html -head $a -body "<H3>Test-AppvLegacyPackage</H3>" | Out-File C:\TAL.html

Once this command has been ran you get a nice formatted HTML table with errors sorted first then warnings, so no need to scroll through a large HTML document.

clip_image010

Disclaimer
The sample scripts are not supported under any Microsoft standard support program or service. The sample scripts are provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.

Conclusion
Powershell is your friend with App-V 5.0 and this blog posts shows you how easy it is to use App-V 5.0 cmdlets and inbuilt Powershell functionality to create a formatted report testing App-V legacy packages.

David Falkus | Premier Field Engineer | Application Virtualization


Viewing all articles
Browse latest Browse all 36188

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>