tag:blogger.com,1999:blog-89968566230969683722024-02-07T05:56:37.845+01:00pleasepressanykeymy microsoft technology blogmerowingerhttp://www.blogger.com/profile/05679656055137095951noreply@blogger.comBlogger46125tag:blogger.com,1999:blog-8996856623096968372.post-77906039497037305722013-11-11T08:48:00.004+01:002013-11-11T08:52:18.064+01:00ConfigMgr - Standalone removable media not working<br />
<span lang="EN-US" style="font-family: "Calibri","sans-serif"; font-size: 11pt; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;">I've used
a new SanDisk Extreme USB thumb drive to deploy my huge Configmgr Task Sequence
as a standalone Media. When booting from it i see the Windows 8 PE Logo, a
dialog with "Initializing hardware devices" and afterwards i get the
following error: "Unable to read task sequence configuration disk".
In the SMSTS.log file i regogniced the following entry: "<span style="mso-bidi-font-weight: bold;">Booted</span> from <span style="mso-bidi-font-weight: bold;">fixed disk".</span><o:p></o:p></span><br />
<br />
<span lang="EN-US" style="font-family: "Calibri","sans-serif"; font-size: 11pt; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;">I've read
a lot of posts pointing to missing Network Drivers, usage of USB 3.0 slots,
etc. which did not help me.<o:p></o:p></span><br />
<br />
<span lang="EN-US" style="font-family: "Calibri","sans-serif"; font-size: 11pt; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;">In my
case the problem is because my USB removable Sticks is discovered as a fixed
Hard Disk and indeed in Windows Explorer it shows up as a normal hard disk.<o:p></o:p></span><br />
<br />
<span lang="EN-US" style="font-family: "Calibri","sans-serif"; font-size: 11pt; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;">Unfortunately
fixed disks are not supported to be used as standalone Media in ConfigMgr. All
vendors are fored to create removable sticks as fixed Disks as they will not
get any Windows 8 certification from Microsoft without. I'm really disappointed
about the communication which is (not) taking place between the
Windows and ConfigMgr Team at Microsoft. <o:p></o:p></span><br />
<br />
<span lang="EN-US" style="font-family: "Calibri","sans-serif"; font-size: 11pt; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;">The only
solution right now is to buy other USB Sticks which are discovered as
removable, thumb drives. The only problem is, i have no idea which sticks can be used and which not...</span><br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span lang="EN-US" style="mso-ansi-language: EN-US;"><o:p> </o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span lang="EN-US" style="mso-ansi-language: EN-US;"><o:p> </o:p></span></div>
merowingerhttp://www.blogger.com/profile/05679656055137095951noreply@blogger.com3tag:blogger.com,1999:blog-8996856623096968372.post-38267596699601069752013-11-07T06:33:00.000+01:002013-11-07T06:34:02.973+01:00PXE Advertisement Flag remains for a MAC Address after removing a systemI had the same problem which Steve Rachui is posting <a href="http://blogs.msdn.com/b/steverac/archive/2013/10/03/delete-behavior-for-devices-in-configmgr-2012.aspx?CommentPosted=true#commentmessage">here</a> and still opened a call months ago.<br />
<br />
The problem is that PXE Advertisement Flag remains for MAC Addresses after removing a system. If there is created a new Client record in SCCM with the same MAC Addresses (e.g. when you reinstall that system with a new name) there's still is a PXE Advertisement Flag available, which blocks the Client from PXE Boot. You can then manually remove the Flag via "Clear PXE Advertisement" but 1. you have to know that problem and remember it when troubleshooting and 2. It's a bug, becuase when i remove a system it should be removed without leaving some entries in SQL Tables (in this case v_RA_System_MACAddress<span lang="EN-US" style="color: #1f497d; font-family: "Calibri","sans-serif"; font-size: 11pt; mso-ansi-language: EN-US; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: DE; mso-fareast-theme-font: minor-latin;">)</span><br />
<br />
Now Microsoft wrote to me that the problem is a bug which will be solved in the next version of the product. Quote: <br />
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
<span lang="EN-GB" style="mso-ansi-language: EN-GB;"><span style="font-family: Calibri;"><em>"Following
some investigation we have identified the parts of the product that need to
change to ensure that the old profiles will no longer be used once deleted from
the console and requested that this is changed in the next version of the
product."<o:p></o:p></em></span></span></div>
merowingerhttp://www.blogger.com/profile/05679656055137095951noreply@blogger.com0tag:blogger.com,1999:blog-8996856623096968372.post-83813432730379468922011-09-20T13:50:00.003+02:002011-09-20T13:51:30.926+02:00PXE Service Point Role missing for Secondary Site ServerThe PXE Service Point Option is not available in the "New Roles" Wizard within ConfigMgr if you want to install it on a Secondary Site Server.
<br />
<br />
<b>Solution:</b> Install the Windows Deployment Services (WDS) Server Role on the Secondary Site Server and also make sure you're connected to the Primary Site where the Secondary Site Server belongs tomerowingerhttp://www.blogger.com/profile/05679656055137095951noreply@blogger.com0tag:blogger.com,1999:blog-8996856623096968372.post-88691812050258225582011-06-27T18:02:00.005+02:002011-06-27T18:07:54.971+02:00SCCM Asset Intelligence - List manufacturer friendly namesThis Query will list all possible manufacturer listings of an application and the friendly names (grouped)<br /><pre class="SQL" name="code"><br />SELECT Distinct CommonPublisher,Publisher <br />FROM v_LU_SoftwareList <br />INNER JOIN V_LU_Softwarehash ON V_LU_Softwarehash.SoftwareID = v_LU_SoftwareList.SoftwareID<br />ORDER BY CommonPublisher<br /></pre>merowingerhttp://www.blogger.com/profile/05679656055137095951noreply@blogger.com0tag:blogger.com,1999:blog-8996856623096968372.post-43817268429081661162011-05-26T10:17:00.007+02:002011-05-26T10:26:52.065+02:00List installed ConfigMgr Hotfixes automaticallyI tried to store the current ConfigMgr patch state during ConfigMgr Backup automatically to make sure i can restore the exaclty configuration after a Server Crash.<br />Unfortunately the command <em>wmic qfe list</em> does only list installed Windows Updates.<br />If you want to to the same you can use the following command<br /><br /><strong>For a 64 Bit Windows Server</strong><br /><em>reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Updates\System Center Configuration Manager 2007\SP2" /s > ConfigMgrPatchState.txt</em><br /><br /><strong>For a 32 Bit Windows Server</strong><br /><em>reg query "HKLM\SOFTWARE\Microsoft\Updates\System Center Configuration Manager 2007\SP2" /s > ConfigMgrPatchState.txt</em><br /><br />You can automatically execute the command after the Backup by using the AfterBackup.bat<br /><a href="http://technet.microsoft.com/en-us/library/cc181721.aspx">http://technet.microsoft.com/en-us/library/cc181721.aspx</a>merowingerhttp://www.blogger.com/profile/05679656055137095951noreply@blogger.com0tag:blogger.com,1999:blog-8996856623096968372.post-45211358556826372011-05-16T11:00:00.008+02:002011-05-18T10:38:38.442+02:00GPP - Power Plan not applyingDeployed Power Management options defined in the Group Policy Preferences (GPPs) are not applying on your Clients. Maybe other settings which are defined in the same Policy are working.<br /><br />Check if you've configured the option <strong>apply once and do not reapply</strong> in the GPPs.<br /><br />According to <a href="http://ctp.social.technet.microsoft.com/Forums/en-US/w7itproinstall/thread/29520882-a0da-44b5-9f47-0656cd63aed9">this article</a> here is this behaviour a by design issue.<br />The Power Management options have to be applied two times. The first time the Power Plan gets created on your Client and at the second time the Plan is enabled. So if you've configured the above listed option the policy is only applied once and so the Power Management is not configured.<br /><br />One option to get he Power Plan applied is to disable the "apply once and do not reapply" option. But in this case Power Plan changes from the Users are overwritten each time the policy is applied.<br /><br />Another option is to create the following RegistryKey within the same Policy:<br /><strong>Path:</strong> HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce<br /><strong>Name:</strong> EnablePowerPlan<br /><strong>Type:</strong> Reg_SZ<br /><strong>Value:</strong> cmd /c powercfg -s 381b4222-f694-41f0-9685-ff5bb260df2e<br /><br />Make sure the Option "apply once and do not reapply" is also enabled for this Key. With this Workaround the PowerOptions are applied and enabled as soon as the User logs on to the client. If the policy is applied after the logon process, then the PowerOptions are enabled at the next logonmerowingerhttp://www.blogger.com/profile/05679656055137095951noreply@blogger.com0tag:blogger.com,1999:blog-8996856623096968372.post-55080761287004593632011-05-12T20:38:00.000+02:002011-05-13T22:31:00.433+02:00Task Sequence Error Code 80070002 in ConfigMgr 2012The OSD Task Sequence in ConfigMgr 2012 fails with error code 80070002.<br />Also you see the following errors in smsts.log:<br /><br /><strong>Authentication failure - 401<br />Resending the request by setting the credentials on getting an unauthorized response<br />HTTP result: 401<br />...<br />Tried all the available http based locations. SMB based locations will be attempted now<br />!saSMBContentSources.empty(), HRESULT=80070002<br />...<br />Exit Code 2147942402</strong><br /><br />One possible solution is to configure a Network Service Account.<br /><em>ConfigMgr Console -> Administration -> Site Operations -> Sites -> Your Site -> Configure Site Components -> Software Distribution -> Network Access Account</em>merowingerhttp://www.blogger.com/profile/05679656055137095951noreply@blogger.com0tag:blogger.com,1999:blog-8996856623096968372.post-89487369409354991612011-05-06T10:07:00.004+02:002011-05-06T10:13:41.380+02:00Backup SQL 2008 R2 DB with HP Data ProtectorTo Backup a Database on a SQL 2008 R2 Server with HP Data Protector (e.g. Version 6.11) you've to install the SQL 2005 Backwards compatibility tools on the SQL Server. They are part of the <a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyId=50b97994-8453-4998-8226-fa42ec403d17&displaylang=en">SQL 2005 Distributed Management Objects toolkit</a>merowingerhttp://www.blogger.com/profile/05679656055137095951noreply@blogger.com0tag:blogger.com,1999:blog-8996856623096968372.post-19074120728448328422011-05-05T13:36:00.005+02:002011-05-05T14:50:12.961+02:00L2TP VPN Connection failsYour L2TP VPN Connection fails on a Client with the following error:<br /><br /><em>Error: 789 "The L2TP connection attempt failed because the security layer encountered a processing error during initial negotiations with the remote computer"</em><br /><br />The error occurs because your client connects to the VPN Server via a NAT Device. By default you've to configure your clients to allow this type of VPN connection.<br /><br />To make it work configure the following on your clients:<br /><br /><strong>Windows XP</strong><br />RegPath: HKLM\SYSTEM\CurrentControlSet\Services\IPSec<br />RegKey: AssumeUDPEncapsulationContextOnSendRule<br />RegType: DWORD 32 bit<br />RegValue: 2<br /><br /><strong>Windows Vista/7</strong><br />RegPath: HKLM\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy<br />RegKey: IPsecThroughNAT<br />RegType: DWORD 32 bit<br />RegValue: 2<br /><br />and<br /><br />RegPath: HKLM\SYSTEM\CurrentControlSet\Services\PolicyAgent\<br />RegKey: AssumeUDPEncapsulationContextOnSendRule<br />RegType: DWORD 32 bit<br />RegValue: 2<br /><br />Then reboot the Client or restart the Service IKE and AuthIP IPsec Keying Modules<br />(NET STOP IKEEXT && NET START IKEEXT)merowingerhttp://www.blogger.com/profile/05679656055137095951noreply@blogger.com2tag:blogger.com,1999:blog-8996856623096968372.post-56698102810029370452011-04-13T17:02:00.009+02:002011-04-15T13:05:48.234+02:00vbScript - set permissons on ConfigMgr Objects in bulkThis little vbscript loops throught the file SetPermissons.txt and creates all class and instance permissons for your ConfigMgr Objects which are defined<br /><br /><strong>File Structure must be:</strong><br />1st postition: Object Level (Possible Values: Class(C) or Instance (I))<br />2nd postition: Object Type (COLLECTION, ADVERTISEMENT, PACKAGE, ...)<br />3rd postition: Object Name (If Object Level is Class, the Name is not used. Best value in this case is "N/A")<br />4th postition: Username (Format: domain\username)<br />5th postition: Permissons (Format: Permisson1&Permisson2&...) - For all Permissons on an Object use keyword "FULL". Check the lower part of the vbScript for detailed information. Also note that the permissons have to make sense. So please first check the available permissons for each object in your ConfigMgr Console<br /><br /># are and blank lines are ignored<br /># are available for comments<br /><br />The <strong>SetPermissons.txt</strong> file should look like this:<br /><pre class="bat" name="code"><br />###########################################################################<br />############################### EXAMPLES ##################################<br />###########################################################################<br />### I;COLLECTION;All Systems;mydomain\myuser;READ&MODIFY&READ_RESOURCE<br />### I;COLLECTION;All Systems;mydomain\myuser2;READ&ADVERTISE&DELETE_RESOURCE<br />### I;PACKAGE;Adobe_Reader;mydomain\myuser2;DISTRIBUTE<br />### I;PACKAGE;Adobe_Reader;mydomain\myuser;MODIFY&DISTRIBUTE<br />### I;ADVERTISEMENT;Install_Adobe_Reader;mydomain\myuse;FULL<br />### C;SITE;N/A;mydomain\myuser;FULL<br />### C;TASKSEQUENCE;N/A;mydomain\myuser2;READ&MODIFY<br />###########################################################################<br />###########################################################################<br />###########################################################################<br /><br />#Set Collections Permissons<br />I;Collection;MyCollectionABC;mydomain\BillGates;READ&MODIFY&READ_RESOURCE<br />I;Collection;MyCollectionXYZ;mydomain\SteveBallmer;READ&ADVERTISE&DELETE_RESOURCE<br /><br />#Set Package Permissons<br />I;PACKAGE;Adobe_Reader;mydomain\BillGates;DISTRIBUTE<br />I;PACKAGE;Adobe_Reader;mydomain\SteveBallmer;READ&DISTRIBUTE<br />I;PACKAGE;Adobe_Reader;mydomain\ElvisPresley;READ&MODIFY&DISTRIBUTE<br /><br />#Set Advertisement Permissons<br />I;Advertisement;Repair_Java;mydomain\SteveBallmer;READ<br /><br />#Set Permissons for the new HelpDesk Employee<br />I;COLLECTION;MyCollection;mydomain\johnwayne;READ<br />I;COLLECTION;HisCollection;mydomain\johnwayne;READ&MODFIY<br />I;Advertisement;Uninstall_7ZIP;mydomain\johnwayne;READ&DELETE<br />C;COLLECTION;N/A;mydomain\johnwayne;READ<br />C;SITE;N/A;mydomain\johnwayne;READ&IMPORTMACHINE<br /><br />#Set Permissons for the Group OSD Admins<br />C;OSINSTALLPACKAGE;N/A;mydomain\OSDAdmins;FULL<br />C;COMPUTERASSOCIATION;N/A;mydomain\OSDAdmins;READ&DELETE&ADMINISTER&CREATE<br />C;OSIMAGE;N/A;mydomain\OSDAdmins;FULL<br />C;TASKSEQUENCE;N/A;mydomain\OSDAdmins;FULL<br />C;DRIVERPACKAGE;N/A;mydomain\OSDAdmins;FULL<br />C;DEVICEDRIVER;N/A;mydomain\OSDAdmins;FULL<br /></pre><br /><br />The vbScript is the below code - Have fun ;)<br />Note: There's not build in a lot of error handling, so please first test it carefully<br /><br /><pre class="vb" name="code"><br />'************************************************************************************************************<br />' Jonas Hettich<br />'************************************************************************************************************<br />'<br />' Ver 1.00 - 13.04.2011 - initial version<br />'<br />' What this script does:<br />' This Scripts creates the Permissons defined in the file SetPermissons.txt<br />'<br />' Not Supported: Instace Rights for Drivers, Asset Intelligence<br />'************************************************************************************************************<br /><br />result = MsgBox("Do you really want to create the Collection Permissons?", vbYesNo)<br />If result = vbNo Then WScript.Quit<br /><br />Dim strChoosenPermissons<br />Dim strSiteServer : strSiteServer = "<Servername>"<br />Dim strSitecode : strSitecode = "<SiteCode>"<br />Dim objSWbemLocator : Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")<br />Dim objSWbemServices : Set objSWbemServices = objSWbemLocator.ConnectServer(strSiteServer,"root/sms/site_" & strSitecode)<br /><br />Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")<br />Dim objFile : Set objFile = objFSO.OpenTextFile("SetPermissons.txt")<br />Dim strCurrentLine<br />Dim strObjectsType, strObjectName, strUser, strPermissons, strObjectEnv<br /><br />'Loop the Source File<br />Do While not objFile.AtEndOfStream<br /> strCurrentLine = objFile.ReadLine<br /> <br /> 'Skip Comment and Blank lines<br /> If strCurrentLine <> "" Then<br /> If Not Left(strCurrentLine,1) = "#" Then<br /> <br /> 'Parse the information<br /> strObjectEnv = Ucase(Split(strCurrentLine,";")(0))<br /> strObjectsType = Ucase(Split(strCurrentLine,";")(1))<br /> strObjectName = Ucase(Split(strCurrentLine,";")(2))<br /> strUser = Ucase(Split(strCurrentLine,";")(3))<br /> strPermissons = Ucase(Split(strCurrentLine,";")(4))<br /> <br /> Call SetInstanceRights(strObjectEnv,strObjectsType, strObjectName, strUser, strPermissons)<br /><br /> 'Reset the Permissons for the next action<br /> strChoosenPermissons = 0<br /> <br /> End If<br /> End If<br /> <br /><br />Loop<br /><br />Function NameToID(strObjectType,strObjectName)<br />Dim colResuls, objResult<br /><br />Select Case (strObjectType)<br />Case("COLLECTION")<br /><br /> Set colResults = objSWbemServices.ExecQuery ("select * from SMS_Collection where Name='" & strObjectName & "'")<br /> For Each objResult In colResults<br /> NameToID = objResult.CollectionID<br /> Next<br /><br />Case("PACKAGE")<br /><br /> Set colResults = objSWbemServices.ExecQuery ("select * from SMS_Package where Name='" & strObjectName & "'")<br /> For Each objResult In colResults<br /> NameToID = objResult.PackageID<br /> Next<br /> <br />Case ("ADVERTISEMENT")<br /><br /> Set colResults = objSWbemServices.ExecQuery ("select * from SMS_Advertisement where AdvertisementName='" & strObjectName & "'")<br /> For Each objResult In colResults<br /> NameToID = objResult.AdvertisementID<br /> Next<br /> <br />Case ("TASKSEQUENCE")<br /><br /> Set colResults = objSWbemServices.ExecQuery ("Select * from SMS_TaskSequencePackage where Name='" & strObjectName & "'")<br /> For Each objResult In colResults<br /> NameToID = objResult.PackageID<br /> Next<br /> <br />Case ("OSINSTALLPACKAGE")<br /><br /> Set colResults = objSWbemServices.ExecQuery ("Select * from SMS_OperatingSystemInstallPackage where Name='" & strObjectName & "'")<br /> For Each objResult In colResults<br /> NameToID = objResult.PackageID<br /> Next<br /><br />Case ("OSIMAGE")<br /><br /> Set colResults = objSWbemServices.ExecQuery ("Select * from SMS_ImagePackage where Name='" & strObjectName & "'")<br /> For Each objResult In colResults<br /> NameToID = objResult.PackageID<br /> Next <br /><br />Case ("BOOTIMAGE")<br /><br /> Set colResults = objSWbemServices.ExecQuery ("Select * from SMS_BootImagePackage where Name='" & strObjectName & "'")<br /> For Each objResult In colResults<br /> NameToID = objResult.PackageID<br /> Next <br /><br />Case ("DRIVERPACKAGE")<br /><br /> Set colResults = objSWbemServices.ExecQuery ("Select * from SMS_DriverPackage where Name='" & strObjectName & "'")<br /> For Each objResult In colResults<br /> NameToID = objResult.PackageID<br /> Next<br />Case Else<br /> Log "Error: Objecttype not supported"<br /> Exit Function<br />End Select<br /><br />End Function<br /><br />Function SetInstanceRights(ObjectEnv, ObjectType, ObjectName, User, Permissons)<br /> Dim arrPermissons, strPermisson<br /> Dim strObjectID<br /> Dim objUserPermissions<br /> <br /> 'Choose between Class and Instance Permissons<br /> If ObjectEnv = "I" Then<br /> Set objUserPermissions = objSWbemServices.Get("SMS_UserInstancePermissions")<br /> Log vbNewLine &"*** Configure Instance Permissons ***"<br /> ElseIf ObjectEnv = "C" Then<br /> Set objUserPermissions = objSWbemServices.Get("SMS_UserClassPermissions")<br /> Log vbNewLine &"*** Configure Class Permissons ***"<br /> Else<br /> Log "Error: Object Environment not available. Must be Class(C) or Instance(I)"<br /> WScript.Quit<br /> End If<br /> <br /> <br /> 'Create UserInstancePermissonsObject<br /> Set objNewUserPermissions = objUserPermissions.SpawnInstance_<br /> <br /> 'Set the Objecttype<br /> Select Case (ObjectType)<br /> Case "COLLECTION"<br /> objNewUserPermissions.ObjectKey = 1<br /> Case "PACKAGE"<br /> objNewUserPermissions.ObjectKey = 2<br /> Case "ADVERTISEMENT"<br /> objNewUserPermissions.ObjectKey = 3<br /> Case "STATUSMESSAGE"<br /> objNewUserPermissions.ObjectKey = 4<br /> Case "SITE"<br /> objNewUserPermissions.ObjectKey = 6<br /> Case "QUERY"<br /> objNewUserPermissions.ObjectKey = 7<br /> Case "REPORT"<br /> objNewUserPermissions.ObjectKey = 8<br /> Case "SOFTWAREMETERINGRULE"<br /> objNewUserPermissions.ObjectKey = 9<br /> Case "APPLICABLEUPDATESSUMMARY"<br /> objNewUserPermissions.ObjectKey = 10<br /> Case "CONFIGURATIONITEMS"<br /> objNewUserPermissions.ObjectKey = 11<br /> Case "OSINSTALLPACKAGE"<br /> objNewUserPermissions.ObjectKey = 14<br /> Case "DEPLOYMENTTEMPLATE"<br /> objNewUserPermissions.ObjectKey = 15<br /> Case "DEPLOYMENT"<br /> objNewUserPermissions.ObjectKey = 16<br /> Case "COMPUTERASSOCIATION"<br /> objNewUserPermissions.ObjectKey = 17<br /> Case "OSIMAGE"<br /> objNewUserPermissions.ObjectKey = 18<br /> Case "BOOTIMAGE"<br /> objNewUserPermissions.ObjectKey = 19<br /> Case "TASKSEQUENCE"<br /> objNewUserPermissions.ObjectKey = 20<br /> Case "DEVICESETTINGPACKAGE"<br /> objNewUserPermissions.ObjectKey = 21<br /> Case "DEVICESETTINGITEM"<br /> objNewUserPermissions.ObjectKey = 22<br /> Case "DRIVERPACKAGE"<br /> objNewUserPermissions.ObjectKey = 23<br /> Case "DEPLYOMENTPACKAGE"<br /> objNewUserPermissions.ObjectKey = 24<br /> Case "DEVICEDRIVER"<br /> objNewUserPermissions.ObjectKey = 25<br /> Case Else<br /> Log "Error: Objecttype not supported"<br /> Exit Function<br /> End Select <br /> <br /> <br /> 'Set the Object ID<br /> If ObjectEnv = "I" Then<br /> strObjectID = NameToID(ObjectType,ObjectName)<br /> If strObjectID <> "" Then <br /> objNewUserPermissions.InstanceKey = strObjectID<br /> Else<br /> Log "Error: " &ObjectType &" was not found: " &ObjectName<br /> WScript.Quit<br /> End If<br /> End If<br /> <br /> 'Set the User or Group<br /> objNewUserPermissions.UserName = User<br /> <br /> 'Set the Permissons<br /> If Permissons = "FULL" Then<br /> 'Set Full Permissons String<br /> Permissons = FullPermissons(ObjectType,ObjectEnv)<br /> End If<br /><br /> <br /> arrPermissons = Split(Permissons,"&")<br /> For Each strPermisson In arrPermissons<br /> <br /> 'Parse the Permissons<br /> 'http://msdn.microsoft.com/en-us/library/cc143194.aspx<br /> Select Case UCASE(strPermisson)<br /> Case "READ"<br /> strChoosenPermissons = strChoosenPermissons + 1<br /> Case "MODIFY"<br /> strChoosenPermissons = strChoosenPermissons + 2<br /> Case "DELETE"<br /> strChoosenPermissons = strChoosenPermissons + 4<br /> Case "DISTRIBUTE"<br /> strChoosenPermissons = strChoosenPermissons + 8<br /> Case "REMOTE_CONTROL"<br /> strChoosenPermissons = strChoosenPermissons + 32<br /> Case "ADVERTISE"<br /> strChoosenPermissons = strChoosenPermissons + 64<br /> Case "MODIFY_RESOURCE"<br /> strChoosenPermissons = strChoosenPermissons + 128<br /> Case "ADMINISTER"<br /> strChoosenPermissons = strChoosenPermissons + 256<br /> Case "DELETE_RESOURCE"<br /> strChoosenPermissons = strChoosenPermissons + 512<br /> Case "CREATE"<br /> If ObjectEnv = "I" And ObjectType = "COLLECTION" Then<br /> 'Collection Instances do no have the permissons CREATE, ADMINISTER, DELEGATE<br /> Log "ERROR: CREATE, ADMINISTER and DELEGATE permissons are not possible on Collection Instances"<br /> Exit Function<br /> Else<br /> strChoosenPermissons = strChoosenPermissons + 1024<br /> End If<br /> Case "VIEWCOLLECTEDFILES"<br /> strChoosenPermissons = strChoosenPermissons + 2048<br /> Case "READ_RESOURCE"<br /> strChoosenPermissons = strChoosenPermissons + 4096<br /> Case "DELEGATE"<br /> strChoosenPermissons = strChoosenPermissons + 8192<br /> Case "METER"<br /> strChoosenPermissons = strChoosenPermissons + 16384<br /> Case "MANAGESQLCOMMAND"<br /> strChoosenPermissons = strChoosenPermissons + 32768<br /> Case "MANAGESTATUSFILTER"<br /> strChoosenPermissons = strChoosenPermissons + 65536<br /> Case "MANAGEFOLDERS"<br /> strChoosenPermissons = strChoosenPermissons + 131072<br /> Case "NETWORKACCESS"<br /> strChoosenPermissons = strChoosenPermissons + 262144<br /> Case "IMPORTMACHINE"<br /> strChoosenPermissons = strChoosenPermissons + 524288<br /> Case "CREATETASKSEQUENCEMEDIA"<br /> strChoosenPermissons = strChoosenPermissons + 1048576<br /> Case "MODIFYCOLLECTIONSETTING"<br /> strChoosenPermissons = strChoosenPermissons + 2097152<br /> Case "MANAGEOSDCERTIFICATE"<br /> strChoosenPermissons = strChoosenPermissons + 4194304<br /> Case "RECOVERUSERSTATE"<br /> strChoosenPermissons = strChoosenPermissons + 8388608<br /> Case "MANAGEMGMTCONROLLERS"<br /> strChoosenPermissons = strChoosenPermissons + 16777216<br /> Case "VIEWMGMTCONROLLERS"<br /> strChoosenPermissons = strChoosenPermissons + 33554432<br /> Case Else<br /> Log "Error: Permissons not supported"<br /> End Select <br /> <br /> Next<br /><br /><br /> If ObjectEnv = "I" Then<br /> objNewUserPermissions.InstancePermissions = strChoosenPermissons<br /> ElseIf ObjectEnv = "C" Then<br /> objNewUserPermissions.ClassPermissions = strChoosenPermissons<br /> End If<br /><br /> <br /> 'Creating Permissons<br /> On Error Resume Next<br /> objNewUserPermissions.put_<br /> <br /> <br /> If Err.Number = 0 Then<br /> Log "Successfully set following permissons:"<br /> Log vbTab &" - ObjectType: " &ObjectType<br /> Log vbTab &" - ObjectName: " &ObjectName<br /> Log vbTab &" - User: " &User<br /> Log vbTab &" - Permissons: " &Permissons <br /> Else<br /> Log "Error (" &Err.Description &") when trying to create the object:"<br /> Log vbTab &" - ObjectType: " &ObjectType<br /> Log vbTab &" - ObjectName: " &ObjectName<br /> Log vbTab &" - User: " &User<br /> Log vbTab &" - Permissons: " &Permissons <br /> End If<br /><br /> <br /> Set objNewUserPermissions = Nothing<br /> <br />End Function<br /><br /><br />Function FullPermissons(ObjectType,ObjectEnv)<br /><br />Select Case (ObjectType)<br /><br />Case "SITE"<br /> FullPermissons = "IMPORTMACHINE&DELEGATE&ADMINISTER&CREATE&DELETE&READ&MODIFY&MANAGEOSDCERTIFICATE&MANAGESTATUSFILTER&MANAGESQLCOMMAND&METER"<br />Case "OSINSTALLPACKAGE"<br /> FullPermissons = "READ&DISTRIBUTE&MODIFY&DELETE&ADMINISTER&CREATE&MANAGEFOLDERS&DELEGATE"<br />Case "OSIMAGE"<br /> FullPermissons = "READ&DISTRIBUTE&MODIFY&DELETE&ADMINISTER&CREATE&MANAGEFOLDERS&DELEGATE"<br />Case "TASKSEQUENCE"<br /> FullPermissons = "READ&CREATETASKSEQUENCEMEDIA&MODIFY&DELETE&ADMINISTER&CREATE&MANAGEFOLDERS&DELEGATE"<br />Case "DRIVERPACKAGE"<br /> FullPermissons = "READ&DISTRIBUTE&MODIFY&DELETE&ADMINISTER&CREATE&MANAGEFOLDERS&DELEGATE"<br />Case "STATUSMESSAGE" <br /> FullPermissons = "READ&DELETE&CREATE&ADMINISTER"<br />Case "QUERY"<br /> FullPermissons ="READ&MODIFY&DELETE&ADMINISTER&CREATE&DELEGATE&MANAGEFOLDERS"<br />Case "REPORT"<br /> FullPermissons = "READ&MODIFY&DELETE&ADMINISTER&CREATE&DELEGATE&MANAGEFOLDERS"<br />Case "SOFTWAREMETERINGRULE"<br /> FullPermissons = "READ&MODIFY&DELETE&ADMINISTER&CREATE&DELEGATE&MANAGEFOLDERS"<br />Case "APPLICABLEUPDATESSUMMARY"<br /> FullPermissons = "READ&MODIFY&DELETE&ADMINISTER&CREATE&DELEGATE"<br />Case "CONFIGURATIONITEMS"<br /> FullPermissons = "READ&MODIFY&DELETE&DISTRIBUTE&ADMINISTER&CREATE&DELEGATE&MANAGEFOLDERS&NETWORKACCESS"<br />Case "DEPLOYMENTTEMPLATE"<br /> FullPermissons = "READ&MODIFY&DELETE&ADMINISTER&CREATE&DELEGATE"<br />Case "DEPLOYMENT"<br /> FullPermissons = "READ&MODIFY&DELETE&ADMINISTER&CREATE&DELEGATE"<br />Case "DEVICESETTINGPACKAGE"<br /> FullPermissons ="READ&MODIFY&DELETE&DISTRIBUTE&ADMINISTER&CREATE&DELEGATE&MANAGEFOLDERS"<br />Case "DEVICESETTINGITEM"<br /> FullPermissons = "READ&MODIFY&DELETE&ADMINISTER&CREATE&DELEGATE"<br />Case "DEPLYOMENTPACKAGE"<br /> FullPermissons = "READ&MODIFY&DELETE&DISTRIBUTE&ADMINISTER&CREATE&DELEGATE&MANAGEFOLDERS"<br />Case "COLLECTION"<br /> If ObjectEnv = "C" Then<br /> FullPermissons = "READ&MODIFY&DELETE&CREATE&REMOTE_CONTROL&ADVERTISE&MODIFY_RESOURCE&ADMINISTER&DELETE_RESOURCE&VIEWCOLLECTEDFILES&READ_RESOURCE&DELEGATE&MODIFYCOLLECTIONSETTING&MANAGEMGMTCONROLLERS&VIEWMGMTCONROLLERS"<br /> ElseIf ObjectEnv = "I" Then<br /> 'Collection Instances do no have the permissons CREATE, ADMINISTER, DELEGATE<br /> FullPermissons = "READ&MODIFY&DELETE&REMOTE_CONTROL&ADVERTISE&MODIFY_RESOURCE&DELETE_RESOURCE&VIEWCOLLECTEDFILES&READ_RESOURCE&MODIFYCOLLECTIONSETTING&MANAGEMGMTCONROLLERS&VIEWMGMTCONROLLERS"<br /> End If<br />Case "PACKAGE"<br /> FullPermissons = "READ&MODIFY&DELETE&DISTRIBUTE&ADMINISTER&CREATE&DELEGATE&MANAGEFOLDERS"<br />Case "ADVERTISEMENT"<br /> FullPermissons = "READ&MODIFY&DELETE&ADMINISTER&CREATE&DELEGATE&MANAGEFOLDERS"<br />Case "DRIVERPACKAGE"<br /> FullPermissons = "READ&MODIFY&DISTRIBUTE&DELETE&ADMINISTER&CREATE&DELEGATE&MANAGEFOLDERS"<br />Case "COMPUTERASSOCIATION"<br /> FullPermissons = "READ&DELETE&ADMINISTER&CREATE&DELEGATE&MANAGEFOLDERS&RECOVERUSERSTATE"<br />Case "DEVICEDRIVER"<br /> FullPermissons = "READ&MODIFY&DELETE&ADMINISTER&CREATE&DELEGATE&MANAGEFOLDERS"<br />Case "BOOTIMAGE"<br /> FullPermissons = "READ&MODIFY&DELETE&DISTRIBUTE&ADMINISTER&CREATE&DELEGATE&MANAGEFOLDERS"<br />Case Else<br /> Log "Permissons not supported"<br />End Select<br /><br />End Function<br /><br />Function Log(strTextToLog)<br /> WScript.Echo strTextToLog<br /> Dim objFile, objLogFile, objLogFile2<br /> Dim strFilenameWithoutExtension, intMaxFileSize, n <br /> intMaxFileSize = 15 * 1024 * 1024 '15MB <br /> 'strip ".vbs" from the full path scriptname <br /> strFilenameWithoutExtension= left(WScript.ScriptFullName,len(WScript.ScriptFullName)-4) <br /> On Error Resume Next <br /> n = -1 <br /> 'we need to check the current logfile size 1st - open the current logfile <br /> Set objFile = objFSO.getfile(strFilenameWithoutExtension & ".log") <br /> 'check if the the current logfile is bigger than the max file size <br /> If objFile.Size > intMaxFileSize Then <br /> 'it's bigger - so open the backup log file <br /> Set objLogFile2 = objFSO.getfile(strFilenameWithoutExtension & ".lo_") <br /> 'delete the backup file <br /> objLogFile2.Delete <br /> 'rename the original file to "*.lo_" <br /> objFile.name = left(objFile.name, len(objFile.name)-1) & "_" <br /> 'close the file <br /> objFile.close <br /> End If <br /> Set objLogFile = objFSO.opentextfile(strFilenameWithoutExtension & ".log", 8, True) <br /> 'objLogFile.writeline Date & " - " & Time & " - """ & strTextToLog & """" <br /> objLogFile.writeline Date & " - " & Time & " - " & " - """ & strTextToLog & """" <br /> If len(strTextToLog) > 78 then strTextToLog = left(strTextToLog,76) & "..."<br /> 'Log strTextToLog<br /> objLogFile.Close <br /> Set objFile = Nothing <br /> Set objFile2 = Nothing <br /> Set oLogFile = Nothing <br /> Set oFSOLog = Nothing <br /> If Err Then Err.Clear <br /> On Error GoTo 0 <br />End Function<br /></pre>merowingerhttp://www.blogger.com/profile/05679656055137095951noreply@blogger.com2tag:blogger.com,1999:blog-8996856623096968372.post-27093530739300140442011-04-13T16:34:00.004+02:002011-04-13T17:30:48.409+02:00vbScript - bulk import collectionsThis little vbscript loops throught the file CollectionStructure.txt and creates all the defined collections<br /><br /># are and blank lines are ignored<br /># are available for comments<br /><br />The <strong>CollectionStructure.txt</strong> file should look like this:<br /><pre class="bat" name="code"><br />############################################<br />################ EXAMPLES ##################<br />############################################<br />### Parent Collection;Child Collection<br />### COLLROOT;MyCollection1<br />### Collection1;MyCollection2<br />############################################<br />############################################<br />############################################<br /><br />#Create Collections for Department XYZ<br />COLLROOT;Department XYZ<br />Department XYZ;Department XYZ-123<br />Department XYZ;Department XYZ-ABC<br />Department XYZ;Department XYZ-LOL<br /><br />#Create Collections for Adobe Reader<br />SWDIST;Adobe Reader<br />Adobe Reader;Install_Adobe Reader<br />Adobe Reader;Uninstall_Adobe Reader<br /></pre><br /><br />The vbScript is the below code - Have fun ;)<br /><em>Note: There's not build in a lot of error handling, so please first test it</em><br /><br /><pre class="vb" name="code"><br />'************************************************************************************************************<br />' Jonas Hettich<br />'************************************************************************************************************<br />' Ver 1.00 - 13.04.2011 - initial version<br />' What this script does:<br />' This Scripts creates the Collection Structure defined in the file CollectionStructure.txt<br />'************************************************************************************************************<br />result = MsgBox("Do you really want to create the Collections?", vbYesNo)<br />If result = vbNo Then WScript.Quit<br /><br />Dim strSiteServer : strSiteServer = ""<br />Dim strSitecode : strSitecode = ""<br />Dim objSWbemLocator : Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")<br />Dim objSWbemServices : Set objSWbemServices = objSWbemLocator.ConnectServer(strSiteServer,"root/sms/site_" & strSitecode)<br /><br />Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")<br />Dim objFile : Set objFile = objFSO.OpenTextFile("CollectionStructure.txt")<br />Dim strCurrentLine<br />Dim strRootCollection, strChildCollection<br />Dim strRootCollectionID, strChildCollectionID<br /><br />'Loop the Source File<br />Do While not objFile.AtEndOfStream<br /> strCurrentLine = objFile.ReadLine<br /> <br /> 'Skip Comment and Blank lines<br /> If strCurrentLine <> "" Then<br /> If Not Left(strCurrentLine,1) = "#" Then<br /> 'Parse the Root- and Child Collection<br /> strRootCollection = Split(strCurrentLine,";")(0)<br /> strChildCollection = Split(strCurrentLine,";")(1)<br /> <br /> 'Create the collection.<br /> Dim strpath<br /> Dim objChildCollection : Set objChildCollection = objSWbemServices.Get("SMS_Collection").SpawnInstance_()<br /> objChildCollection.Name = strChildCollection<br /> objChildCollection.OwnedByThisSite = True<br /> strpath=objChildCollection.Put_<br /> <br /> If Err.Number = 0 Then<br /> WScript.Echo "Created Collection: " &strChildCollection<br /> Else<br /> WScript.Echo "Error creating Collection: " &strChildCollection &" - ErrNumber:" &Err.Number<br /> End If<br /> Err.Clear<br /> <br /> 'Get Collection ID<br /> Dim objCollection : Set objCollection=objSWbemServices.Get(strpath)<br /> strChildCollectionID = objCollection.CollectionID<br /> <br /> <br /> 'Configure Root Collection<br /> Dim objCollectionRelation<br /> Set objCollectionRelation = objSWbemServices.Get( "SMS_CollectToSubCollect" ).SpawnInstance_()<br /> If strRootCollection = "COLLROOT" Then<br /> objCollectionRelation.parentCollectionID = strRootCollection<br /> Else<br /> objCollectionRelation.parentCollectionID = CollectionNameToID(strRootCollection)<br /> End If<br /> objCollectionRelation.subCollectionID = strChildCollectionID<br /> objCollectionRelation.Put_<br /> <br /> If Err.Number = 0 Then<br /> WScript.Echo "Linked to Root Collection: " &strRootCollection<br /> Else<br /> WScript.Echo "Error when linking to Root Collectionn: " &strRootCollection &" - ErrNumber:" &Err.Number<br /> End If<br /> End If<br /> End If<br />Loop<br /><br />Function CollectionNameToID(strName)<br /> Dim strCollection<br /> Dim intCollectionID : intCollectionID = ""<br /> Dim allCollections : Set allCollections = objSWbemServices.ExecQuery("SELECT * FROM SMS_Collection WHERE Name = '" & strName & "'")<br /> For Each strCollection In allCollections<br /> intCollectionID = strCollection.CollectionID<br /> Next<br /><br /> CollectionNameToID = intCollectionID<br /> <br />End Function<br /></pre>merowingerhttp://www.blogger.com/profile/05679656055137095951noreply@blogger.com0tag:blogger.com,1999:blog-8996856623096968372.post-38932211362366566692011-04-12T11:12:00.003+02:002011-04-12T12:13:17.362+02:00Programmatically creating AppV Deployments in ConfigMgrWhen creating AppV Packages programmatically in ConfigMgr there are some things to consider as they do have programs like classic packages. It's important that the program name is the following string: <strong>[Virtual application]</strong>. If you use asterisk (*) or a any other string the package will not install.<br /><br />Here's a example how to create an AppV Program in VB.Net<br /><pre class="vb" name="code"><br />Set objNewProgram = oWMIService.Get("SMS_Program").SpawnInstance_()<br />objNewProgram.ProgramName = "[Virtual application]"<br />objNewProgram.PackageID = strPackageID<br /></pre><br /><br />If you want to create a Task Sequence which installs a AppV package you've also to define this string as the program name.<br /><pre class="vb" name="code"><br />Set objTSAction = connection.Get("SMS_TaskSequence_InstallSoftwareAction").SpawnInstance_<br />objTSAction.PackageID=strPackageID<br />objTSAction.ProgramName="[Virtual application]" <br />objTSAction.Name=strName<br /></pre>merowingerhttp://www.blogger.com/profile/05679656055137095951noreply@blogger.com0tag:blogger.com,1999:blog-8996856623096968372.post-6191267476166818242011-04-12T09:29:00.005+02:002011-04-12T12:14:23.319+02:00Advertisement on state "WaitingDisabled"An App-V Package which you try to deploy does not get installed.<br />If the App-V Package is assigned directly the Advertisement is not displayed in "Run advertised Programs". If the Package is assigned over a Task Sequence the Advertisement is visible, but cannot be executed. <br />In both cases the following Errors are shown:<br /><br />In CAS.log and Execmgr.log Client logfiles it looks like that the sources are found, but it ends up with the message that no sourcefiles could be located.<br /><em>Download location found 1<br />Matching DP Location found 0</em><br /><br />Also the state of the Advertisement is on WaitingDisabled<br /><br />The ConfigMgr behaviour is this case is correct, cause App-V is not active on your ConfigMgr Site<br /><br />Solution: Enable the AppV deployment on your site in the Client Agent Settings -> Advertised Programs Client Agent -> <strong>"Allow virtual application package advertisement"</strong>merowingerhttp://www.blogger.com/profile/05679656055137095951noreply@blogger.com2tag:blogger.com,1999:blog-8996856623096968372.post-3486197013875533942011-04-07T14:39:00.002+02:002011-04-07T14:44:16.952+02:00Restricted Users cannot create a Direct Membership Rule on a Collection programmatically in SCCMConsider the following scenario:<br />You have a User in SCCM 2007 who has only restricted permissions in SCCM. For example the User can just read and modify some specific collections, import computers and create Collection Membership Rules. When the User is using the SCCM Console there’s no problem and all tasks can be performed.<br />You have written a tool (vbscript, vb.net or whatever) which makes this User possible to perform some tasks very easy and fast on your SCCM Server. The User can import a new machine (with name and mac address), but when trying to create a Direct Membership Rule the tools crashes with <strong>“Generic failure</strong>”.<br />If you check the smsprov.log file on your SCCM Server you get this error message:<br /><strong>User … has no read resource rights in any collection for this ResourceID</strong><br /><br />The problem is that you cannot define a “Default Collection” in the SCCM API where the machine is member of from the beginning. As the User has no Read Rights on the all Collections Class it cannot find that Machine and so it cannot create the Membership Rule. Even if you catch the machine’s ResourceID from the <strong>ImportMachineEntry</strong> function when creating the machine you the tool crashes.<br /><br />Either you give the User read Permissions for the all Collections Class Rights, <em>(but then the User can see all Machines in SCCM)</em> or you use the following workaround:<br />When importing the machine entry there’s created a Status Message on your Site Server. This message looks like listed below and has the <strong>Message ID 30213</strong>:<br /><strong>User "XYZ" imported machine at site "SiteServer - SiteCode" (NetbiosName=YourMachineName, MACAddress=F7:E8:D3:A9:84:FE, SMBIOSGUID=)</strong>.<br />Now create a Status Filter Rule which gets triggered from when this MessageID occurs and start a script with the following command line:<br /><strong>cscript.exe YourScript.vbs %msgis04</strong><br />%msgis04 later contains the Machine name which you have created.<br />Now the script runs with the Local System Account of your SCCM Server and must create a Collection Membership Rule on any collection:<br /><br />Any part of this script would look like this:<br /><pre class="vb" name="code"><br />strComputername = Wscript.Arguments(0)<br />strCollectionID = “XYZ“<br />Set instCollection = objSWbemServices.Get("SMS_Collection.CollectionID='" &strCollectionID & "'")<br />Set instDirectRule = objSWbemServices.Get("SMS_CollectionRuleDirect").SpawnInstance_<br />instDirectRule.ResourceClassName = "SMS_R_System"<br />instDirectRule.ResourceID = NameTOResourceID(strComputerName)<br />instDirectRule.RuleName = strComputername<br />instCollection.AddMembershipRule(instDirectRule)<br /></pre><br /><br />After the script has been executed the Users tool should be able to create the Direct Membership Rule. <br /><br />AddOn: Maybe you have to build in a “wait-routine” in the Users tool until the Machine’s name get resolved into a ResourceID<br /><pre class="vb" name="code"><br />Do<br />objSWbemServices.ExecQuery("SELECT * FROM SMS_R_System WHERE Name = '" & strComputerName & "'"<br />Loop While objSWbemServices.Count = 0<br /></pre>merowingerhttp://www.blogger.com/profile/05679656055137095951noreply@blogger.com0tag:blogger.com,1999:blog-8996856623096968372.post-72201816700353579822011-04-06T22:49:00.010+02:002011-04-07T13:58:00.673+02:00Switch from Local System to User contextSometimes there’s a need to switch from Local System context to the current logged on User.<br />The following article describes how to achieve this. <br /><br />In short words the following happens:<br />1. Something is executed in local system context<br />2. At the end a EventLog entry is written<br />3. A Scheduled Tasks gets trigged by the created EventLog entry<br />4. The Scheduled Tasks which is running in User context executes another script<br /><br />One example is e.g. to inform Users about an Installation which was executed from the Local System Account. The Application Deployment process executes the CreateEventToInform.vbs Script at the end of the installation to create the EventLog entry for informing the User <br /><br /><strong>CreateEventToInform.vbs</strong><br /><pre class="vb" name="code">Dim objShell : Set objShell = CreateObject("WScript.Shell")<br />Dim strMessage : strMessage = "Dear User this is a message from your local system"<br />objShell.LogEvent(4, strMessage)<br /></pre><br /><br /><strong>InformUser.vbs</strong><br /><pre class="vb" name="code">Dim strMessage<br />Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & "."<br />& "\root\cimv2")<br />Set colLoggedEvents = objWMIService.ExecQuery("Select * from Win32_NTLogEvent Where Logfile = 'Application' and SourceName='WSH' and EventCode=4 and Type='Information'")<br /><br />For Each objEvent In colLoggedEvents<br />strMessage = objEvent.Message<br />Exit For<br />Next<br /><br />MsgBox(strMessage, vbInformation + vbOKOnly, "Your Company")<br /></pre><br /><br />It could also be used as an immediately executed “ActiveSetup” for the current logged User. The Application Deployment process executes the CreateEventToExecute.vbs Script at the end of the installation to create the EventLog entry for performing a Active Setup for the current User <br /><br /><strong>CreateEventToExecute.vbs</strong><br /><pre class="vb" name="code">Dim objShell : Set objShell = CreateObject("WScript.Shell")<br />Dim strCommandLine : strCommandLine = "msiexex /fup <msi>"<br />objShell.LogEvent(4, strCommandLine)<br /></pre><br /><br /><strong>ExecuteUserPart.vbs</strong><br /><pre class="vb" name="code">Dim objShell : Set objShell = CreateObject("Wscript.Shell")<br />Dim strCommandLine<br />Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & "." & "\root\cimv2")<br />Set colLoggedEvents = objWMIService.ExecQuery("Select * from Win32_NTLogEvent Where Logfile = 'Application' and SourceName='WSH' and EventCode=4 and Type='Information'")<br /><br />For Each objEvent In colLoggedEvents<br />strCommandLine = objEvent.Message<br />Exit For<br />Next<br /><br />objShell.Run(strCommandLine, 1, False)<br /></pre><br /><br />To make the whole think work we have to create a trigger which reacts to the EventLog Entry which was created. Create a Scheduled Tasks which is executed in the User context as listed below for this <br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAGQpdDeqSFE0xwpxlSFewwyXbPCLR72q4hn7CtWzG5y0Sr6e6jdvrAubFSKrEEoreAzm3BiWSWW3pch6RiZRv5SOPlxeDIKvgBUaXid2YNBIUxcFj3x1FWyY42H42_lveIrg8AuOBXk-5/s1600/2.png"><img style="cursor:pointer; cursor:hand;width: 400px; height: 345px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAGQpdDeqSFE0xwpxlSFewwyXbPCLR72q4hn7CtWzG5y0Sr6e6jdvrAubFSKrEEoreAzm3BiWSWW3pch6RiZRv5SOPlxeDIKvgBUaXid2YNBIUxcFj3x1FWyY42H42_lveIrg8AuOBXk-5/s400/2.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5592590705257898226" /></a><br />Note: You can deploy scheduled tasks to many computer automatically e.g. with Group Policies<br /><br />Now as soon as the EventID is written the Scheduled Tasks executes the below listed command<br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihzDgZXJLWoVRUL3fzWMva4Av0QOt2-rdiDJxyT5gthSXkSKnrUiYKA-GzaQh_SSI2-MMhgZPso9zD1jubfuS5u0VCwg53ZV3lH6-IZhwpa1AmYM2i_iXmZFkdt0397NyY-D6wLvfmgNB_/s1600/1.png"><img style="cursor:pointer; cursor:hand;width: 400px; height: 301px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihzDgZXJLWoVRUL3fzWMva4Av0QOt2-rdiDJxyT5gthSXkSKnrUiYKA-GzaQh_SSI2-MMhgZPso9zD1jubfuS5u0VCwg53ZV3lH6-IZhwpa1AmYM2i_iXmZFkdt0397NyY-D6wLvfmgNB_/s400/1.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5592590876541822578" /></a><br /><br /><br /><strong>Further thoughts:</strong><br />You could create a whole Application which is written variable so that you can perform different actions in User context. To achieve this easily you could tag the EventLog Message with specific keywords. Later the Application parses the EventLog Message and you can react on this. So you can use it for different scenarios. Example: <br /><br /><strong>WriteEventLog.vbs</strong><br /><pre class="vb" name="code">Dim objShell : Set objShell = CreateObject("WScript.Shell")<br />Dim strMessage : strMessage = "[Inform]Dear User now there's happening something" &vbNewLine &"[Execute]msiexex /fup <msi>"<br />objShell.LogEvent 4, strMessage<br /></pre><br /><br /><strong>PerformInUserContext.vbs</strong><br /><pre class="vb" name="code">Dim objShell : objShell = CreateObject("Wscript.Shell")<br />Dim strMessage, arrEventEntry<br />Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & "." & "\root\cimv2")<br />Set colLoggedEvents = objWMIService.ExecQuery("Select * from Win32_NTLogEvent Where Logfile = 'Application' and SourceName='WSH' and EventCode=4 and Type='Information'")<br /><br />For Each objEvent In colLoggedEvents<br />strMessage = objEvent.Message<br />Exit For<br />Next<br /><br />arrEventEntry = Split(strMessage, vbNewLine)<br /><br />For Each strLine In arrEventEntry<br />If InStr(strLine, "[Inform]") Then<br />MsgBox(Replace(strLine, "[Inform]", ""))<br />ElseIf InStr(strLine, "[Execute]") Then<br />objShell.Run(Replace(strLine, "[Execute]", ""), 1, False)<br />End If<br />Next<br /></pre>merowingerhttp://www.blogger.com/profile/05679656055137095951noreply@blogger.com0tag:blogger.com,1999:blog-8996856623096968372.post-77908369577528664242011-02-16T19:30:00.003+01:002011-02-16T19:32:52.733+01:00Windows 7 SP1 ReleasedWindows 7 and Windows Server 2008 R2 Service Pack 1 is no available for download on <a href="http://www.msdn.com/">MSDN</a>merowingerhttp://www.blogger.com/profile/05679656055137095951noreply@blogger.com0tag:blogger.com,1999:blog-8996856623096968372.post-20353726683475215062011-02-01T11:01:00.003+01:002011-02-01T11:07:05.208+01:00vbScript - Get running environmentThe following vbScript Function delivers the value <strong>true</strong> if the script runs within a task sequence environment. If not the functions delivers the value <strong>false</strong>. This function can be useful in scripts like wrapper and so on.<br /><br /><pre class="vb" name="code"><br />...<br />If RunningInTaskSequence = True Then<br />...<br /><br />Function RunningInTaskSequence()<br /> On Error Resume Next<br /> Err.Clear<br /> Dim objTSEnv : Set objTSEnv = CreateObject("Microsoft.SMS.TSEnvironment")<br /> If Err Then<br /> 'Script does not run within the Task Sequence environment<br /> RunningInTaskSequence = False<br /> Else<br /> 'Script does run within the Task Sequence environment<br /> RunningInTaskSequence = True<br /> End If<br /> On Error GoTo 0<br />End Function<br /></pre>merowingerhttp://www.blogger.com/profile/05679656055137095951noreply@blogger.com0tag:blogger.com,1999:blog-8996856623096968372.post-79032787094379003162011-02-01T10:46:00.002+01:002011-02-01T10:50:07.482+01:00Thanks to Mark Cochrane and Sherry Kissinger......for mention me in the new release of the RegKeyToMof v2.5 tool<br /><a href="http://myitforum.com/cs2/blogs/skissinger/archive/2010/12/01/march-cochrane-s-regkeytomof-v2-5.aspx">Here's the associated blog entry</a>merowingerhttp://www.blogger.com/profile/05679656055137095951noreply@blogger.com0tag:blogger.com,1999:blog-8996856623096968372.post-4792735854594207112010-12-01T08:58:00.005+01:002010-12-01T09:12:36.335+01:00Task Sequence Environment not available<strong>Problem:</strong><br />Your deploying a Script which shell use Task Sequence Variables with SCCM.<br />There seems to be a problem when creating the object for the Task Sequence Environment <em>CreateObject("Microsoft.SMS.TSEnvironment")</em>. <br />You may also get the following error: <em>Error 429 - ActiveX component can't create object</em>.<br /><br /><strong>Solution:</strong><br />Make sure that your really running the script within a Task Sequence. Also check that you have created a Task Sequence Advertisement (Advertise Task Sequence).merowingerhttp://www.blogger.com/profile/05679656055137095951noreply@blogger.com0tag:blogger.com,1999:blog-8996856623096968372.post-65514995709460398192010-09-27T17:43:00.017+02:002010-12-01T09:16:06.087+01:00NULL Values in SCCM Hardware InventoryI tried to capture the value of the registry key HKLM\SOFTWARE\YOURCOMPANY\Department from all systems independed of the OS architecture. I had the problem that the inventory delivered NULL Values in the database, although everything seemed to be configured correctly. The problem occurred very sporadic. Sometimes a system delivered a value and sometimes it didn’t.<br />Here’s my basic configuration.mof and sms_def.mof<br /><br /><strong>configuration.mof</strong><br /><span style="font-size:85%;"><span style="color:#000099;">#pragma namespace ("\\\\.\\root\\cimv2")<br />#pragma deleteclass("CustomHINV86", NOFAIL)<br />[DYNPROPS]<br />class CustomHINV86<br />{<br />[key] string KeyName = "";<br />string Department;<br />};<br /><br />[DYNPROPS]<br />instance of CustomHINV86<br />{<br />KeyName="CustomHINV";<br />[PropertyContext("localHKEY_LOCAL_MACHINE\\SOFTWARE\\YOURCOMPANYDepartment"),<br />Dynamic, Provider("RegPropProv")]<br />Department;<br />};<br /><br />#pragma namespace ("\\\\.\\root\\cimv2")<br />#pragma deleteclass("CustomHINV64", NOFAIL)<br />[DYNPROPS]<br />class CustomHINV64<br />{<br />[key] string KeyName = "";<br />string Department;<br />};<br /><br />[DYNPROPS]<br />instance of CustomHINV64<br />{<br />KeyName="CustomHINV";<br />[PropertyContext("localHKEY_LOCAL_MACHINE\\SOFTWARE\\YOURCOMPANYDepartment"),<br />Dynamic, Provider("RegPropProv")]<br />Department;<br />}; </span><br /></span><br /><br /><strong>sms_def.mof</strong><br /><span style="font-size:78%;"><span style="color:#000099;">#pragma namespace ("\\\\.\\root\\cimv2\\SMS")<br />#pragma deleteclass("CustomHINV86", NOFAIL)<br />[SMS_Report(TRUE),<br />SMS_Group_Name("Your Custom HINV"),<br />SMS_Class_ID("YOURCOMPANYYour Custom HINV1.0"),<br />SMS_Context_1 ("__ProviderArchitecture=32uint32"),<br />SMS_Context_2 ("__RequiredArchitecture=trueboolean")]<br /><br />Class CustomHINV86: SMS_Class_Template<br />{<br />[SMS_Report(TRUE),key] string KeyName;<br />[SMS_Report(TRUE)] String Department;<br />};<br /><br />#pragma namespace ("\\\\.\\root\\cimv2\\SMS")<br />#pragma deleteclass("CustomHINV64", NOFAIL)<br />[SMS_Report(TRUE),<br />SMS_Group_Name("Your Custom HINV"),<br />SMS_Class_ID("YOURCOMPANYYour Custom HINV1.0"),<br />SMS_Context_1 ("__ProviderArchitecture=64uint32"),<br />SMS_Context_2 ("__RequiredArchitecture=trueboolean")]<br /><br />Class CustomHINV64: SMS_Class_Template<br />{<br />[SMS_Report(TRUE),key] string KeyName;<br />[SMS_Report(TRUE)] String Department;<br />};</span><br /></span><br />The result was the following entry in the SQL table<br /><table style="WIDTH: 400px HEIGHT: 14px" border="”1”" cellspacing="2" cellpadding="2" width="400"><tbody><tr align="”center”"><td><span style="font-size:85%;">ResourceID</span></td><td><span style="font-size:85%;">GroupID</span></td><td><span style="font-size:85%;">RevisionID</span></td><td><span style="font-size:85%;">AgentID</span></td><td><span style="font-size:85%;">TimeStamp</span></td><td><span style="font-size:85%;">Department0</span></td><td><span style="font-size:85%;">KeyName0</span></td></tr><tr><td><span style="font-size:85%;">33</span></td><td><span style="font-size:85%;">1</span></td><td><span style="font-size:85%;">3</span></td><td><span style="font-size:85%;">1</span></td><td><span style="font-size:85%;">14.09.2010 16:59:19</span></td><td><em><span style="font-size:85%;color:#ff0000;">NULL</span></em></td><td><span style="font-size:85%;">CustomHINV</span></td></tr></tbody></table><br /><br /><strong>That’s the problem!</strong><br />As the hardware inventory listed above is designed for both OS architecture, there should be created two entries in the table. I then compared those entries with some working one, from another customization and saw the differences.<br />The entries were overwritten, as the column KeyName0 is not unique. This also explained the sporadic behavior. Depending on which inventory entry (32bit or 64 bit) was written into the database in which order, the first one was overwritten.<br />The correct entries for a 64 bit system should look like this:<br /><table style="WIDTH: 400px; HEIGHT: 14px" border="”1”" cellspacing="2" cellpadding="2" width="400"><tbody><tr align="”center”"><td><span style="font-size:85%;">ResourceID</span></td><td><span style="font-size:85%;">GroupID</span></td><td><span style="font-size:85%;">RevisionID</span></td><td><span style="font-size:85%;">AgentID</span></td><td><span style="font-size:85%;">TimeStamp</span></td><td><span style="font-size:85%;">Department0</span></td><td><span style="font-size:85%;">KeyName0</span></td></tr><tr><td><span style="font-size:85%;">33</span></td><td><span style="font-size:85%;">1</span></td><td><span style="font-size:85%;">3</span></td><td><span style="font-size:85%;">1</span></td><td><span style="font-size:85%;">14.09.2010 16:59:19</span></td><td><em><span style="font-size:85%;color:#ff0000;">NULL</span></em></td><td><span style="font-size:85%;color:#ff0000;">CustomHINV86</span></td></tr><tr><td><span style="font-size:85%;">33</span></td><td><span style="font-size:85%;">1</span></td><td><span style="font-size:85%;">3</span></td><td><span style="font-size:85%;">1</span></td><td><span style="font-size:85%;">14.09.2010 16:59:19</span></td><td><span style="font-size:85%;color:#ff0000;">MyValue</span></td><td><span style="font-size:85%;color:#ff0000;">CustomHINV64</span></td></tr></tbody></table><br /><br />So the result was to customize the configuration.mof file the get unique KeyName0 columns. Here it is:<br /><span style="font-size:78%;"><span style="color:#000099;">#pragma namespace ("\\\\.\\root\\cimv2")<br />#pragma deleteclass("CustomHINV86", NOFAIL)<br />[DYNPROPS]<br />class CustomHINV86<br />{<br />[key] string KeyName = "";<br />string Department;<br />};<br /><br />[DYNPROPS]<br />instance of CustomHINV86<br />{<br /><span style="color:#ff0000;">KeyName="CustomHINV86";</span><br />[PropertyContext("localHKEY_LOCAL_MACHINE\\SOFTWARE\\YOURCOMPANYDepartment"),<br />Dynamic, Provider("RegPropProv")]<br />Department;<br />};<br /><br /><br />#pragma namespace ("\\\\.\\root\\cimv2")<br />#pragma deleteclass("CustomHINV64", NOFAIL)<br />[DYNPROPS]<br />class CustomHINV64<br />{<br />[key] string KeyName = "";<br />string Department;<br />};<br /><br />[DYNPROPS]<br />instance of CustomHINV64<br />{<br /><span style="color:#ff0000;">KeyName="CustomHINV64";</span><br />[PropertyContext("localHKEY_LOCAL_MACHINE\\SOFTWARE\\YOURCOMPANYDepartment"),<br />Dynamic, Provider("RegPropProv")]<br />Department;<br />};</span> </span>merowingerhttp://www.blogger.com/profile/05679656055137095951noreply@blogger.com2tag:blogger.com,1999:blog-8996856623096968372.post-67101140681563495362010-08-25T11:56:00.006+02:002010-08-25T18:16:51.726+02:00SCCM PatchMgmt - Custom ReportsHere are some SCCM Patch Managenment Reports which i've created for my customers<br /><br /><strong>Maintenance/Patch - Windows and each Computer</strong><br /><pre class="SQL" name="code"><br />select <br />v_Collection.Name as CollectionName, <br />v_ServiceWindow.Description, <br />v_FullCollectionMembership.Name as Computername <br />from v_ServiceWindow <br />inner join v_FullCollectionMembership on (v_FullCollectionMembership.CollectionID = v_ServiceWindow.CollectionID) <br />inner join v_Collection on (v_Collection.CollectionID = v_FullCollectionMembership.CollectionID) <br />order By v_Collection.Name <br /></pre><br /><br /><br /><strong>Required Updates for a specific Computer</strong><br /><pre class="SQL" name="code"><br />select <br />v_R_System.name0 as 'Computername', <br />v_UpdateInfo.Title as 'Updatename', <br />v_StateNames.Statename <br />from <br />v_StateNames, <br />v_Update_ComplianceStatusAll <br />Inner Join v_R_System On (v_R_System.ResourceID = v_Update_ComplianceStatusAll.ResourceID) <br />Inner Join v_UpdateInfo On (v_UpdateInfo.CI_ID = v_Update_ComplianceStatusAll.CI_ID) <br />where <br />v_StateNames.TopicType = 500 and <br />v_StateNames.StateID = v_Update_ComplianceStatusAll.Status and <br />v_R_System.name0 = @Computername and <br />Statename = 'Update is required' <br /></pre><br /><br /><strong>Count of Required Updates for all Computers</strong><br /><pre class="SQL" name="code"><br />select <br />v_R_System.Name0 as 'Computername', <br />Count(v_StateNames.Statename) as 'Required Updates' <br />from <br />v_StateNames, <br />v_Update_ComplianceStatusAll <br />Inner Join v_R_System On (v_R_System.ResourceID = v_Update_ComplianceStatusAll.ResourceID) <br />Inner Join v_UpdateInfo On (v_UpdateInfo.CI_ID = v_Update_ComplianceStatusAll.CI_ID) <br />where <br />v_StateNames.TopicType = 500 and <br />v_StateNames.StateID = v_Update_ComplianceStatusAll.Status and <br />v_StateNames.Statename = 'Update is required' <br />Group By v_R_System.Name0 <br /></pre><br /><br /><strong>Number of Computers requiring an Update</strong><br /><pre class="SQL" name="code"><br />select <br />v_UpdateInfo.Title as 'Updatename', <br />Count(v_R_System.name0) as 'Count of Computers' <br />from <br />v_StateNames, <br />v_Update_ComplianceStatusAll <br />Inner Join v_R_System On (v_R_System.ResourceID = v_Update_ComplianceStatusAll.ResourceID) <br />Inner Join v_UpdateInfo On (v_UpdateInfo.CI_ID = v_Update_ComplianceStatusAll.CI_ID) <br />where <br />v_StateNames.TopicType = 500 and <br />v_StateNames.StateID = v_Update_ComplianceStatusAll.Status and <br />Statename = 'Update is required' <br />Group By v_UpdateInfo.Title <br />Order By 'Count of Computers' DESC <br /></pre><br /><br /><strong>Assinged number of Updates for each Computer</strong><br /><pre class="SQL" name="code"><br />select <br />v_R_System.Name0 as Computername, <br />Count(v_UpdateInfo.Title) as Updates<br />from v_UpdateState_Combined<br />inner join v_R_System on (v_R_System.ResourceID = v_UpdateState_Combined.ResourceID) <br />inner join v_CIAssignmentToCI on (v_CIAssignmentToCI.CI_ID = v_UpdateState_Combined.CI_ID) <br />inner join v_CIAssignment on (v_CIAssignment.AssignmentID = v_CIAssignmentToCI.AssignmentID) <br />inner join v_UpdateInfo on (v_UpdateInfo.CI_ID = v_UpdateState_Combined.CI_ID) <br />inner join v_StateNames on (v_StateNames.TopicType = v_UpdateState_Combined.StateType) <br />where<br />v_StateNames.StateID = v_UpdateState_Combined.StateID and<br />v_StateNames.StateName not like 'Update is not required'<br />Group by v_R_System.Name0<br /></pre><br /><br /><strong>Assinged Updates and current State for a specific Computer</strong><br /><pre class="SQL" name="code"><br />select <br />v_R_System.Name0 as 'Computername', <br />v_UpdateInfo.Title as 'UpdateDescription', <br />v_StateNames.StateName as 'State'<br />from v_UpdateState_Combined, v_CIAssignmentToCI,v_CIAssignment, v_UpdateInfo,v_StateNames, v_R_System<br />where v_R_System.Name0 = @MACHINENAME and<br />v_UpdateState_Combined.ResourceID = v_R_System.ResourceID and<br />v_UpdateState_Combined.CI_ID = v_CIAssignmentToCI.CI_ID and<br />v_CIAssignmentToCI.AssignmentID = v_CIAssignment.AssignmentID and<br />v_UpdateState_Combined.CI_ID = v_UpdateInfo.CI_ID and<br />v_UpdateState_Combined.StateType = v_StateNames.TopicType and <br />v_UpdateState_Combined.StateID = v_StateNames.StateID and<br />v_StateNames.StateName not like 'Update is not required'<br />Order By UpdateDescription<br /></pre><br /><br /><strong>Assinged Updates in an UpdateList and current State for a specific Computer</strong><br /><pre class="SQL" name="code"><br />select distinct v_R_System.Name0,v_StateNames.StateName, v_UpdateInfo.Title<br />from v_AuthListInfo,v_CIRelation,v_UpdateState_Combined,v_StateNames,v_UpdateInfo,v_R_System<br />where v_AuthListInfo.CI_ID = v_CIRelation.FromCIID and<br />v_CIRelation.ToCIID = v_UpdateInfo.CI_ID and<br />v_UpdateState_Combined.CI_ID = v_CIRelation.ToCIID and<br />v_StateNames.TopicType = v_UpdateState_Combined.StateType and<br />v_StateNames.StateID = v_UpdateState_Combined.StateID and<br />v_R_System.ResourceID = v_UpdateState_Combined.ResourceID and<br />v_R_System.Name0 = @COMPUTERNAME and<br />v_AuthListInfo.Title = @UPDATELIST and<br />v_StateNames.StateName not like 'Update is not required' <br /></pre><br /><br /><strong>Number of assinged Updates in an UpdateList and current State for all Computers</strong><br /><pre class="SQL" name="code"><br />select v_R_System.Name0 as Computername , v_StateNames.StateName ,count(v_UpdateInfo.Title) as UpdateCount, v_AuthListInfo.Title as Updatelist<br />from v_AuthListInfo<br />inner join v_CIRelation On (v_CIRelation.FromCIID = v_AuthListInfo.CI_ID)<br />inner join v_UpdateInfo On (v_UpdateInfo.CI_ID = v_CIRelation.ToCIID)<br />inner join v_CIAssignmentToCI on (v_CIAssignmentToCI.CI_ID = v_CIRelation.ToCIID)<br />inner join v_CIAssignmentTargetedMachines on (v_CIAssignmentTargetedMachines.AssignmentID = v_CIAssignmentToCI.AssignmentID)<br />inner join v_R_System on (v_R_System.ResourceID = v_CIAssignmentTargetedMachines.ResourceID)<br />inner join v_UpdateState_Combined on (v_UpdateState_Combined.CI_ID = v_CIRelation.ToCIID)<br />inner join v_StateNames on (v_StateNames.StateID = v_UpdateState_Combined.StateID)<br />where v_AuthListInfo.Title = @UPDATELIST and<br />v_UpdateState_Combined.ResourceID = v_R_System.ResourceID and<br />v_StateNames.TopicType = v_UpdateState_Combined.StateType<br />and v_StateNames.StateName not like 'Update is not required'<br />group by v_R_System.Name0, v_StateNames.StateName, v_AuthListInfo.Title<br />order by v_R_System.Name0<br /></pre><br /><br /><strong>Number of Updates in an Update Deployment</strong><br /><pre class="SQL" name="code"><br />select AssignmentName as Deployment,Count(CI_ID) as UpdateCount<br />from v_CIAssignment <br />Inner Join v_CIAssignmentToCI On (v_CIAssignmentToCI.AssignmentID = v_CIAssignment.AssignmentID)<br />where AssignmentName Like 'Update%' <br />Group By AssignmentName<br />order By AssignmentName<br /></pre><br /><br /><strong>All Updates in an Updatelist</strong><br /><pre class="SQL" name="code"><br />select distinct v_UpdateInfo.Title<br />from v_AuthListInfo,v_CIRelation,v_UpdateInfo<br />where v_AuthListInfo.CI_ID = v_CIRelation.FromCIID and<br />v_CIRelation.ToCIID = v_UpdateInfo.CI_ID and<br />v_AuthListInfo.Title = @UPDATELIST<br />order by v_UpdateInfo.Title<br /></pre>merowingerhttp://www.blogger.com/profile/05679656055137095951noreply@blogger.com15tag:blogger.com,1999:blog-8996856623096968372.post-71413081959247881872010-08-24T09:42:00.005+02:002011-02-01T11:12:41.866+01:00ConfigMgr Patch Installer<p>The <strong>ConfigMgr Patch Installer</strong> is a tool (vbscript) which can be used for installing updates which are advertised from SCCM. If the updates are advertised without a deadline. Especially it is useful for <em>Windows Server 2008 Core </em>edition as they <u>do not have a GUI</u> and so the updates can't be installed. My tool will query SCCM for each Update which is advertised to the System and will install it. The result can be displayed in a output logfile.</p><p>The Tool can be downloaded at <a href="http://www.systemcentercentral.com/tabid/144/indexId/64192/Default.aspx">systemcentercentral.com</a> and <a href="http://www.winoneclick.com">winoneclick.com</a></p>merowingerhttp://www.blogger.com/profile/05679656055137095951noreply@blogger.com0tag:blogger.com,1999:blog-8996856623096968372.post-8722318278122803042010-08-20T16:46:00.004+02:002010-08-20T17:01:40.922+02:00vbScript - Migrate Reports from SMS to SCCMThis script will migrate all advertisements from on site sms/sccm to another one. It should also migrate the prompts in the report. But this is a very tricky part<br /><strong>Be careful: Never run the script in your production until you've tested it!!!</strong><br /><br /><pre class="vb" name="code"><br />On Error Resume Next<br />Option Explicit<br /><br />Dim strSourceServer : strSourceServer = "SMSServer"<br />Dim strTargetServer : strTargetServer = "SCCMServer"<br />Dim strSourceSiteCode : strSourceSiteCode = "000"<br />Dim strTargetSiteCode : strTargetSiteCode = "000"<br />Dim objSourceWMIService, objTargetWMIService<br />dim AllReports, objReport, newReport<br />Dim AllContainers, objContainer<br />Dim objLazyProperties, Path, Report<br />Dim strNewContainerID<br />Dim AllParameters, objParameter<br />Dim intContainerObjectType : intContainerObjectType = 8<br />Dim objReportParams, strReportParamClass, newReportParam<br />Dim bolReportParamsAvailable : bolReportParamsAvailable = False<br />Dim intReportParameterCount : intReportParameterCount = 0<br />Dim arrTempParam()<br /><br /><br />Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")<br />Dim objLogFile : Set objLogFile = objFSO.CreateTextFile("MigrateReports.log")<br /><br />Set objSourceWMIService = GetObject("winmgmts://" & strSourceServer & "\root\sms\site_" & strSourceSiteCode)<br />Set objTargetWMIService = GetObject("winmgmts://" & strTargetServer & "\root\sms\site_" & strTargetSiteCode)<br /><br />'Creating all Containers<br />Call CreateContainer<br /><br />'Only Reports in SubContainers<br />'Set AllContainers = objSourceWMIService.ExecQuery("SELECT * FROM SMS_ObjectContainerItem WHERE ObjectType='" &intContainerObjectType &"'") <br />'For Each objContainer In AllContainers<br /> <br /> 'Set AllReports = objSourceWMIService.ExecQuery("SELECT * FROM SMS_Report WHERE SecurityKey='" &objContainer.InstanceKey &"'")<br /> Set AllReports = objSourceWMIService.ExecQuery("SELECT * FROM SMS_Report")<br /> <br /> For Each objReport In AllReports<br /> <br /> 'Check if there are Report parameter<br /> Set objReport = objSourceWMIService.Get("SMS_Report.ReportID=" & objReport.ReportID) <br /> On Error Resume Next<br /> <br /> 'For each Parameter in the Report<br /> For i = 0 To UBound(objReport.ReportParams)<br /> Set objReportParams = objReport.ReportParams(i)<br /> strReportParamClass=objReportParams.Path_.Class<br /> If strReportParamClass = "SMS_ReportParameter" Then<br /> bolReportParamsAvailable = True<br /> ReDim Preserve arrTempParam(i)<br /><br /> Set newReportParam = objSourceWMIService.Get("SMS_ReportParameter").SpawnInstance_<br /> newReportParam.VariableName = objReportParams.VariableName<br /> newReportParam.PromptText = objReportParams.PromptText<br /> newReportParam.DefaultValue = objReportParams.DefaultValue<br /> newReportParam.AllowEmpty = objReportParams.AllowEmpty<br /> newReportParam.SampleValueSQL = objReportParams.SampleValueSQL<br /> <br /> Set arrTempParam(i) = newReportParam<br /> objLogFile.WriteLine Now &" - Report Parameter available " &objReport.Name<br /> <br /> Else<br /> bolReportParamsAvailable = False<br /> objLogFile.WriteLine Now &" - No Report Parameter (skipping) " &objReport.Name<br /> End If<br /> Next<br /> On Error GoTo 0<br /> <br /> <br /> For Each item In arrTempParam<br /> WScript.Echo item.VariableName<br /> Next<br /> <br /> Set newReport = objTargetWMIService.Get("SMS_Report").SpawnInstance_<br /> <br /> newReport.Category = objReport.Category<br /> newReport.Comment = objReport.Comment<br /> newReport.DrillThroughColumns = objReport.DrillThroughColumns<br /> newReport.DrillThroughURL = objReport.DrillThroughURL<br /> newReport.GraphCaption = objReport.GraphCaption<br /> newReport.GraphType = objReport.GraphType<br /> newReport.GraphXCol = objReport.GraphXCol<br /> newReport.GraphYCol = objReport.GraphYCol<br /> newReport.Name = "NEW " &objReport.Name<br /> newReport.NumPrompts = objReport.NumPrompts<br /> newReport.RefreshInterval = objReport.RefreshInterval<br /> <br /> If bolReportParamsAvailable = true Then <br /> newReport.ReportParams = arrTempParam<br /> <br /> bolReportParamsAvailable = False<br /> Set objReportParams = Nothing<br /> Set newReportParam = Nothing<br /> strReportParamClass = ""<br /> End If<br /> <br /> newReport.StatusMessageDetailSource = objReport.StatusMessageDetailSource<br /> newReport.XColLabel = objReport.XColLabel<br /> newReport.YColLabel = objReport.YColLabel<br /> newReport.DrillThroughReportID = objReport.DrillThroughReportID<br /> newReport.DrillThroughReportPath = objReport.DrillThroughReportPath<br /> newReport.MachineDetail = objReport.MachineDetail<br /> newReport.MachineSource = objReport.MachineSource<br /> <br /> 'Get SQL Query of the Report and Count the Report Parameter<br /> Set objLazyProperties = objSourceWMIService.Get("SMS_Report.ReportID=" &objReport.ReportID)<br /> intReportParameterCount = Len(objLazyProperties.SQLQuery) - Len(Replace(objLazyProperties.SQLQuery, "@", ""))<br /> newReport.SQLQuery = objLazyProperties.SQLQuery<br /> <br /> If objLazyProperties Is Nothing Then<br /> objLogFile.WriteLine Now &" - Error: Cannot read SQLQuery from Report " &objReport.Name &". Skipping this Report"<br /> Else<br /> objLogFile.WriteLine Now &" - Creating Report " &objReport.Name<br /> <br /> 'Write the instance to WMI<br /> Path = newReport.Put_()<br /> <br /> 'Get automatically assigned package ID<br /> 'Set Report=objTargetWMIService.Get(Path)<br /> <br /> 'Getting new Container ID<br /> 'strNewContainerID = GetNewContainerID(ContainerIDToName( objContainer.ContainerNodeID))<br /> <br /> 'Moving the Report into the Container<br /> 'Call MoveReportInToContainer(strNewContainerID, Report.SecurityKey)<br /> <br /> 'Clean up<br /> Set objLazyProperties = Nothing <br /> End If<br /><br /> Next<br />'Next<br /><br />WScript.Echo "Done"<br /><br />Sub CreateContainer<br /><br />Dim AllSourceContainer, objSourceContainer<br />Dim objTargetContainer<br /><br /> Set AllSourceContainer = objSourceWMIService.ExecQuery("SELECT * FROM SMS_ObjectContainerNode WHERE ObjectType='" &intContainerObjectType &"'")<br /> For Each objSourceContainer In AllSourceContainer<br /> <br /> objLogFile.WriteLine Now &" - Migrating Container " &objSourceContainer.Name<br /> Set objTargetContainer = objTargetWMIService.Get("SMS_ObjectContainerNode").SpawnInstance_()<br /> objTargetContainer.Name = objSourceContainer.Name<br /> objTargetContainer.ObjectType = objSourceContainer.ObjectType<br /> objTargetContainer.ParentContainerNodeID = objSourceContainer.ParentContainerNodeID<br /> On Error Resume Next<br /> objTargetContainer.Put_<br /> On Error GoTo 0<br /> <br /> Next<br /> <br />End Sub<br /><br />Function ContainerIDToName(ContainerID)<br />Dim AllContainers, objContainer<br /><br />Set AllContainers = objSourceWMIService.ExecQuery("SELECT * FROM SMS_ObjectContainerNode WHERE ObjectType='" &intContainerObjectType &"' AND ContainerNodeID='" &ContainerID &"'") <br />For Each objContainer In AllContainers<br /> ContainerIDToName = objContainer.Name<br />Next<br /><br />End Function<br /><br />Function GetNewContainerID(ContainerName)<br />Dim AllSourceContainer, objSourceContainer<br /> <br />Set AllSourceContainer = objTargetWMIService.ExecQuery("SELECT * FROM SMS_ObjectContainerNode WHERE ObjectType='" &intContainerObjectType &"' and Name = '" &ContainerName &"'")<br /><br />For Each objSourceContainer In AllSourceContainer<br /> GetNewContainerID = objSourceContainer.ContainerNodeID<br />Next<br /><br />End Function<br /><br />Function MoveReportInToContainer(ContainerID, ReportID)<br />Dim folderItem<br /><br />If ContainerID <> "" Then<br /><br /> objLogFile.WriteLine Now &" - Moving Report " &ReportID &" into Container " &ContainerID<br /> <br /> Set folderItem = objTargetWMIService.Get("SMS_ObjectContainerItem").SpawnInstance_()<br /> folderItem.InstanceKey = ReportID<br /> folderItem.ObjectType = "8"<br /> folderItem.ContainerNodeID = ContainerID<br /> folderItem.Put_<br />Else<br /> objLogFile.WriteLine Now &" - No need to move the Report " &ReportID &", because it's listed in the root"<br />End If<br /> <br />End Function<br /></pre>merowingerhttp://www.blogger.com/profile/05679656055137095951noreply@blogger.com0tag:blogger.com,1999:blog-8996856623096968372.post-64287879342507446432010-08-20T16:43:00.004+02:002010-08-20T17:01:47.400+02:00vbScript - Migrate Advertisements from SMS to SCCMThis script will migrate all advertisements from on site sms/sccm to another one<br /><strong>Be careful: Never run the script in your production until you've tested it!!!</strong><br /><br /><pre class="vb" name="code"><br />'On Error Resume Next<br />'Option Explicit<br /><br />Dim strSourceServer : strSourceServer = "SMSServer"<br />Dim strTargetServer : strTargetServer = "SCCMServer"<br />Dim strSourceSiteCode : strSourceSiteCode = "000"<br />Dim strTargetSiteCode : strTargetSiteCode = "000"<br />Dim objSourceWMIService, objTargetWMIService<br />Dim AllPackages, objPackage<br />Dim strProgramName, strCurPackageVersion, strCurpackageLanguage, strCurPackageManufacturer<br />Dim Token, schedule, schedtype<br />Dim Path<br />Dim strNewCollectionsID, strNewPackageID, strNewContainerID<br />Dim AllAdvertisements, objAdvertisement, newAdvertisement, Advertisement<br />Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")<br />Dim objLogFile : Set objLogFile = objFSO.CreateTextFile("MigrateAdvertisements.log")<br /><br />Set objSourceWMIService = GetObject("winmgmts://" & strSourceServer & "\root\sms\site_" & strSourceSiteCode)<br />Set objTargetWMIService = GetObject("winmgmts://" & strTargetServer & "\root\sms\site_" & strTargetSiteCode)<br /><br />'Creating Container<br />Call CreateContainer<br /><br />Set AllAdvertisements = objSourceWMIService.ExecQuery("Select * From SMS_Advertisement") <br />For Each objAdvertisement In AllAdvertisements<br /> <br /> strProgramName = objAdvertisement.ProgramName<br /> objLogFile.WriteLine Now &" - The program " &strProgramName &" is assigned to the Advertisement " &objAdvertisement.AdvertisementName<br /> <br /> 'Get Container ID of the Advertisement<br /> strNewContainerID = GetNewContainerID(ContainerIDToName(GetContainerID(objAdvertisement.AdvertisementID)))<br /> objLogFile.WriteLine Now &" - New ContainerID for Advertisement " &objAdvertisement.AdvertisementName &" is " &strNewContainerID<br /> <br /> 'Get New Collections ID<br /> strNewCollectionsID = GetNewCollectionsID(CollectionIDToName(objAdvertisement.CollectionID))<br /> objLogFile.WriteLine Now &" - The CollectionID " &strNewCollectionsID &" will be assigned to " &objAdvertisement.AdvertisementName<br /> <br /> 'Get New Package ID<br /> strNewPackageID = GetNewPackageID(PackageIDToName(objAdvertisement.PackageID))<br /> objLogFile.WriteLine Now &" - The PackageID " &strNewPackageID &" will be assigned to " &objAdvertisement.AdvertisementName<br /> <br /> 'Create Advertisement<br /> If strNewCollectionsID <> "" And strProgramName <> "" And strNewPackageID <> "" Then<br /> Set newAdvertisement = objTargetWMIService.Get("SMS_Advertisement").SpawnInstance_()<br /> Set lazyproperties = objSourceWMIService.get("sms_advertisement.advertisementid='" & objAdvertisement.advertisementid & "'")<br /><br /> newAdvertisement.assignedscheduleenabled = lazyproperties.assignedscheduleenabled<br /> newAdvertisement.assignedscheduleisgmt = lazyproperties.assignedscheduleisgmt<br /> newAdvertisement.expirationtimeenabled = lazyproperties.expirationtimeenabled<br /> newAdvertisement.expirationtimeisgmt = lazyproperties.expirationtimeisgmt<br /> newAdvertisement.assignedschedule = lazyproperties.assignedschedule<br /> newAdvertisement.presenttimeisgmt=lazyproperties.presenttimeisgmt<br /><br /> newAdvertisement.AdvertisementName = objAdvertisement.AdvertisementName<br /> newAdvertisement.AdvertFlags= objAdvertisement.AdvertFlags<br /> newAdvertisement.CollectionID = strNewCollectionsID<br /> newAdvertisement.DeviceFlags = DeviceFlags<br /> newAdvertisement.comment = objAdvertisement.Comment <br /> newAdvertisement.ExpirationTime= objAdvertisement.ExpirationTime<br /> newAdvertisement.HierarchyPath = objAdvertisement.HierarchyPath<br /> newAdvertisement.IncludeSubCollection = objAdvertisement.IncludeSubCollection<br /> newAdvertisement.PackageID = strNewPackageID<br /> newAdvertisement.PresentTime=objAdvertisement.PresentTime<br /> newAdvertisement.PresentTimeEnabled=objAdvertisement.PresentTimeEnabled<br /> newAdvertisement.ProgramName = strProgramName<br /> newAdvertisement.RemoteClientFlags = objAdvertisement.RemoteClientFlags<br /> newAdvertisement.Priority = objAdvertisement.Priority<br /> newAdvertisement.TimeFlags = objAdvertisement.TimeFlags<br /> Path = newAdvertisement.Put_<br /> <br /> 'Get automatically assigned Advertisement ID<br /> Set Advertisement=objTargetWMIService.Get(Path)<br /> 'Moving the Advertisements into Container<br /> Call MoveAdvertisementInToContainer(strNewContainerID, Advertisement.AdvertisementID)<br /> <br /> Else<br /> objLogFile.WriteLine Now &" - ERROR: Advertisement " &objAdvertisement.AdvertisementName &" could not be migrated. Maybe a Collection, Package or Program does not exist"<br /> End If<br /> <br /> strProgramName = ""<br /> strNewPackageID = ""<br /> strNewCollectionsID = ""<br /> <br />Next<br />WScript.Echo "Done"<br /> <br /> <br />Function CollectionIDToName(CollectionID)<br />Dim AllCollections, objCollection<br /><br />Set AllCollections = objSourceWMIService.ExecQuery("SELECT * FROM SMS_Collection WHERE CollectionID='" &CollectionID &"'") <br />For Each objCollection In AllCollections<br /> CollectionIDToName = objCollection.Name<br />Next<br />End Function<br /><br />Function GetNewCollectionsID(CollectionName)<br />Dim AllCollections, objCollection<br /><br />Set AllCollections = objTargetWMIService.ExecQuery("SELECT * FROM SMS_Collection WHERE Name='" &CollectionName &"'") <br />For Each objCollection In AllCollections<br /> GetNewCollectionsID = objCollection.CollectionID<br />Next<br />End Function<br /> <br />Function PackageIDToName(PackageID)<br />Dim AllPackages, objPackage<br /><br />Set AllPackages = objSourceWMIService.ExecQuery("SELECT * FROM SMS_Package WHERE PackageID='" &PackageID &"'") <br />For Each objPackage In AllPackages<br /> PackageIDToName = objPackage.Name<br /> strCurPackageVersion = objPackage.Version<br /> strCurPackageManufacturer = objPackage.Manufacturer<br /> strCurpackageLanguage = objPackage.Language<br />Next<br />End Function<br /><br />Function GetNewPackageID(PackageName)<br />Dim AllPackages, objPackage<br /><br />'Make sure the Correct Package is choosen<br />Set AllPackages = objTargetWMIService.ExecQuery("SELECT * FROM SMS_Package WHERE Name='" &PackageName _<br /> &"' AND Version='" &strCurPackageVersion _ <br /> &"' AND Language='" &strCurpackageLanguage _ <br /> &"' AND Manufacturer='" &strCurPackageManufacturer &"'")<br /><br />For Each objPackage In AllPackages<br /> GetNewPackageID = objPackage.PackageID<br />Next<br />strCurPackageVersion = ""<br />strCurpackageLanguage = ""<br />strCurPackageManufacturer = ""<br />End Function<br /><br />Sub CreateContainer<br /><br />Dim AllSourceContainer, objSourceContainer<br />Dim objTargetContainer<br /><br /> Set AllSourceContainer = objSourceWMIService.ExecQuery("SELECT * FROM SMS_ObjectContainerNode WHERE ObjectType='3'")<br /> For Each objSourceContainer In AllSourceContainer<br /> <br /> objLogFile.WriteLine Now &" - Migrating Container " &objSourceContainer.Name<br /> Set objTargetContainer = objTargetWMIService.Get("SMS_ObjectContainerNode").SpawnInstance_()<br /> objTargetContainer.Name = objSourceContainer.Name<br /> objTargetContainer.ObjectType = objSourceContainer.ObjectType<br /> objTargetContainer.ParentContainerNodeID = objSourceContainer.ParentContainerNodeID<br /> On Error Resume Next<br /> objTargetContainer.Put_<br /> On Error GoTo 0<br /> <br /> Next<br /> <br />End Sub<br /> <br />Function MoveAdvertisementInToContainer(ContainerID, AdvertisementID)<br />Dim folderItem<br /><br />If ContainerID <> "" Then<br /><br /> objLogFile.WriteLine Now &" - Moving Advertisement " &AdvertisementID &" into Container " &ContainerID<br /> <br /> Set folderItem = objTargetWMIService.Get("SMS_ObjectContainerItem").SpawnInstance_()<br /> folderItem.InstanceKey = AdvertisementID<br /> folderItem.ObjectType = "3"<br /> folderItem.ContainerNodeID = ContainerID<br /> folderItem.Put_<br />Else<br /> objLogFile.WriteLine Now &" - No need to move the Advertisement " &AdvertisementID &", because it's listed in the root"<br />End If<br /> <br />End Function<br /><br />Function GetContainerID(AdvertisementID)<br />Dim AllContainers, objContainer<br /><br />Set AllContainers = objSourceWMIService.ExecQuery("SELECT * FROM SMS_ObjectContainerItem WHERE ObjectType='3' AND InstanceKey='" &AdvertisementID &"'") <br />For Each objContainer In AllContainers<br /> GetContainerID = objContainer.ContainerNodeID<br />Next<br /><br />End Function<br /><br />Function ContainerIDToName(ContainerID)<br />Dim AllContainers, objContainer<br /><br />Set AllContainers = objSourceWMIService.ExecQuery("SELECT * FROM SMS_ObjectContainerNode WHERE ObjectType='3' AND ContainerNodeID='" &ContainerID &"'") <br />For Each objContainer In AllContainers<br /> ContainerIDToName = objContainer.Name<br />Next<br /><br />End Function<br /><br />Function GetNewContainerID(ContainerName)<br />Dim AllSourceContainer, objSourceContainer<br /> <br />Set AllSourceContainer = objTargetWMIService.ExecQuery("SELECT * FROM SMS_ObjectContainerNode WHERE ObjectType='3' and Name = '" &ContainerName &"'")<br /><br />For Each objSourceContainer In AllSourceContainer<br /> GetNewContainerID = objSourceContainer.ContainerNodeID<br />Next<br />End Function<br /></pre>merowingerhttp://www.blogger.com/profile/05679656055137095951noreply@blogger.com0tag:blogger.com,1999:blog-8996856623096968372.post-91233112266275518842010-08-20T16:38:00.005+02:002010-08-20T17:01:53.310+02:00vbScript - Migrate Packages from SMS to SCCMThis script will migrate all packages from on site sms/sccm to another one<br /><strong>Be careful: Never run the script in your production until you've tested it!!!</strong><br /><pre class="vb" name="code"><br />'Option Explicit<br />On Error Resume Next<br />Dim strSourceServer : strSourceServer = "SMSServer"<br />Dim strTargetServer : strTargetServer = "SCCMServer"<br />Dim strSourceSiteCode : strSourceSiteCode = "000"<br />Dim strTargetSiteCode : strTargetSiteCode = "000"<br />Dim strNewSourcePath : strNewSourcePath = "SCCMServer"<br />Dim strOldSourcePath : strOldSourcePath = "SMSServer"<br />Dim objSourceWMIService, objTargetWMIService<br />Dim objPackage, AllPackages<br />Dim strContainerID, strContainerName<br />Dim bolScheduleAvailable : bolScheduleAvailable = False<br />Dim Token, schedule, schedtype<br />Dim strPkgManufacturer, strPkgName, strPkgVersion, strPkgLanguage, strPkgDescription, strPkgSource, strPkgSourceFlag<br />Dim strPkgExtendedData, strPkgExtendedDataSize, strPkgForcedDisconnectDelay, strPkgForcedDisconnectEnabled<br />Dim strPkgForcedDisconnectRetries, strPkgIcon, strPkgiconSize,strPkgIgnoreAddressSchedule,strPkgFlags, strPkgPriority<br />Dim strPkgMIFName, strPkgMIFPublisher, srtPktMIFVersion, strPkgMIFFilename, strPkgPreferedAddressType<br />Dim strPkgRefreshSourceFlag, strPkgShareName, strPkgShareType, strPkgSourceData, strPkgSourceVersion<br />Dim strNewPackageID<br />Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")<br />Dim objLogFile : Set objLogFile = objFSO.CreateTextFile("MigratePackages.log")<br /><br />Set objSourceWMIService = GetObject("winmgmts://" & strSourceServer & "\root\sms\site_" & strSourceSiteCode)<br />Set objTargetWMIService = GetObject("winmgmts://" & strTargetServer & "\root\sms\site_" & strTargetSiteCode)<br /><br />objLogFile.WriteLine Now &" - Migrating Packages from " &strSourceServer &" to " &strTargetServer<br /><br />'First create all Containers<br />Call CreateContainer<br /><br />'Loop trought all packages exsisting on the source server<br />Set AllPackages = objSourceWMIService.ExecQuery("SELECT * FROM SMS_Package") <br />For Each objPackage In AllPackages<br /> <br /> objLogFile.WriteLine Now &" - Migrating Package " &objPackage.PackageID<br /> <br /> 'Get Package settings<br /> strPkgName = objPackage.Name<br /> strPkgManufacturer = objPackage.Manufacturer<br /> strPkgVersion = objPackage.Version<br /> strPkgLanguage = objPackage.Language<br /> strPkgDescription = objPackage.Description<br /> strPkgSource = objPackage.PkgSourcePath<br /> strPkgSourceFlag = objPackage.PkgSourceFlag<br /> strPkgExtendedData = objPackage.extendedData<br /> strPkgExtendedDataSize = objPackage.extendedDataSize<br /> strPkgForcedDisconnectDelay = objPackage.forcedDisconnectDelay<br /> strPkgForcedDisconnectEnabled = objPackage.forcedDisconnectEnabled<br /> strPkgForcedDisconnectRetries = objPackage.forcedDisconnectNumretries<br /> strPkgIcon = objPackage.Icon<br /> strPkgiconSize = objPackage.IconSize<br /> strPkgIgnoreAddressSchedule = objPackage.IgnoreAddressSchedule<br /> strPkgMIFFilename = objPackage.MifFileName<br /> strPkgMIFName = objPackage.MifName<br /> strPkgMIFPublisher = objPackage.MifPublisher<br /> srtPktMIFVersion = objPackage.MifVersion<br /> strPkgFlags = objPackage.PKGFlags<br /> strPkgPreferedAddressType = objPackage.PreferredAddressType<br /> strPkgPriority = objPackage.Priority<br /> strPkgRefreshSourceFlag = objPackage.RefreshPkgSourceFlag<br /> strPkgShareName = objPackage.ShareName<br /> strPkgShareType = objPackage.ShareType<br /> strPkgSourceData = objPackage.SourceDate<br /> strPkgSourceVersion = objPackage.SourceVersion <br /> <br /> 'Get Package Refresh Schedule<br /> Set objPackage = objSourceWMIService.Get("SMS_Package='" & objPackage.PackageID & "'" ) <br /> On Error Resume Next<br /> Set schedule = objPackage.RefreshSchedule(0)<br /> On Error GoTo 0<br /> <br /> <br /> If err.number = 424 Then<br /> objLogFile.WriteLine Now &" - Package has no Schedule " &objPackage.PackageID<br /> ElseIf err.number <> 0 Then<br /> objLogFile.WriteLine Now &" - An Error (" &err.number &") occured while getting the Refresh Schedule from " &objPackage.PackageID<br /> Else<br /> On Error Resume Next<br /> schedtype=Schedule.Path_.Class<br /> <br /> Select Case (schedtype)<br /> Case "SMS_ST_RecurInterval"<br /> Set Token = objTargetWMIService.Get("SMS_ST_RecurInterval").SpawnInstance_()<br /> If schedule.MinuteSpan <> 0 Then Token.MinuteSpan = schedule.MinuteSpan<br /> If schedule.HourSpan <> 0 Then Token.HourSpan = schedule.HourSpan<br /> If schedule.DaySpan <> 0 Then Token.DaySpan = schedule.DaySpan<br /> If schedule.MinuteDuration <> 0 Then Token.MinuteDuration = schedule.MinuteDuration<br /> If schedule.HourDuration <> 0 Then Token.HourDuration = schedule.HourDuration<br /> If schedule.DayDuration <> 0 Then Token.DayDuration = schedule.DayDuration<br /> Token.StartTime = schedule.StartTime<br /> <br /> bolScheduleAvailable = True<br /> objLogFile.WriteLine Now &" - SMS_ST_RecurInterval Schedule available " &objPackage.PackageID<br /> <br /> Case "SMS_ST_RecurWeekly"<br /> Set Token = objTargetWMIService.Get("SMS_ST_RecurWeekly").SpawnInstance_()<br /> If schedule.MinuteDuration <> 0 Then Token.MinuteDuration = schedule.MinuteDuration<br /> If schedule.HourDuration <> 0 Then Token.HourDuration = schedule.HourDuration<br /> If schedule.DayDuration <> 0 Then Token.DayDuration = schedule.DayDuration<br /> If schedule.ForNumberOfWeeks <> 0 Then Token.ForNumberOfWeeks = schedule.ForNumberOfWeeks<br /> If schedule.Day <> 0 Then Token.Day = schedule.Day<br /> Token.StartTime = schedule.StartTime<br /> <br /> bolScheduleAvailable = True<br /> objLogFile.WriteLine Now &" - SMS_ST_RecurWeekly Schedule available " &objPackage.PackageID<br /> <br /> Case "SMS_ST_RecurMonthlyByDate"<br /> Set Token = objTargetWMIService.Get("SMS_ST_RecurMonthlyByDate").SpawnInstance_()<br /> If schedule.MinuteDuration <> 0 Then Token.MinuteDuration = schedule.MinuteDuration<br /> If schedule.HourDuration <> 0 Then Token.HourDuration = schedule.HourDuration<br /> If schedule.DayDuration <> 0 Then Token.DayDuration = schedule.DayDuration<br /> If schedule.ForNumberOfMonths <> 0 Then Token.ForNumberOfMonths = schedule.ForNumberOfMonths<br /> If schedule.MonthDay <> 0 Then Token.MonthDay = schedule.MonthDay<br /> Token.StartTime = schedule.StartTime<br /> <br /> bolScheduleAvailable = True<br /> objLogFile.WriteLine Now &" - SMS_ST_RecurMonthlyByDate Schedule available " &objPackage.PackageID<br /> <br /> Case "SMS_ST_RecurMonthlyByWeekday"<br /> Set Token = objTargetWMIService.Get("SMS_ST_RecurMonthlyByWeekday").SpawnInstance_()<br /> If schedule.MinuteDuration <> 0 Then Token.MinuteDuration = schedule.MinuteDuration<br /> If schedule.HourDuration <> 0 Then Token.HourDuration = schedule.HourDuration<br /> If schedule.DayDuration <> 0 Then Token.DayDuration = schedule.DayDuration<br /> If schedule.ForNumberOfMonths <> 0 Then Token.ForNumberOfMonths = schedule.ForNumberOfMonths<br /> If schedule.WeekOrder <> 0 Then Token.WeekOrder = schedule.WeekOrder<br /><br /> Token.StartTime = schedule.StartTime<br /> objLogFile.WriteLine Now &" - SMS_ST_RecurMonthlyByWeekday Schedule available " &objPackage.PackageID<br /> <br /> bolScheduleAvailable = True<br /><br /> Case "SMS_ST_NonRecurring"<br /> Set Token = objTargetWMIService.Get("SMS_ST_NonRecurring").SpawnInstance_()<br /> If schedule.MinuteDuration <> 0 Then Token.MinuteDuration = schedule.MinuteDuration<br /> If schedule.HourDuration <> 0 Then Token.HourDuration = schedule.HourDuration<br /> If schedule.DayDuration <> 0 Then Token.DayDuration = schedule.DayDuration<br /> Token.StartTime = schedule.StartTime<br /> <br /> bolScheduleAvailable = True<br /> objLogFile.WriteLine Now &" - SMS_ST_NonRecurring Schedule available " &objPackage.PackageID<br /> <br /> Case Else<br /> bolScheduleAvailable = False<br /> objLogFile.WriteLine Now &" - Unknown Schedule (skipping) " &objPackage.PackageID<br /> End Select<br /> <br /> End If<br /> <br /><br /> 'Get the container id of the package<br /> strContainerID = GetContainerID(objPackage.PackageID)<br /> <br /> 'Get the containers name of the package<br /> strContainerName = ContainerIDToName(strContainerID)<br /> objLogFile.WriteLine Now &" - Old Container of the Package is " &strContainerName<br /> <br /> 'Get the new containers id<br /> strNewContainerID = GetNewContainerID(strContainerName)<br /> objLogFile.WriteLine Now &" - New Container ID of the Package is " &strNewContainerID<br /><br /> 'Create the Package and get the new Package ID<br /> strNewPackageID = CreatePackage()<br /> <br /> Call CreatePrograms(objPackage.PackageID, strNewPackageID)<br /> <br /> 'Move the Package into the Container<br /> Call MovePackageInToContainer(strNewContainerID, strNewPackageID)<br /> <br /><br />Next<br /><br />WScript.Echo "Done"<br />objLogFile.WriteLine Now &" - Finish"<br /> <br /><br />Sub CreateContainer<br /><br />Dim AllSourceContainer, objSourceContainer<br />Dim objTargetContainer<br /><br /> Set AllSourceContainer = objSourceWMIService.ExecQuery("SELECT * FROM SMS_ObjectContainerNode WHERE ObjectType='2'")<br /> For Each objSourceContainer In AllSourceContainer<br /> <br /> objLogFile.WriteLine Now &" - Migrating Container " &objSourceContainer.Name<br /> Set objTargetContainer = objTargetWMIService.Get("SMS_ObjectContainerNode").SpawnInstance_()<br /> objTargetContainer.Name = objSourceContainer.Name<br /> objTargetContainer.ObjectType = objSourceContainer.ObjectType<br /> objTargetContainer.ParentContainerNodeID = objSourceContainer.ParentContainerNodeID<br /> On Error Resume Next<br /> objTargetContainer.Put_<br /> On Error GoTo 0<br /> <br /> Next<br /> <br />End Sub<br /><br />Function GetContainerID(PackageID)<br />Dim AllContainers, objContainer<br /><br />Set AllContainers = objSourceWMIService.ExecQuery("SELECT * FROM SMS_ObjectContainerItem WHERE ObjectType='2' AND InstanceKey='" &PackageID &"'") <br />For Each objContainer In AllContainers<br /> GetContainerID = objContainer.ContainerNodeID<br />Next<br /><br />End Function<br /><br />Function GetNewContainerID(ContainerName)<br />Dim AllSourceContainer, objSourceContainer<br /> <br />Set AllSourceContainer = objTargetWMIService.ExecQuery("SELECT * FROM SMS_ObjectContainerNode WHERE ObjectType='2' and Name = '" &ContainerName &"'")<br /><br />For Each objSourceContainer In AllSourceContainer<br /> GetNewContainerID = objSourceContainer.ContainerNodeID<br />Next<br /><br />End Function<br /><br />Function ContainerIDToName(ContainerID)<br />Dim AllContainers, objContainer<br /><br />Set AllContainers = objSourceWMIService.ExecQuery("SELECT * FROM SMS_ObjectContainerNode WHERE ObjectType='2' AND ContainerNodeID='" &ContainerID &"'") <br />For Each objContainer In AllContainers<br /> ContainerIDToName = objContainer.Name<br />Next<br /><br />End Function<br /><br />Function CreatePackage()<br />Dim newPackage, PKGSourcePath<br />Dim Package<br /><br /> objLogFile.WriteLine Now &" - Creating the Package " &strPkgManufacturer &" " &strPkgName &" " &strPkgVersion &" " &strPkgLanguage<br /><br /> Set newPackage = objTargetWMIService.Get("SMS_Package").SpawnInstance_<br /><br /> newPackage.Name = strPkgName<br /> newPackage.Description = strPkgDescription <br /> newPackage.extendedData = strPkgExtendedData<br /> newPackage.extendedDataSize = strPkgExtendedDataSize <br /> newPackage.forcedDisconnectDelay = strPkgForcedDisconnectDelay<br /> newPackage.forcedDisconnectEnabled = strPkgForcedDisconnectEnabled<br /> newPackage.forcedDisconnectNumretries = strPkgForcedDisconnectRetries<br /> newPackage.Icon = strPkgIcon<br /> newPackage.IconSize = strPkgiconSize<br /> newPackage.IgnoreAddressSchedule = strPkgIgnoreAddressSchedule<br /> newPackage.Language = strPkgLanguage <br /> newPackage.Manufacturer = strPkgManufacturer<br /> newPackage.MifFileName = strPkgMIFFilename<br /> newPackage.MifName = strPkgMIFName<br /> newPackage.MifPublisher = strPkgMIFPublisher<br /> newPackage.MifVersion = srtPktMIFVersion<br /> newPackage.PKGFlags = strPkgFlags<br /> newPackage.PkgSourceFlag = strPkgSourceFlag<br /> PKGSourcePath= Replace(Lcase(strPkgSource),Lcase(strOldSourcePath),Lcase(strNewSourcePath)) <br /> newPackage.PkgSourcePath = PKGSourcePath<br /> newPackage.PreferredAddressType = strPkgPreferedAddressType<br /> newPackage.Priority = strPkgPriority<br /> newPackage.RefreshPkgSourceFlag = strPkgRefreshSourceFlag<br /> newPackage.ShareName = strPkgShareName<br /> newPackage.ShareType = strPkgShareType<br /> newPackage.SourceDate = strPkgSourceData<br /> newPackage.SourceVersion= strPkgSourceVersion<br /> newPackage.Version = strPkgVersion <br /> <br /> 'Create Refresh Schedule for Package<br /> If bolScheduleAvailable = True Then<br /> newPackage.RefreshSchedule = Array(Token)<br /> End If<br /><br /> Path = newPackage.Put_<br /> <br /> 'Get automatically assigned package ID<br /> Set Package=objTargetWMIService.Get(Path)<br /> CreatePackage = Package.PackageID<br /><br /><br />'Clean Variables<br />On Error Resume Next<br />Set Token = Nothing<br />Set schedule = Nothing<br />Set newPackage = Nothing<br />bolScheduleAvailable = False<br />schedtype = ""<br /><br />End Function<br /><br />Function MovePackageInToContainer(ContainerID, PackageID)<br />Dim folderItem<br /><br />If ContainerID <> "" Then<br /><br /> objLogFile.WriteLine Now &" - Moving Package " &PackageID &" into Container " &ContainerID<br /> <br /> Set folderItem = objTargetWMIService.Get("SMS_ObjectContainerItem").SpawnInstance_()<br /> folderItem.InstanceKey = PackageID<br /> folderItem.ObjectType = "2"<br /> folderItem.ContainerNodeID = ContainerID<br /> folderItem.Put_<br />Else<br /> objLogFile.WriteLine Now &" - No need to move the Package " &PackageID &", because it's listed in the root"<br />End If<br /> <br />End Function<br /><br />Function CreatePrograms(OldPackageID, NewPackageID)<br />Dim AllPrograms, objProgram<br />Dim newProgram<br /><br />Set AllPrograms = objSourceWMIService.ExecQuery("SELECT * FROM SMS_Program WHERE PackageID='" &OldPackageID &"'")<br />If Not AllPrograms Is Nothing Then<br /> For Each objProgram In AllPrograms<br /> <br /> objLogFile.WriteLine Now &" - Creating the Program " &objProgram.ProgramName &" in Package " &OldPackageID<br /> <br /> Set newProgram = objTargetWMIService.Get("SMS_Program").SpawnInstance_() <br /> newProgram.CommandLine = objProgram.commandline<br /> newProgram.Comment = objProgram.comment<br /> newProgram.Description = objProgram.description<br /> newProgram.Deviceflags = objProgram.deviceflags<br /> newProgram.DiskSpaceReq = objProgram.DiskSpaceReq<br /> newProgram.DriveLetter = objProgram.DriveLetter<br /> newProgram.Duration = objProgram.Duration<br /> newProgram.extendedData = objProgram.extendedData<br /> newProgram.extendedDataSize = objProgram.extendedDataSize<br /> newProgram.icon = objProgram.icon<br /> newProgram.iconsize = objProgram.iconSize<br /> newProgram.MSIFilePath = objProgram.MSIFilePath<br /> newProgram.MSIProductID = objProgram.MSIProductID<br /> newProgram.PackageID = NewPackageID<br /> newProgram.ProgramFlags = objProgram.ProgramFlags<br /> newProgram.ProgramName = objProgram.ProgramName<br /> newProgram.RemovalKey = objProgram.RemovalKey<br /> newProgram.Requirements = objProgram.Requirements<br /> newProgram.SupportedOperatingSystems = objProgram.SupportedOperatingSystems<br /> newProgram.WorkingDirectory = objProgram.WorkingDirectory<br /> On Error Resume Next<br /> newProgram.Put_<br /> Next<br />End If<br /><br />End Function<br /></pre>merowingerhttp://www.blogger.com/profile/05679656055137095951noreply@blogger.com1