{"id":74761,"date":"2015-11-18T00:01:00","date_gmt":"2015-11-18T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2015\/11\/18\/powershell-and-configuration-manager-2012-r2part-3\/"},"modified":"2019-06-18T23:27:47","modified_gmt":"2019-06-19T07:27:47","slug":"powershell-and-configuration-manager-2012-r2part-3","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/powershell-and-configuration-manager-2012-r2part-3\/","title":{"rendered":"PowerShell and Configuration Manager 2012 R2\u2013Part 3"},"content":{"rendered":"<p><b style=\"font-size: 12px;\">Summary<\/b><span style=\"font-size: 12px;\">: Use the Configuration Manager cmdlets to update applications in distribution points.<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Question\" \/>\u00a0Hey, Scripting Guy!<\/p>\n<p>I\u2019m forever having the nightmare of going clickity, click, click, click when I\u2019m working with my distribution points\u2014especially when updating applications and packages. There must be some way to do this in Windows PowerShell. Can you help me?<\/p>\n<p>\u2014DS<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Answer\" \/>\u00a0Hello DS,<\/p>\n<p>Honorary Scripting Guy, Sean Kearney, is here, shedding more light on the Configuration Manager cmdlets!<\/p>\n<p><strong> \u00a0Note<\/strong>\u00a0\u00a0This is a five-part series that includes the following posts:<\/p>\n<ul>\n<li><a href=\"https:\/\/devblogs.microsoft.com\/scripting\/powershell-and-configuration-manager-2012-r2part-1\/\" target=\"_blank\" rel=\"noopener noreferrer\">PowerShell and Configuration Manager 2012 R2\u2013Part 1<\/a>\nLoad the Configuration Manager cmdlets and make a basic site connection.<\/li>\n<li><a href=\"https:\/\/devblogs.microsoft.com\/scripting\/powershell-and-configuration-manager-2012-r2part-2\" target=\"_blank\" rel=\"noopener noreferrer\">PowerShell and Configuration Manager 2012 R2\u2013Part 2<\/a>\nUse the Configuration Manager cmdlets to work with site collections.<\/li>\n<li><a href=\"https:\/\/devblogs.microsoft.com\/scripting\/powershell-and-configuration-manager-2012-r2part-3\" target=\"_blank\" rel=\"noopener noreferrer\">PowerShell and Configuration Manager 2012 R2\u2013Part 3<\/a>\nUse the Configuration Manager cmdlets to update applications in distribution points.<\/li>\n<li><a href=\"https:\/\/devblogs.microsoft.com\/scripting\/powershell-and-configuration-manager-2012-r2part-4\" target=\"_blank\" rel=\"noopener noreferrer\">PowerShell and Configuration Manager 2012 R2\u2013Part 4<\/a>\nUse the Configuration Manager cmdlets to work with driver packages.<\/li>\n<li><a href=\"https:\/\/devblogs.microsoft.com\/scripting\/powershell-and-configuration-manager-2012-r2part-5\" target=\"_blank\" rel=\"noopener noreferrer\">PowerShell and Configuration Manager 2012 R2\u2013Part 5<\/a>\nUse the Configuration Manager cmdlets to create an application.<\/li>\n<\/ul>\n<p>I feel your pain. Whenever I have to develop and test packages for a client, invariably, it\u2019s the same process over and over: create the package or application, update the distribution point, make a change, click away again\u2026<\/p>\n<p>Anybody at all who\u2019s done this knows it\u2019s another good way to burn in the buttons on your brand new mouse. This is great if you like a new computer mouse every week and don\u2019t mind the odd case of carpel tunnel.<\/p>\n<p>Me? I prefer my hands to remain useful and keeping the company mouse replacement budget well under control. I\u2019d rather that money went towards a new Surface Book for me.<\/p>\n<p>Getting the list of these available cmdlets is the same as accessing a list of collection cmdlets. Simply run <b>Get-Command<\/b> and filter away!<\/p>\n<p style=\"margin-left: 30px;\">Get-Command \u2013module ConfigurationManager *Distribution*<\/p>\n<p><a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/TNBlogsFS\/prod.evol.blogs.technet.com\/CommunityServer.Blogs.Components.WeblogFiles\/00\/00\/00\/76\/18\/6087.1.PNG\"><img decoding=\"async\" title=\"Image of command output\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/TNBlogsFS\/prod.evol.blogs.technet.com\/CommunityServer.Blogs.Components.WeblogFiles\/00\/00\/00\/76\/18\/6087.1.PNG\" alt=\"Image of command output\" \/><\/a><\/p>\n<p>As you can see, the list here is a little more refined that the one for collections. Outside in the Land of PowerShell, we can now do some of those tasks as a single line or small script instead.<\/p>\n<p>One of the tasks I was forever doing (especially when debugging packages or applications) was updating the distribution points. That\u2019s now simply a cmdlet!<\/p>\n<p>If I\u2019d like to update the application called <b>\u2018HSG App\u2019<\/b> with a particular program called <b>\u2018HSG MSI Deployment\u2019<\/b>, instead of clicking madly through the console, I can do this:<\/p>\n<p style=\"margin-left: 30px;\">Update-CMDistributionPoint \u2013ApplicationName \u2018HSG App\u2019 \u2013DeploymentTypeName \u2018HSG MSI Deployment\u2019<\/p>\n<p>At this point, it\u2019s happily running in the background.<\/p>\n<p>But where did I pull those names from? I used two additional cmdlets to get the application display name and the display name for the application type.<\/p>\n<p>First we can run the <b>Get-CMApplication<\/b> cmdlet, which will give us an object that contains every application we have access to in the console.<\/p>\n<p style=\"margin-left: 30px;\">Get-CMApplication<\/p>\n<p>To filter this list to what we\u2019re looking for, we can target the <b>Name<\/b> or <b>PackageID<\/b>. In the following example, we\u2019re using the display name of the application called <b>\u20187 zip\u2019<\/b>.<\/p>\n<p style=\"margin-left: 30px;\">Get-CMApplication \u2013Name \u20187 zip*\u2019<\/p>\n<p>This will produce a list of all entries in the application model that match the name <b>\u20187 zip*\u2019<\/b> at the beginning. You can also target by the <b>PackageID<\/b> if you pipe the results to a <b>Where-Object<\/b> filter.<\/p>\n<p style=\"margin-left: 30px;\">Get-CMApplication | Where { $_.PackageID \u2013eq \u2018SMS00123\u2019 }<\/p>\n<p>When you have your application in question, you\u2019ll need to obtain its name, which is stored under <b>\u2018LocalizedDisplayName\u2019<\/b>, and then place that into an object.<\/p>\n<p style=\"margin-left: 30px;\">$AppName=(Get-CMApplication | Where { $_.PackageID \u2013eq \u2018SMS00123\u2019 }).LocalizedDisplayName<\/p>\n<p>With this information, we now need to find the deployment types that are made available by the application. For this, we use the <b>Get-CMDeploymentType<\/b> cmdlet.<\/p>\n<p>We supply it the application name that we captured previously, and we can filter on the names of the deployment types.<\/p>\n<p style=\"margin-left: 30px;\">Get-CmDeployment \u2013ApplicationName $Appname<\/p>\n<p>If there is more than one, you can pipe it through <b>Where-Object<\/b> to clean up the list. In the following example, we\u2019re only targeting those with the word <b>\u2018MSI\u2019<\/b> in the deployment type\u2019s <b>DisplayName<\/b>:<\/p>\n<p style=\"margin-left: 30px;\">Get-CmDeployment \u2013ApplicationName $Appname | Where { $_.LocalizedDisplayName \u2013match \u2018msi\u2019 }<\/p>\n<p>When we have it, we\u2019ll also store that away in an object. We\u2019ll call this one (strangely enough) <b>$DeploymentType<\/b>.<\/p>\n<p style=\"margin-left: 30px;\">$DeploymentType=Get-CmDeployment \u2013ApplicationName $Appname | Where { $_.LocalizedDisplayName \u2013match \u2018msi\u2019 }<\/p>\n<p>With this provided environmental data, we would update our distribution point as previously, except we supply the PowerShell variables.<\/p>\n<p style=\"margin-left: 30px;\">Update-CMDistributionPoint \u2013ApplicationName $Appname \u2013DeploymentTypeName $DeploymentType<\/p>\n<p>There is so much more we can do with these cmdlets, such as establishing new distribution points, or even modifying memberships of deployment groups. I could easily write for a week about this alone!<\/p>\n<p>DS, now you know how to update distribution points with the PowerShell cmdlets in Configuration Manager. Tomorrow we\u2019ll actually use the cmdlets to work with packages. See you soon!<\/p>\n<p>I invite you to follow the Scripting Guys on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\" target=\"_blank\" rel=\"noopener noreferrer\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\" target=\"_blank\" rel=\"noopener noreferrer\">Facebook<\/a>. If you have any questions, send email to them at <a href=\"mailto:scripter@microsoft.com\" target=\"_blank\" rel=\"noopener noreferrer\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\" target=\"_blank\" rel=\"noopener noreferrer\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, always remember that with great PowerShell comes great responsibility.<\/p>\n<p><b>Sean Kearney, <\/b>Honorary Scripting Guy and Cloud and Datacenter Management MVP<span style=\"font-size: 12px;\">\u00a0<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Use the Configuration Manager cmdlets to update applications in distribution points. \u00a0Hey, Scripting Guy! I\u2019m forever having the nightmare of going clickity, click, click, click when I\u2019m working with my distribution points\u2014especially when updating applications and packages. There must be some way to do this in Windows PowerShell. Can you help me? \u2014DS \u00a0Hello [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[487,56,154,45],"class_list":["post-74761","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-configuration-manager","tag-guest-blogger","tag-sean-kearney","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Use the Configuration Manager cmdlets to update applications in distribution points. \u00a0Hey, Scripting Guy! I\u2019m forever having the nightmare of going clickity, click, click, click when I\u2019m working with my distribution points\u2014especially when updating applications and packages. There must be some way to do this in Windows PowerShell. Can you help me? \u2014DS \u00a0Hello [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/74761","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=74761"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/74761\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=74761"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=74761"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=74761"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}