{"id":52,"date":"2015-12-29T09:42:36","date_gmt":"2015-12-29T08:42:36","guid":{"rendered":"http:\/\/backes.nu\/?p=52"},"modified":"2016-06-15T08:14:04","modified_gmt":"2016-06-15T06:14:04","slug":"52-2","status":"publish","type":"post","link":"https:\/\/backes.nu\/index.php\/2015\/12\/29\/52-2\/","title":{"rendered":"Uppdatera Configmgr Content, d\u00e4r det beh\u00f6vs"},"content":{"rendered":"<p>\u00c5terigen, Rikard R\u00f6nnkvist spar mig\u00a0massor av tid med sina PowerShell-script, tack!<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">PARAM (\r\n    $sccmServer = &quot;configmgr.snowland.se&quot;,\r\n    $sccmSiteCode = &quot;ABC&quot;,\r\n    $failStates = &quot;2, 3, 5, 6&quot;, # Retrying and Failed (Both Install and Removal)\r\n    $packageTypes = &quot;0, 3, 4, 8, 257, 258&quot; # Not checking 5 (SUP) due to automatic deployments\r\n)\r\n \r\nWrite-Host &quot;Searching for failed content distributions&quot;\r\nForEach ($FailedDist in (Get-WmiObject -ComputerName $sccmServer -Namespace &quot;ROOT\\SMS\\Site_$($sccmSiteCode)&quot; -Query &quot;SELECT * FROM SMS_PackageStatusDistPointsSummarizer WHERE State IN ($($failStates)) AND PackageType IN ($($packageTypes))&quot; | Sort-Object PackageID)) {\r\n     \r\n    # Figure out servername from NalPath\r\n    $failedServer = $FailedDist.ServerNALPath.Substring($FailedDist.ServerNALPath.LastIndexOf(&quot;]&quot;)+3).Trim(&quot;\\&quot;)\r\n \r\n    # Get the distribution points that content wouldn't distribute to\r\n    ForEach ($FailedDPDist in (Get-WmiObject -ComputerName $sccmServer -Namespace &quot;ROOT\\SMS\\Site_$($sccmSiteCode)&quot; -Query &quot;SELECT * FROM SMS_DistributionPoint WHERE SiteCode='$($FailedDist.SiteCode)' AND PackageID='$($FailedDist.PackageID)' AND ServerNALPath LIKE '%$($failedServer)%'&quot;) ) {\r\n        # Refresh content on the selected DP\r\n        Write-Host &quot;Refreshing $($FailedDPDist.PackageID), type $($FailedDist.PackageType) in state $($FailedDist.State) on $($failedServer)&quot;\r\n        $FailedDPDist.RefreshNow = $true\r\n        $FailedDPDist.Put() | Out-Null\r\n    }\r\n}\r\n \r\nWrite-Host &quot;Done!&quot;<\/pre>\n<p>Tack till Rikard R\u00f6nnkvist, k\u00e4lla: <a href=\"http:\/\/www.snowland.se\/2015\/12\/22\/refresh-configmgr-content-where-its-needed\/\" target=\"_blank\">SnowLand<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u00c5terigen, Rikard R\u00f6nnkvist spar mig\u00a0massor av tid med sina PowerShell-script, tack! PARAM ( $sccmServer = &quot;configmgr.snowland.se&quot;, $sccmSiteCode = &quot;ABC&quot;, $failStates = &quot;2, 3, 5, 6&quot;, # Retrying and Failed (Both Install and Removal) $packageTypes = &quot;0, 3, 4, 8, 257,&#8230;..<\/p>\n","protected":false},"author":1,"featured_media":92,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[47,12],"tags":[28,29,30,25,22,26],"class_list":["post-52","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-notmine","category-note-to-myself","tag-configmgr","tag-content","tag-life-saver","tag-powershell","tag-sccm","tag-snowland"],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/backes.nu\/wp-content\/uploads\/2016\/04\/maxresdefault.jpg?fit=1920%2C1080&ssl=1","jetpack-related-posts":[],"jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5Cu3K-Q","_links":{"self":[{"href":"https:\/\/backes.nu\/index.php\/wp-json\/wp\/v2\/posts\/52","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/backes.nu\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/backes.nu\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/backes.nu\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/backes.nu\/index.php\/wp-json\/wp\/v2\/comments?post=52"}],"version-history":[{"count":2,"href":"https:\/\/backes.nu\/index.php\/wp-json\/wp\/v2\/posts\/52\/revisions"}],"predecessor-version":[{"id":93,"href":"https:\/\/backes.nu\/index.php\/wp-json\/wp\/v2\/posts\/52\/revisions\/93"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/backes.nu\/index.php\/wp-json\/wp\/v2\/media\/92"}],"wp:attachment":[{"href":"https:\/\/backes.nu\/index.php\/wp-json\/wp\/v2\/media?parent=52"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/backes.nu\/index.php\/wp-json\/wp\/v2\/categories?post=52"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/backes.nu\/index.php\/wp-json\/wp\/v2\/tags?post=52"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}