ࡱ> 463 ~bjbj$$ .$F|F|~66666JJJJ VJ~0rrrrrMMM$`#6MMMMM#66rr8M6r6rMrkl#N0~6666(MMMMMMM##MMM~MMMM6MMMMMMMMM : ################################################# ## Created By: Luke Salter ## ## Created On: 07/05/2014 ## ## SCCM Collection Creation Based on CSV Input ## ################################################# ## Load Configuration Manager Module and Switch to EH Site Server CD "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin" import-module .\ConfigurationManager.psd1 CD EH1: function CreateInstallCollection { ## Creates Collection based on the Name read in the CSV File New-CMUserCollection -name $InstallCollectionName -LimitingCollectionName "All USERS" -RefreshType ConstantUpdate ## Creates a Query based rule for the Collection just created. Query looks at AD for name read in the CSV File Add-CMUserCollectionQueryMembershipRule -RuleName $InstallCollectionName -Collectionname $InstallCollectionName -QueryExpression "Select SMS_R_USER.ResourceID,SMS_R_USER.ResourceType,SMS_R_USER.Name,SMS_R_USER.UniqueUserName,SMS_R_USER.WindowsNTDomain from SMS_R_User where SMS_R_User.UserGroupName = 'EH\\SCCM_DL_$InstallCollectionName'" ## Connects to the site WMI namespace and reads the CollectionID for the collection created. $collection = gwmi -Namespace root\sms\site_EH1 -Class SMS_Collection | where {$_.Name -eq "$InstallCollectionName"} $collID = $collection.CollectionID ## Creates Variables for moving the collection [Array]$DeviceCollectionID = $collid $TargetFolderID = 16777234 ## Target Folder = Applications\Live $CurrentFolderID = 0 ## Current Directory = Root $ObjectTypeID = 5001 ## Object Type = User (5000 for Computer) ## Moves the collection to the applications sub folder Invoke-WmiMethod -Namespace "Root\SMS\Site_EH1" -Class SMS_objectContainerItem -Name MoveMembers -ArgumentList $CurrentFolderID,$DeviceCollectionID,$ObjectTypeID,$TargetFolderID $InstallCollectionName | Out-File C:\Temp\Powershell\'Collection Creation'\CreatedCollections.txt -append $DeviceCollectionID | Out-File C:\Temp\Powershell\'Collection Creation'\CreatedCollections.txt -append } function CreateUninstallCollection { ## Creates Collection based on the Name read in the CSV File New-CMUserCollection -name $UninstallCollectionName -LimitingCollectionName "All USERS" -RefreshType ConstantUpdate ## Creates a Query based rule for the Collection just created. Query looks at AD for name read in the CSV File Add-CMUserCollectionQueryMembershipRule -RuleName $UninstallCollectionName -Collectionname $UninstallCollectionName -QueryExpression "Select SMS_R_USER.ResourceID,SMS_R_USER.ResourceType,SMS_R_USER.Name,SMS_R_USER.UniqueUserName,SMS_R_USER.WindowsNTDomain from SMS_R_User where SMS_R_User.UserGroupName = 'EH\\SCCM_DL_$UninstallCollectionName'" ## Connects to the site WMI namespace and reads the CollectionID for the collection created. $collection = gwmi -Namespace root\sms\site_EH1 -Class SMS_Collection | where {$_.Name -eq "$UninstallCollectionName"} $collID = $collection.CollectionID ## Creates Variables for moving the collection [Array]$DeviceCollectionID = $collid $TargetFolderID = 16777235 ## Target Folder = Applications\Live $CurrentFolderID = 0 ## Current Directory = Root $ObjectTypeID = 5001 ## Object Type = User (5000 for Computer) ## Moves the collection to the applications sub folder Invoke-WmiMethod -Namespace "Root\SMS\Site_EH1" -Class SMS_objectContainerItem -Name MoveMembers -ArgumentList $CurrentFolderID,$DeviceCollectionID,$ObjectTypeID,$TargetFolderID $UninstallCollectionname | Out-File C:\Temp\Powershell\'Collection Creation'\CreatedCollections.txt -append $DeviceCollectionID | Out-File C:\Temp\Powershell\'Collection Creation'\CreatedCollections.txt -append } ## Read Applications CSV File import-csv 'C:\Temp\Powershell\Collection Creation\Applications1.csv' | foreach { ## Collection Name Variable for each row in the CSV File $InstallCollectionName=$_.APPNAME+'_Install' $UninstallCollectionName=$_.APPNAME+'_Uninstall' ## Check Existing Collection IF(!(Get-WmiObject -Namespace "root\SMS\Site_EH1" -Query "Select * from SMS_Collection where name = '$InstallCollectionName'" | Select-Object Name)) { CreateInstallCollection CreateUnInstallCollection } ELSE {$InstallCollectionname | Out-File C:\Temp\Powershell\'Collection Creation'\ExistingCollections.txt -append} } sz~hgM hgMhgM2d>  l n M N } ~ *ggdgMWY:;jkT gdgM:so}gs~gdgM,1h. A!"#$% j 666666666vvvvvvvvv666666>6666666666666666666666666666666666666666666666666hH6666666666666666666666666666666666666666666666666666666666666666662 0@P`p2( 0@P`p 0@P`p 0@P`p 0@P`p 0@P`p 0@P`p8XV~ OJPJQJ_HmH nH sH tH J`J Normal dCJ_HaJmH sH tH DA D Default Paragraph FontRiR 0 Table Normal4 l4a (k ( 0No List H`H <* No SpacingCJ_HaJmH sH tH PK![Content_Types].xmlN0EH-J@%ǎǢ|ș$زULTB l,3;rØJB+$G]7O٭V$ !)O^rC$y@/yH*񄴽)޵߻UDb`}"qۋJחX^)I`nEp)liV[]1M<OP6r=zgbIguSebORD۫qu gZo~ٺlAplxpT0+[}`jzAV2Fi@qv֬5\|ʜ̭NleXdsjcs7f W+Ն7`g ȘJj|h(KD- dXiJ؇(x$( :;˹! I_TS 1?E??ZBΪmU/?~xY'y5g&΋/ɋ>GMGeD3Vq%'#q$8K)fw9:ĵ x}rxwr:\TZaG*y8IjbRc|XŻǿI u3KGnD1NIBs RuK>V.EL+M2#'fi ~V vl{u8zH *:(W☕ ~JTe\O*tHGHY}KNP*ݾ˦TѼ9/#A7qZ$*c?qUnwN%Oi4 =3N)cbJ uV4(Tn 7_?m-ٛ{UBwznʜ"Z xJZp; {/<P;,)''KQk5qpN8KGbe Sd̛\17 pa>SR! 3K4'+rzQ TTIIvt]Kc⫲K#v5+|D~O@%\w_nN[L9KqgVhn R!y+Un;*&/HrT >>\ t=.Tġ S; Z~!P9giCڧ!# B,;X=ۻ,I2UWV9$lk=Aj;{AP79|s*Y;̠[MCۿhf]o{oY=1kyVV5E8Vk+֜\80X4D)!!?*|fv u"xA@T_q64)kڬuV7 t '%;i9s9x,ڎ-45xd8?ǘd/Y|t &LILJ`& -Gt/PK! ѐ'theme/theme/_rels/themeManager.xml.relsM 0wooӺ&݈Э5 6?$Q ,.aic21h:qm@RN;d`o7gK(M&$R(.1r'JЊT8V"AȻHu}|$b{P8g/]QAsم(#L[PK-![Content_Types].xmlPK-!֧6 0_rels/.relsPK-!kytheme/theme/themeManager.xmlPK-!0C)theme/theme/theme1.xmlPK-! ѐ' theme/theme/_rels/themeManager.xml.relsPK] ~$~~8@0(  B S  ?y/?G\^t@BJLacqs$+CTi/14I[ae|7Ft-DKVXd+= " * A C Y g r s  % ' / 1 H J X Z q s   , = T     6 H N R i $ 3 a m 18CEQ,G\`q"0@Uuw bds}333333333zz}` ~!<*gM~@zzzz~@UnknownG*Ax Times New Roman5Symbol3. *Cx Arial7.@CalibriA$BCambria Math"qh&G&G ! !q20uuKQHP  $P<*2!xx +Salter, Luke (Secure information solutions)+Salter, Luke (Secure information solutions)Oh+'0d px   , 8DLT\,Salter, Luke (Secure information solutions) Normal.dotm,Salter, Luke (Secure information solutions)2Microsoft Office Word@@b`@b`՜.+,0 hp   Capita SIS! u  Title  !"$%&'()*,-./0125Root Entry FRx71Table6WordDocument.$SummaryInformation(#DocumentSummaryInformation8+CompObjr  F Microsoft Word 97-2003 Document MSWordDocWord.Document.89q