Showing posts with label PowerShell. Show all posts
Showing posts with label PowerShell. Show all posts

Thursday, April 2, 2020

Automate Convertion of old App-V 4.6 packages into App-V 5.1 using Powershell

App-V 5.1 is out now. There might be a case where you need to convert old App-V 4.5 or App-V 4.6 applications to new App-V 5.1 format.If there are one or two packages it will be easy to create. But what if suppose there are some 100's of App-V 4.x apps? It will be quite complex and time consuming. 
This powershell script will make this scenario very easy. Just provide the folder where the old packages (App-V 4.5 or App-V 4.6) are kept and run the powershell script. Within some minutes, new App-V 5.1 packages will be created in the output folder. 
For Example: Create a single folder named App-V packages in C:\ drive (C:\App-V packages). Copy all the old App-V 4.x packages to this folder. Edit the powershell script and give this main folder as input to the  $appv46folder variable.

# specify the folder where bulk App-V 4.6 packages are kept

$appv46folder = "C:\App-V packages"  

NOTE: Do not create subfolders inside the main folder as it has not been handled in the PS.
Run this script where App-V 5.1 sequencer has been installed.Prior to conversion it is good to test the packages for its conversion using Test-AppVLegacyPackage
Convereted App-V 5.1 packages can be found in  C:\AppV5convertedpackages folder.
Check this link to know about converting of old App-V 4.x applications to new App-V 5.1 format – 
NOTE: If you are running a computer with a 64-bit architecture, you must use the x86 version of PowerShell to run this script. Also execution policy has to be enabled to allow this script to be run.
This script can also be used to convert old App-V packages into App-V 5.0 format too. 
Disclaimer: This script is designed only for testing purpose and hence I do not own any responsibility for any system failures or issues. Test the script in your environment before you do any mass conversion.
To download the script click HERE

Friday, December 23, 2016

Right Click and Publish App-V Package along with Dynamic Configuration File - Context Menu Shortcut


In my previous blog I had posted about a simple registry tweak to publish packages globally/User by just right clicking and selecting the option. But in that method, it will not use the dynamic configuration file. And so I have covered how to do that in this blog.


copy the below code in notepad and save it in .reg format. After saving, double click on it and register the keys.


Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.appv]
@="appvex"

[HKEY_CLASSES_ROOT\appvex]

[HKEY_CLASSES_ROOT\appvex\shell]

[HKEY_CLASSES_ROOT\appvex\shell\Publish Globally]
@="&Publish Globally"

[HKEY_CLASSES_ROOT\appvex\shell\Publish Globally\command]
@="cmd /c start /b /wait powershell.exe -nologo -ExecutionPolicy bypass -file \"c:\\Publish globally.ps1\" \"%1\""

[HKEY_CLASSES_ROOT\appvex\shell\Publish to User]
@="Publish to &User"

[HKEY_CLASSES_ROOT\appvex\shell\Publish to User\command]
@="cmd /c start /b /wait powershell.exe -nologo -ExecutionPolicy bypass -file \"c:\\Publish to user.ps1\" \"%1\""


Publish Globally:


Copy the below code in a notepad and save it as Publish globally.ps1. Place this file in C:\ drive. If you are planning to keep it elsewhere, then edit the registry entry accordingly.


#Import App-V Client Module
Import-Module AppvClient

#Enable execution of scripts
Set-AppvClientConfiguration -EnablePackageScripts 1


#get appvfile

$appvfile = "$args"

Write-Host $appvfile

#get appv file location

