{"id":448,"date":"2009-10-21T09:58:13","date_gmt":"2009-10-21T07:58:13","guid":{"rendered":"http:\/\/testwebsrv\/?p=3"},"modified":"2009-10-21T09:58:13","modified_gmt":"2009-10-21T07:58:13","slug":"%d1%81%d0%be%d0%b7%d0%b4%d0%b0%d0%bd%d0%b8%d0%b5-%d0%ba%d0%be%d0%bb%d0%bb%d0%b5%d0%ba%d1%86%d0%b8%d0%b9-sccm-2007-%d0%bf%d1%80%d0%b8-%d0%bf%d0%be%d0%bc%d0%be%d1%89%d0%b8-%d1%81%d0%ba%d1%80%d0%b8%d0%bf","status":"publish","type":"post","link":"https:\/\/www.maxx.net.ua\/?p=448","title":{"rendered":"\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0439 SCCM 2007 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u043d\u0430 powershell"},"content":{"rendered":"<p>\u041a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u043d\u0443\u0436\u043d\u0430 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e advetersement \u0438 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d. \u041f\u0440\u0438\u0447\u0435\u043c \u0436\u0435\u0434\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u044d\u0442\u0443 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c, \u0447\u0442\u043e\u0431 \u0432 \u043d\u0435\u0435 \u043f\u043e\u043f\u0430\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u044b, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043d\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0430. \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043c\u043d\u0435 \u043d\u0430\u0434\u043e\u0435\u043b\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0434\u043d\u043e \u0438 \u0442\u043e\u0436\u0435, \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0447\u0435\u0433\u043e \u0440\u043e\u0434\u0438\u043b\u0441\u044f \u0441\u043a\u0440\u0438\u043f\u0442. \u0421\u043a\u0440\u0438\u043f\u0442\u0443 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0441\u0442\u0440\u043e\u043a\u0430 \u0434\u043b\u044f \u043e\u0442\u0431\u043e\u0440\u0430 \u0438 \u0435\u0441\u043b\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0430\u044f \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0432\u0430\u0442\u044c \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f 2 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 &#8211; \u043e\u0434\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0440\u0435\u044b, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0430, \u0432\u0442\u043e\u0440\u0430\u044f \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0430. \u041a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u0431\u0443\u0434\u0443\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0440\u0430\u0437 \u0432 \u0441\u0443\u0442\u043a\u0438 \u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f Query based \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438. <\/p>\n<p>\u0412 \u0434\u0430\u043b\u044c\u0448\u0435\u0439\u0448\u0435\u043c \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0432\u0435\u0440\u0441\u0438\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0430 \u0432\u044b\u0431\u043e\u0440 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0443 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e <\/p>\n<div><span style=\"font-family: Arial;\"> <\/span><\/div>\n<div><span style=\"font-family: Arial;\"> <\/span><\/div>\n<div><span style=\"font-family: Arial;\"><\/span><\/div>\n<p><span style=\"font-family: Arial;\"><\/p>\n<blockquote><p><span style=\"font-family: Courier New;\">$Site = &#8220;site name&#8221;<br \/>\n$sccmServer = &#8220;sccmserver name&#8221;<\/span> <\/p>\n<p dir=\"ltr\"><span style=\"font-family: Courier New;\">function Create-SCCMCollection($parentCollectionName, $collectionName)<br \/>\n{<br \/>\n $ColClass = [WMIClass]&#8221;\\\\$sccmServer\\Root\\SMS\\Site_$($Site):SMS_Collection&#8221;<br \/>\n $shClass = [WMIClass]&#8221;\\\\$sccmServer\\Root\\SMS\\Site_$($Site):SMS_ST_RecurInterval&#8221;<br \/>\n $Col = $ColClass.PSBase.CreateInstance()<br \/>\n $Col.Name = $collectionName<br \/>\n $Col.OwnedByThisSite = $True<br \/>\n $Col.Comment = &#8220;Collection $collectionName&#8221;<br \/>\n $col.RefreshType = 2<br \/>\n $sh = $shClass.PSBase.CreateInstance();<br \/>\n $sh.dayspan = 1<br \/>\n $col.RefreshSchedule = $sh<br \/>\n $Col.psbase<br \/>\n $Col.psbase.Put()<br \/>\n $parentColID = (get-wmiobject -class &#8220;SMS_Collection&#8221; -namespace &#8220;root\\sms\\site_$($Site)&#8221; -computername &#8220;solsms&#8221; -filter &#8220;Name = &#8216;$parentCollectionName'&#8221;).collectionID<br \/>\n $NewCollectionID = (Get-WmiObject -computerName $sccmServer -namespace Root\\SMS\\Site_$Site -class SMS_Collection | where {$_.Name -eq $collectionName}).CollectionID $RelClass = [WMIClass]&#8221;\\\\$sccmServer\\Root\\SMS\\Site_$($Site):SMS_CollectToSubCollect&#8221;<br \/>\n $Rel = $RelClass.PSBase.CreateInstance()<br \/>\n $Rel.ParentCollectionID = $parentColID<br \/>\n $Rel.SubCollectionID = $NewCollectionID<br \/>\n $Rel.psbase<br \/>\n $Rel.psbase.Put()<\/span> <\/p>\n<p><span style=\"font-family: Courier New;\">}<\/span> <\/p>\n<p><span style=\"font-family: Courier New;\"> function AddQueryToCollection($collectionName, $query)<br \/>\n{<br \/>\n $host.UI.RawUI.ForegroundColor = &#8220;White&#8221;<br \/>\n $Method = &#8220;AddMembershipRule&#8221;<br \/>\n $colClass = get-wmiobject -class &#8220;SMS_Collection&#8221; -namespace &#8220;root\\sms\\site_$($Site)&#8221; -computername $sccmServer -filter &#8220;Name = &#8216;$collectionName'&#8221;<br \/>\n $objColRuleDirect = [WmiClass]&#8221;\\\\$sccmServer\\root\\sms\\site_A01:SMS_CollectionRuleQuery&#8221;<br \/>\n $objColRuleDirect.psbase.Properties[&#8220;LimitToCollectionID&#8221;].value = &#8220;&#8221;<br \/>\n $objColRuleDirect.psbase.Properties[&#8220;QueryExpression&#8221;].value = $query<br \/>\n $objColRuleDirect.psbase.Properties[&#8220;RuleName&#8221;].value = &#8220;Auto Query Rule&#8221; $InParams = $colClass.psbase.GetMethodParameters($Method)<br \/>\n $InParams.collectionRule = $objColRuleDirect<br \/>\n  $param = $objColRuleDirect.psbase.getMethodParameters(&#8220;ValidateQuery&#8221;)<br \/>\n $param.wqlquery = $query<br \/>\n $R = $objColRuleDirect.psbase.invokeMethod(&#8220;ValidateQuery&#8221;,$param,$null)<br \/>\n if ($R.ReturnValue -eq $True) {<br \/>\n  $R = $colClass.psbase.InvokeMethod($Method, $inParams, $Null)<br \/>\n  if ($R.ReturnValue -eq 0) {<br \/>\n   write-Host &#8220;Query sucssesful added&#8221; $curObj.ResourceID<br \/>\n  }<br \/>\n }<br \/>\n else {<br \/>\n  $host.UI.RawUI.ForegroundColor = &#8220;Red&#8221;<br \/>\n  write-Host &#8220;Error in query &#8221; $query<br \/>\n  $host.UI.RawUI.ForegroundColor = &#8220;White&#8221;<br \/>\n }<br \/>\n}<br \/>\nIf ($args.length -eq 0) {<br \/>\n write-host &#8220;Please use command Softname SoftQuery Parent Collection Name&#8221;<br \/>\n exit<br \/>\n} $softname = $args[0]<br \/>\n$softquery = $args[1]<br \/>\n$parentcollection = $args[2]<br \/>\nIf ($parentcollection.length -eq $null) {<br \/>\n write-host &#8220;Use default collections&#8221;<br \/>\n Create-SCCMCollection &#8220;Corporate Software Collections&#8221; $softname&#8221; Installed&#8221;<br \/>\n Create-SCCMCollection &#8220;Corporate Software Installation&#8221; $softname&#8221; Not Installed&#8221;<br \/>\n}<br \/>\nelse{<br \/>\n write-host &#8220;Use custom collections&#8221;<br \/>\n Create-SCCMCollection $parentcollection $softname&#8221; Installed&#8221;<br \/>\n Create-SCCMCollection $parentcollection $softname&#8221; Not Installed&#8221;<br \/>\n}<\/span> <\/p>\n<p><span style=\"font-family: Courier New;\">$soft = $softquery<br \/>\n$selectFull = &#8220;SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name, SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup, SMS_R_SYSTEM.Client&#8221;<br \/>\n$selectShort = &#8220;SMS_R_System.ResourceID&#8221;<br \/>\n$queryPresentSoft = &#8220;select &#8221; + $selectFull + &#8221; from SMS_R_System inner join SMS_G_System_ADD_REMOVE_PROGRAMS on SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceID = SMS_R_System.ResourceId where SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName like &#8216;&#8221; + $soft + &#8220;&#8216; and Active = 1 and Obsolete = 0&#8221;;<br \/>\n$querycontain = &#8220;select &#8221; + $selectShort + &#8221; from SMS_R_System inner join SMS_G_System_ADD_REMOVE_PROGRAMS on SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceID = SMS_R_System.ResourceId where SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName like &#8216;&#8221; + $soft + &#8220;&#8216; and Active = 1 and Obsolete = 0&#8221;;<br \/>\n$queryNotPresentSoft = &#8220;select &#8221; + $selectFull+&#8221; from SMS_R_System where ResourceId not in (&#8220;+$querycontain+&#8221;) and Active = 1 and Obsolete = 0&#8243;<\/span> <\/p>\n<p><span style=\"font-family: Courier New;\">AddQueryToCollection $softname&#8221; Installed&#8221; $queryPresentSoft<br \/>\nAddQueryToCollection $softname&#8221; Not Installed&#8221; $queryNotPresentSoft<br \/>\n$host.UI.RawUI.ForegroundColor = &#8220;Green&#8221; <\/span> <\/p><\/blockquote>\n<p><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u043d\u0443\u0436\u043d\u0430 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e advetersement \u0438 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d. \u041f\u0440\u0438\u0447\u0435\u043c \u0436\u0435\u0434\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u044d\u0442\u0443 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c, \u0447\u0442\u043e\u0431 \u0432 \u043d\u0435\u0435 \u043f\u043e\u043f\u0430\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u044b, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043d\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0430. \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043c\u043d\u0435 \u043d\u0430\u0434\u043e\u0435\u043b\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0434\u043d\u043e \u0438 \u0442\u043e\u0436\u0435, \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0447\u0435\u0433\u043e \u0440\u043e\u0434\u0438\u043b\u0441\u044f \u0441\u043a\u0440\u0438\u043f\u0442. \u0421\u043a\u0440\u0438\u043f\u0442\u0443 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0441\u0442\u0440\u043e\u043a\u0430 \u0434\u043b\u044f \u043e\u0442\u0431\u043e\u0440\u0430 \u0438 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[8,9],"tags":[23],"_links":{"self":[{"href":"https:\/\/www.maxx.net.ua\/index.php?rest_route=\/wp\/v2\/posts\/448"}],"collection":[{"href":"https:\/\/www.maxx.net.ua\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.maxx.net.ua\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.maxx.net.ua\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.maxx.net.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=448"}],"version-history":[{"count":0,"href":"https:\/\/www.maxx.net.ua\/index.php?rest_route=\/wp\/v2\/posts\/448\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.maxx.net.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=448"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.maxx.net.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=448"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.maxx.net.ua\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=448"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}