Part 1 – App-V 5.0 and Configuration Manager 2012 SP1 Powershell Integration Basics

Hi all,

Recently I’ve been working a lot with App-V 5.0 and Configuration Manager 2012 SP1 integration and it’s time to share how you can use the Powershell cmdlets to automate package imports and deployments.

Before we go into the cool scripts we need to understand how we can use the Configuration Manager Powershell cmdlets.

Importing the Powershell Module

There are two options to load the Configuration Manager Powershell Cmdlets:

1. Connect via Window Powershell in the Configuration Manager Consoleclip_image002

2. Import the module into the current Powershell session:

What you need to do is find the path to ConfigurationManager.psd1 file which is located in the AdminConsole folder structure of the Configuration Manager installation.

$CM_Module = "D:\ConfigMgr\AdminConsole\bin\ConfigurationManager.psd1"

Once I’ve set the path in Powershell I then need to import that module into my session so we use the “Import-module” cmdlet built into Powershell.

Import-Module $CM_Module

If you try and import the module from within a 64-bit session then you will receive the following error:

clip_image004

As it states the Configuration Manager Powershell cmdlets will only work in an x86 version of Powershell.

Now we have the Powershell module imported how can I use the new commandlets?

If you review the “about_ConfigurationManager_Cmdlets” on technet it tells you:

“The Configuration Manager module for Windows PowerShell includes a Windows PowerShell drive provider for individual sites. By using the CD command in the Windows PowerShell console, you can change the context of your session to a different site.”

https://technet.microsoft.com/en-us/library/jj849986.aspx

So I need to find out the drive that I need to connect to so I’m using the following command:

Get-PSDrive | select Name,Provider

clip_image006

You can see above there is the provider “AdminUI.PS.Provider\CMSite” and the name should represent your site name created when you installed Configuration Manager.

The next command shows how you can search for all the different CM sites that you could connect to:

Get-PSDrive | where { $_.Provider -like "*CMSite*" }

clip_image008

Now I know the name of my drive to connect to I can then go ahead and load the drive with the command below:

cd PRI:

Once the drive is loaded you can then get a list of cmdlets available in the session.

Get-Command -Module ConfigurationManager

clip_image010

You can then use the “Configuration Manager SP1 Cmdlet Reference” to understand what you can do with each cmdlet.

https://technet.microsoft.com/en-us/library/jj821831.aspx

Conclusion

I hope this blog has helped you understand how to import the Configuration Manager Powershell module, in part 2 we will cover off how you can automatically Import App-V 5.0 applications, distribute the content to the DPs and the deploy the application to your users.

David Falkus | Premier Field Engineer | Application Virtualization