$appvlocation = $appvfile.lastindexof("\")

$location = $appvfile.substring(0,$appvlocation)

Write-Host $location

Write-Host "Path is valid = $(Test-Path $location)"

Set-Location $location 

#get _Deploymentconfig file

ForEach ($file in "$location") 

{
$Name=Get-ChildItem $file
  for ($i = 0; $i -lt $Name.count; $i++)
  {
   
    if ($Name[$i].Extension -eq ".xml")
   {
    $xmlFileName = $Name[$i].FullName
    if ($xmlFileName.contains("_DeploymentConfig"))
    {
     $deploymentconfigfile = $xmlFileName
Write-Host "$deploymentconfigfile"

    }
    
    
   }

  }


Add-AppvClientPackage -path $appvfile -DynamicDeploymentConfiguration "$deploymentconfigfile" | Publish-AppvClientPackage -Global  | Mount-AppvClientPackage 

}


Publish to User:

Copy the below code in a notepad and save it as Publish to user.ps1. Place this file in C:\ drive. If you are planning to keep it elsewhere, then edit the registry entry accordingly.



#Import App-V Client Module
Import-Module AppvClient

#Enable execution of scripts
Set-AppvClientConfiguration -EnablePackageScripts 1


#get appvfile

$appvfile = "$args"

Write-Host $appvfile

#get appv file location

$appvlocation = $appvfile.lastindexof("\")

$location = $appvfile.substring(0,$appvlocation)

Write-Host $location

Write-Host "Path is valid = $(Test-Path $location)"

Set-Location $location 

#get _userconfig file

ForEach ($file in "$location") 

{
$Name=Get-ChildItem $file
  for ($i = 0; $i -lt $Name.count; $i++)
  {
   
    if ($Name[$i].Extension -eq ".xml")
   {
    $xmlFileName = $Name[$i].FullName
    if ($xmlFileName.contains("_UserConfig"))
    {
     $UserConfigfile = $xmlFileName
Write-Host "$UserConfigfile"

    }
    
    
   }

  }


Add-AppvClientPackage -path $appvfile | Publish-AppvClientPackage -DynamicUserConfigurationPath "$UserConfigfile"| Mount-AppvClientPackage 

}


Context Menu Preview:


When you right click any .appv file, it will show the below two context menu shortcuts.If you want to publish globally along with the deploymentconfig file then click on Publish Globally and to publish to a user along with the Userconfig file then click on Publish to User.


Wednesday, August 26, 2015

Powershell to Automate Publishing of Bulk App-V 5.0 or 5.1 packages to a User in a Standalone environment.

In a standalone environment, where there are many App-V 5.0 or App-V 5.1 packages that needs to be published and mounted to a user in order to test the applications, it’s quite hard to open up powershell and type in the commands each time. This is quite time consuming and a repeated job. 
With this powershell script, the job can be made easy by publishing these BULK packages. This powershell script code contains commands to ADD the App-V packages along with their respective DeploymentConfig.xml file and Publish them along with their UserConfig.xml file and at last Mount them successfully.
User has to first place all the App-V packages in a single folder and then edit the powershell script by giving in the exact folder path. 
The powershell code will first load the AppvClient module.

 #Import App-V Client Module 
 Import-Module AppvClient 
  
Next it will enable the execution of scripts present in the dynamic configuration files.
  
#Enable execution of scripts 

Set-AppvClientConfiguration -EnablePackageScripts
  
NOTE: User has to edit the powershell code and give in the exact path where the packages are located. Say example, you have kept all the App-V packages in C:\App-V packages folder, then you need to edit the script and give in the exact C:\App-V packages path in the $appvfolder variable . 
# specify the folder where bulk App-V packages are kept 
$appvfolder = "C:\App-V packages" 
  
After this, the code fetches files from the given folder and executes the Add-AppvClientPackage, Publish-AppvClientPackage and Mount-AppvClientPackage.
The resrtriction policy has to be changed in order to make the script to work properly. 
To download the Powershell script click HERE

Powershell to Automate Publishing of Bulk App-V 5.0 or 5.1 packages Globally in a Standalone environment


In a standalone environment, where there are many App-V 5.0 or App-V 5.1 packages that needs to be published and mounted in order to test the applications, it’s quite hard to open up powershell and type in the commands each time. This is quite time consuming and a repeated job.

With this powershell script, the job can be made easy by publishing these BULK packages. This powershell script code contains commands to ADD the App-V packages along with their respective DeploymentConfig.xml file and Publish them  and at last Mount them successfully.

The powershell code will first load the AppvClient module.

#Import App-V Client Module

Import-Module AppvClient


Next it will enable the execution of scripts present in the dynamic configuration files.


#Enable execution of scripts

Set-AppvClientConfiguration -EnablePackageScripts 1


NOTE: User has to edit the powershell code and give in the exact path where the packages are located. Say example, you have kept all the App-V packages in C:\App-V packages folder, then you need to edit the script and give in the exact C:\App-V packages path in the $appvfolder variable .

# specify the folder where bulk App-V packages are kept

$appvfolder = "C:\App-V packages"  

After this, the code fetches files from the given folder and executes the Add-AppvClientPackage, Publish-AppvClientPackage and Mount-AppvClientPackage


The resrtriction policy has to be changed in order to make the script to work properly.
To download the Powershell script click HERE


Thursday, July 30, 2015

Download Microsoft E-books for free

Download Microsoft E-book for free. Including Windows 10, Windows 8.1, Windows 8, Windows 7, Office 2013, Office 365, SharePoint 2013, Dynamics CRM, PowerShell, Exchange Server, Lync 2013, System Center, Azure, Cloud, SQL Server etc.


So why wait, Go and grab your own copy.


Download Links:


Link1
Link2
Link3