Last active
January 27, 2016 14:22
Revisions
-
vannmangel revised this gist
Jan 27, 2016 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ =========================================================================== Created with: SAPIEN Technologies, Inc., PowerShell Studio 2015 v4.2.95 Created on: 28.10.2015 16.18 Created by: Stian Myhre (including some "stealing with pride" from Kaido Järvemets, CoreTech) Organization: Amedia Teknologi Filename: Add-AllPackageIDsToDistributionPointGroup.ps1 =========================================================================== @@ -58,7 +58,7 @@ Function Add-AllPackageIDsToDistributionPointGroup #Add the PackageIDs to DP group foreach ($PackageID in $allpackages) { #A special thanks to Kaido Järvemets in CoreTech for this code :) Try { $DPGroupQuery = Get-WmiObject -Namespace "Root\SMS\Site_$SiteCode" -Class SMS_DistributionPointGroup -ComputerName $SiteServer ` -
vannmangel created this gist
Oct 28, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,79 @@ #Requires -version 3 <# .NOTES =========================================================================== Created with: SAPIEN Technologies, Inc., PowerShell Studio 2015 v4.2.95 Created on: 28.10.2015 16.18 Created by: Stian Myhre (including some "stealing with pride" from Kaido Jãrvaments, CoreTech) Organization: Amedia Teknologi Filename: Add-AllPackageIDsToDistributionPointGroup.ps1 =========================================================================== .DESCRIPTION Fetches the PackageID from all applications, packages, boot images, OS images and driver packages and puts them in a DP group. #> Function Add-AllPackageIDsToDistributionPointGroup { [CmdLetBinding()] Param ( [Parameter(Mandatory = $True, HelpMessage = "Enter ConfigMgr site code")] $SiteCode, [Parameter(Mandatory = $True, HelpMessage = "Enter site server name")] $SiteServer, [Parameter(Mandatory = $True, HelpMessage = "Enter Distribution Point Group name")] $DPGroup, [Parameter(Mandatory = $false, HelpMessage = "Import ConfigMgr module from default installation path")] [Switch]$UseDefaultModulePath, [Parameter(Mandatory = $false, HelpMessage = "Specify the path to ConfigMgr module")] $CMModulePath ) #Import the module if ($UseDefaultModulePath) { Import-Module -Name "${env:ProgramFiles(x86)}\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1" } if ($CMModulePath) { Import-Module -Name $CMModulePath } #Verify ConfigMgr module existence $CMModule = Get-Module ConfigurationManager if ($CMModule.Name -eq "ConfigurationManager") { #Connect to Site Code PSDrive Set-Location ($sitecode + ':\') #Fetch the PackageIDs Get-CMApplication | select PackageID -OutVariable Applications Get-CMPackage | select PackageID -OutVariable Package Get-CMBootImage | select PackageID -OutVariable BootImage Get-CMOperatingSystemImage | select PackageID -OutVariable OSImage Get-CMDriverPackage | select PackageID -OutVariable DriverPackage #Merge the PackageIDs $allpackages = ($Applications.PackageID + $Package.PackageID + $BootImage.PackageID + $OSImage.PackageID + $DriverPackage.PackageID) #Add the PackageIDs to DP group foreach ($PackageID in $allpackages) { #A special thanks to Kaido Järvaments in CoreTech for this code :) Try { $DPGroupQuery = Get-WmiObject -Namespace "Root\SMS\Site_$SiteCode" -Class SMS_DistributionPointGroup -ComputerName $SiteServer ` -ErrorAction STOP -Filter "Name='$DPGroup'" $DPGroupQuery.AddPackages($PackageID) } Catch { $_.Exception.Message } } } else #error handling { Write-Output 'Oops, seems like the ConfigurationManager module was not imported correctly.' Break } }