<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Hican.net</title>
	<atom:link href="http://www.hican.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hican.net</link>
	<description>IT Blog about all that is interesting.</description>
	<lastBuildDate>Sun, 05 Aug 2012 12:46:30 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>PowerShell: Rename Photos To Parent Folder Name</title>
		<link>http://www.hican.net/2012/03/15/powershell-rename-photos-to-parent-folder-name/</link>
		<comments>http://www.hican.net/2012/03/15/powershell-rename-photos-to-parent-folder-name/#comments</comments>
		<pubDate>Thu, 15 Mar 2012 13:35:52 +0000</pubDate>
		<dc:creator>hicannet</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Photos]]></category>
		<category><![CDATA[Rename]]></category>

		<guid isPermaLink="false">http://www.hican.net/?p=185</guid>
		<description><![CDATA[<p>A colleague of mine asked me if I could make a PowerShell script which would rename all of his jpg photos on his NAS. All photos need to be renamed to the (parent) folder they are in.<br /> <br /> I decided to write it in a function with multiple for loops (for readability) and to put in a jpg filter. If you want different files to be renamed, just change that filter (or extend it).<br /> <br /> The  <a href="http://www.hican.net/2012/03/15/powershell-rename-photos-to-parent-folder-name/" class="continueRead" >Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>A colleague of mine asked me if I could make a PowerShell script which would rename all of his jpg photos on his NAS. All photos need to be renamed to the (parent) folder they are in.<br />
<br />
I decided to write it in a function with multiple for loops (for readability) and to put in a jpg filter. If you want different files to be renamed, just change that filter (or extend it).<br />
<br />
The script can be used by putting it in the root of the folder where all the different photo folders are present and run it.<br />
For example if you have a folder called HolidayPhotos and in that folder multiple folders like Ibiza_2010, Florida_2012, etc. just put the script in the HolidayPhotos folder. Now run the script and all jpg files will be renamed to Ibiza_2010_1, Ibiza_2010_2, etc. and Flordia_2012_1, Florida_2012_2, etc.<br />
<br />
<strong>rename_photos.ps1</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
</pre></td><td class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008000;">#######################################################</span>
<span style="color: #008000;"># AUTHOR  : http://www.hican.net - @hicannet</span>
<span style="color: #008000;"># DATE    : 12-03-2012</span>
<span style="color: #008000;"># COMMENT : This script renames all .jpg files to the</span>
<span style="color: #008000;">#           name of the .jpg parent folder recursively,</span>
<span style="color: #008000;">#           extended with an increasing number.</span>
<span style="color: #008000;">#           Put the script in the root of the folders'</span>
<span style="color: #008000;">#           parent folder.</span>
<span style="color: #008000;">#######################################################</span>
<span style="color: #800080;">$path</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">Split-Path</span> <span style="color: #008080; font-style: italic;">-parent</span> <span style="color: #800080;">$MyInvocation</span>.MyCommand.Definition
&nbsp;
<span style="color: #0000FF;">Function</span> renamePhotos
<span style="color: #000000;">&#123;</span>
  <span style="color: #008000;"># Loop through all directories</span>
  <span style="color: #800080;">$dirs</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">dir</span> <span style="color: #800080;">$path</span> <span style="color: #008080; font-style: italic;">-Recurse</span> <span style="color: pink;">|</span> <span style="color: #0000FF;">Where</span> <span style="color: #000000;">&#123;</span> <span style="color: #000080;">$_</span>.psIsContainer <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$true</span> <span style="color: #000000;">&#125;</span>
  <span style="color: #0000FF;">Foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$dir</span> <span style="color: #0000FF;">In</span> <span style="color: #800080;">$dirs</span><span style="color: #000000;">&#41;</span>
  <span style="color: #000000;">&#123;</span>
    <span style="color: #800080;">$i</span> <span style="color: pink;">=</span> <span style="color: #804000;">1</span>
    <span style="color: #800080;">$newdir</span> <span style="color: pink;">=</span> <span style="color: #800080;">$dir</span>.name <span style="color: pink;">+</span> <span style="color: #800000;">&quot;_&quot;</span>
    <span style="color: #800080;">$images</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">Get-ChildItem</span> <span style="color: #008080; font-style: italic;">-Path</span> <span style="color: #800080;">$dir</span>.fullname <span style="color: pink;">-</span><span style="color: #0000FF;">Filter</span> <span style="color: pink;">*</span>.jpg <span style="color: #008080; font-style: italic;">-Recurse</span>
    <span style="color: #0000FF;">Foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$image</span> <span style="color: #0000FF;">In</span> <span style="color: #800080;">$images</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
      <span style="color: #800080;">$split</span>    <span style="color: pink;">=</span> <span style="color: #800080;">$image</span>.name.split<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;.jpg&quot;</span><span style="color: #000000;">&#41;</span>
      <span style="color: #800080;">$replace</span>  <span style="color: pink;">=</span> <span style="color: #800080;">$split</span><span style="color: #000000;">&#91;</span><span style="color: #804000;">0</span><span style="color: #000000;">&#93;</span> <span style="color: #FF0000;">-Replace</span> <span style="color: #800080;">$split</span><span style="color: #000000;">&#91;</span><span style="color: #804000;">0</span><span style="color: #000000;">&#93;</span><span style="color: pink;">,</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$newdir</span> <span style="color: pink;">+</span> <span style="color: #800080;">$i</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot;.jpg&quot;</span><span style="color: #000000;">&#41;</span>
&nbsp;
      <span style="color: #800080;">$image_string</span> <span style="color: pink;">=</span> <span style="color: #800080;">$image</span>.fullname.ToString<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.Trim<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
      <span style="color: #008080; font-weight: bold;">Rename-Item</span> <span style="color: #800000;">&quot;$image_string&quot;</span> <span style="color: #800000;">&quot;$replace&quot;</span>
      <span style="color: #800080;">$i</span><span style="color: pink;">++</span>
    <span style="color: #000000;">&#125;</span>
  <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #008000;"># RUN SCRIPT</span>
renamePhotos
<span style="color: #800000;">&quot;SCRIPT FINISHED&quot;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.hican.net/2012/03/15/powershell-rename-photos-to-parent-folder-name/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VBScript: Auto Create SCCM Collections</title>
		<link>http://www.hican.net/2012/03/06/vbscript-auto-create-sccm-collections/</link>
		<comments>http://www.hican.net/2012/03/06/vbscript-auto-create-sccm-collections/#comments</comments>
		<pubDate>Tue, 06 Mar 2012 10:16:30 +0000</pubDate>
		<dc:creator>hicannet</dc:creator>
				<category><![CDATA[VBScript]]></category>
		<category><![CDATA[Collections]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Product ID]]></category>
		<category><![CDATA[SCCM]]></category>

		<guid isPermaLink="false">http://www.hican.net/?p=178</guid>
		<description><![CDATA[<p>During a project it was required to do extensive and recurring cleanups of applications within that specific company. The cleanup was done in Active Directory by checking who wasn&#8217;t supposed to be a member of the application groups, but also through SCCM.<br /> <br /> For the SCCM cleanup 3 different Collections were used: Uninstall Query, Install Overview and a User Overview. These collections were created by hand and took quite some time, because a lot applications had to be  <a href="http://www.hican.net/2012/03/06/vbscript-auto-create-sccm-collections/" class="continueRead" >Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>During a project it was required to do extensive and recurring cleanups of applications within that specific company. The cleanup was done in Active Directory by checking who wasn&#8217;t supposed to be a member of the application groups, but also through SCCM.<br />
<br />
For the SCCM cleanup 3 different Collections were used: Uninstall Query, Install Overview and a User Overview. These collections were created by hand and took quite some time, because a lot applications had to be cleaned from time to time (mainly licensed applications).<br />
<br />
To easen things we decided to create a VBScript to auto create the uninstall collections, based on an input.csv.<br />
<br />
<strong>Note #1</strong>: Check an example of the input.csv at the bottom of the page.<br />
<strong>Note #2</strong>: This script also contains a logging / output function which outputs the actions to an output.csv.<br />
<br />
<strong>create_uninstall_collections.vbs</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbnet" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">'''''''''''''''''''''''''''''''''''''''''''''''''''''''</span>
<span style="color: #008080; font-style: italic;">' AUTHOR  : http://www.hican.net - @hicannet</span>
<span style="color: #008080; font-style: italic;">' DATE    : 06-03-2012</span>
<span style="color: #008080; font-style: italic;">' COMMENT : This script auto creates (removal) </span>
<span style="color: #008080; font-style: italic;">'           Collections based on an input csv file.</span>
<span style="color: #008080; font-style: italic;">'           Including Logging.</span>
<span style="color: #008080; font-style: italic;">'''''''''''''''''''''''''''''''''''''''''''''''''''''''</span>
<span style="color: #FF8000;">Option</span> Explicit
&nbsp;
<span style="color: #0600FF;">Const</span> <span style="color: #0600FF;">ForWriting</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">2</span>
<span style="color: #0600FF;">Const</span> <span style="color: #0600FF;">ForReading</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span>
<span style="color: #0600FF;">Const</span> <span style="color: #0600FF;">ForAppending</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">8</span>
&nbsp;
<span style="color: #0600FF;">Dim</span> objWshShell, objFso, objFile, objEnv, objLogFileFSO, objLogFile
<span style="color: #0600FF;">Dim</span> swbemLocator, swbemconnection, providerLoc, Location
<span style="color: #0600FF;">Dim</span> sConnect, sCurPath, sInputFile, sOutputFile, sNextLine, sSplit
<span style="color: #0600FF;">Dim</span> sParent, sAppName, sAll, sC2R, sInstalls, sUsers, sUsrName, sComment
<span style="color: #0600FF;">Dim</span> sColCheck, <span style="color: #008000;">Collection</span>, objCollection, newCollection, collectionPath
<span style="color: #0600FF;">Dim</span> sCollectionID, objContainerNode, Container, ParentFolderID, sResourceID
<span style="color: #0600FF;">Dim</span> newCollectionRelation, Token, objNewCollection, sColInput, sLimitID
<span style="color: #0600FF;">Dim</span> newQueryRule, newCollectionRule, sQueryC2R, sQueryInstalls, sQueryUsers
<span style="color: #0600FF;">Dim</span> sGroupName, sProductID
&nbsp;
sConnect        <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;&lt;SERVER_NAME&gt;&quot;</span>
sCurPath        <span style="color: #008000;">=</span> <span style="color: #0600FF;">left</span><span style="color: #000000;">&#40;</span>WScript.<span style="color: #0000FF;">ScriptFullName</span>,<span style="color: #000000;">&#40;</span><span style="color: #FF8000;">Len</span><span style="color: #000000;">&#40;</span>WScript.<span style="color: #0000FF;">ScriptFullName</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">-</span><span style="color: #000000;">&#40;</span><span style="color: #FF8000;">len</span><span style="color: #000000;">&#40;</span>WScript.<span style="color: #0000FF;">ScriptName</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
sInputFile      <span style="color: #008000;">=</span> sCurPath <span style="color: #008000;">+</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">92</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">+</span> <span style="color: #808080;">&quot;input.csv&quot;</span>
sOutputFile     <span style="color: #008000;">=</span> sCurPath <span style="color: #008000;">+</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">92</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">+</span> <span style="color: #808080;">&quot;output.csv&quot;</span>
&nbsp;
<span style="color: #FF8000;">Set</span> objWshShell <span style="color: #008000;">=</span> WScript.<span style="color: #0600FF;">CreateObject</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;WScript.Shell&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Set</span> objFso      <span style="color: #008000;">=</span> <span style="color: #0600FF;">CreateObject</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Scripting.FileSystemObject&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Set</span> objFile     <span style="color: #008000;">=</span> objFso.<span style="color: #0000FF;">OpenTextFile</span><span style="color: #000000;">&#40;</span>sInputFile, <span style="color: #0600FF;">ForReading</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Set</span> objEnv      <span style="color: #008000;">=</span> objWshShell.<span style="color: #0000FF;">Environment</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;process&quot;</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #008080; font-style: italic;">'Try to make a connection with the SCCM server.</span>
ConnectToSCCM
&nbsp;
OpenLogFile<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
WriteToLog <span style="color: #808080;">&quot;-------------------------------------------------------------------&quot;</span> <span style="color: #008000;">&amp;</span> VbCrLf
WriteToLog <span style="color: #808080;">&quot;START LOG  (&quot;</span> <span style="color: #008000;">+</span> <span style="color: #0600FF;">FormatDateTime</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Now</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>, vbGeneralDate<span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #0600FF;">Do</span> Until objFile.<span style="color: #0000FF;">AtEndOfStream</span>
  sNextLine  <span style="color: #008000;">=</span> objFile.<span style="color: #0000FF;">Readline</span>
  sSplit     <span style="color: #008000;">=</span> <span style="color: #0600FF;">Split</span><span style="color: #000000;">&#40;</span>sNextLine, <span style="color: #808080;">&quot;;&quot;</span><span style="color: #000000;">&#41;</span>
  sParent    <span style="color: #008000;">=</span> sSplit<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">0</span><span style="color: #000000;">&#41;</span>
  sAppName   <span style="color: #008000;">=</span> sSplit<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span>
  sProductID <span style="color: #008000;">=</span> sSplit<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">2</span><span style="color: #000000;">&#41;</span>
  sGroupName <span style="color: #008000;">=</span> sSplit<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">3</span><span style="color: #000000;">&#41;</span>
&nbsp;
  sAll       <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;All_&quot;</span> <span style="color: #008000;">+</span> sAppName
  sC2R       <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;C2R_&quot;</span> <span style="color: #008000;">+</span> sAppName
  sInstalls  <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Installs_&quot;</span> <span style="color: #008000;">+</span> sAppName
  sUsers     <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Users_&quot;</span> <span style="color: #008000;">+</span> sAppName
&nbsp;
  sQueryC2R      <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System INNER JOIN SMS_R_User ON SMS_R_System.LastLogonUserName = SMS_R_User.UserName WHERE (SMS_R_System.Name NOT IN (SELECT SMS_R_System.Name FROM SMS_R_User INNER JOIN SMS_R_System ON SMS_R_User.Username = SMS_R_System.LastLogonUserName WHERE (SMS_R_User.UserGroupName = 'Hican.net\\&quot;</span> <span style="color: #008000;">+</span> sGroupName <span style="color: #008000;">+</span> <span style="color: #808080;">&quot;'))) AND (SMS_R_System.Name IN (SELECT SMS_R_System.Name FROM SMS_R_System AS SMS_R_System INNER JOIN SMS_G_System_ADD_REMOVE_PROGRAMS ON SMS_R_System.ResourceID = SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceID WHERE (SMS_G_System_ADD_REMOVE_PROGRAMS.ProdID = '&quot;</span> <span style="color: #008000;">+</span> sProductID <span style="color: #008000;">+</span> <span style="color: #808080;">&quot;')))&quot;</span>
  sQueryInstalls <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_ADD_REMOVE_PROGRAMS on SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceID = SMS_R_System.ResourceId where SMS_G_System_ADD_REMOVE_PROGRAMS.ProdID = '&quot;</span> <span style="color: #008000;">+</span> sProductID <span style="color: #008000;">+</span> <span style="color: #808080;">&quot;'&quot;</span>
  sQueryUsers    <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;select SMS_R_USER.ResourceID,SMS_R_USER.ResourceType,SMS_R_USER.Name,SMS_R_USER.UniqueUserName,SMS_R_USER.WindowsNTDomain from SMS_R_USER WHERE (SMS_R_USER.USERGROUPNAME = 'Hican.net\\&quot;</span> <span style="color: #008000;">+</span> sGroupName <span style="color: #008000;">+</span> <span style="color: #808080;">&quot;')&quot;</span>
&nbsp;
  sUsrName  <span style="color: #008000;">=</span> objEnv<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;USERNAME&quot;</span><span style="color: #000000;">&#41;</span>
  sComment  <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Created via script by &quot;</span> <span style="color: #008000;">+</span> sUsrName <span style="color: #008000;">+</span> <span style="color: #808080;">&quot; on &quot;</span> <span style="color: #008000;">+</span> <span style="color: #0600FF;">Replace</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">FormatDateTime</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Now</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>, vbShortDate<span style="color: #000000;">&#41;</span>, <span style="color: #808080;">&quot;/&quot;</span>, <span style="color: #808080;">&quot;-&quot;</span><span style="color: #000000;">&#41;</span>
  sColCheck <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;&quot;</span>
&nbsp;
  <span style="color: #0600FF;">If</span> <span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Left</span><span style="color: #000000;">&#40;</span>sNextLine, <span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;*&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
    WriteToLog <span style="color: #808080;">&quot;LINE: &quot;</span> <span style="color: #008000;">&amp;</span> sNextLine <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot; DISABLED FOR PROCESSING...&quot;</span>
  <span style="color: #FF8000;">Else</span>
    CreateCollections<span style="color: #000000;">&#40;</span>sAll<span style="color: #000000;">&#41;</span>
    CreateCollections<span style="color: #000000;">&#40;</span>sC2R<span style="color: #000000;">&#41;</span>
    CreateCollections<span style="color: #000000;">&#40;</span>sInstalls<span style="color: #000000;">&#41;</span>
    CreateCollections<span style="color: #000000;">&#40;</span>sUsers<span style="color: #000000;">&#41;</span>
  <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
<span style="color: #0600FF;">Loop</span>
&nbsp;
objFile.<span style="color: #0600FF;">Close</span>
&nbsp;
WriteToLog <span style="color: #808080;">&quot;-------------------------------------------------------------------&quot;</span> <span style="color: #008000;">&amp;</span> VbCrLf
CloseLogFile<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
Wscript.<span style="color: #0000FF;">Echo</span> <span style="color: #808080;">&quot;Finished creating the Collections!&quot;</span>
Wscript.<span style="color: #0000FF;">Quit</span>
&nbsp;
<span style="color: #008080; font-style: italic;">'''''''''''''''''''''''''''''</span>
<span style="color: #008080; font-style: italic;">'         FUNCTIONS         '</span>
<span style="color: #008080; font-style: italic;">'''''''''''''''''''''''''''''</span>
<span style="color: #0600FF;">Function</span> ConnectToSCCM
<span style="color: #FF8000;">On</span> <span style="color: #FF8000;">Error</span> <span style="color: #FF8000;">Resume</span> <span style="color: #FF8000;">Next</span>
<span style="color: #FF8000;">Set</span> swbemLocator <span style="color: #008000;">=</span> <span style="color: #0600FF;">CreateObject</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;WbemScripting.SWbemLocator&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Set</span> swbemconnection <span style="color: #008000;">=</span> swbemLocator.<span style="color: #0000FF;">ConnectServer</span><span style="color: #000000;">&#40;</span>sConnect, <span style="color: #808080;">&quot;root\sms&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Set</span> providerLoc <span style="color: #008000;">=</span> swbemconnection.<span style="color: #0000FF;">InstancesOf</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;SMS_ProviderLocation&quot;</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #FF8000;">For</span> <span style="color: #0600FF;">Each</span> Location In providerLoc
  <span style="color: #0600FF;">If</span> location.<span style="color: #0000FF;">ProviderForLocalSite</span> <span style="color: #008000;">=</span> <span style="color: #0600FF;">True</span> <span style="color: #FF8000;">Then</span>
    <span style="color: #FF8000;">Set</span> swbemconnection <span style="color: #008000;">=</span> swbemLocator.<span style="color: #0000FF;">ConnectServer</span><span style="color: #000000;">&#40;</span>Location.<span style="color: #0000FF;">Machine</span>, <span style="color: #808080;">&quot;root\sms\site_&quot;</span> <span style="color: #008000;">+</span> Location.<span style="color: #0000FF;">SiteCode</span><span style="color: #000000;">&#41;</span>
    <span style="color: #0600FF;">Exit</span> <span style="color: #FF8000;">For</span>
  <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
<span style="color: #FF8000;">Next</span>
<span style="color: #0600FF;">If</span> <span style="color: #008000;">Err</span>.<span style="color: #0000FF;">Number</span> &lt;&gt; <span style="color: #FF0000;">0</span> <span style="color: #FF8000;">Then</span>
  Wscript.<span style="color: #0000FF;">echo</span> <span style="color: #808080;">&quot;Unable to connect to the SCCM provider. &quot;</span> <span style="color: #008000;">&amp;</span> _
               <span style="color: #808080;">&quot;Check the connection and / or the settings in the script!&quot;</span> <span style="color: #008000;">&amp;</span> _
               <span style="color: #808080;">&quot;The script will be stopped now.&quot;</span>
  WScript.<span style="color: #0000FF;">Quit</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
<span style="color: #FF8000;">On</span> <span style="color: #FF8000;">Error</span> GoTo <span style="color: #FF0000;">0</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span>
&nbsp;
<span style="color: #0600FF;">Sub</span> OpenLogFile<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>  	
<span style="color: #FF8000;">Set</span> objLogFileFSO <span style="color: #008000;">=</span> <span style="color: #0600FF;">CreateObject</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Scripting.FileSystemObject&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #0600FF;">If</span> objLogFileFSO.<span style="color: #0000FF;">FileExists</span><span style="color: #000000;">&#40;</span>sOutputFile<span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
  <span style="color: #FF8000;">Set</span> objLogFile <span style="color: #008000;">=</span> objLogFileFSO.<span style="color: #0000FF;">OpenTextFile</span><span style="color: #000000;">&#40;</span>sOutputFile, <span style="color: #0600FF;">ForAppending</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Else</span>
  <span style="color: #FF8000;">Set</span> objLogFile <span style="color: #008000;">=</span> objLogFileFSO.<span style="color: #0000FF;">CreateTextFile</span><span style="color: #000000;">&#40;</span>sOutputFile<span style="color: #000000;">&#41;</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>	
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span>
&nbsp;
<span style="color: #0600FF;">Sub</span> CloseLogFile<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
objLogFile.<span style="color: #0600FF;">Close</span>	
<span style="color: #FF8000;">Set</span> objLogfileFSO <span style="color: #008000;">=</span> <span style="color: #FF8000;">Nothing</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span>
&nbsp;
<span style="color: #0600FF;">Function</span> WriteToLog<span style="color: #000000;">&#40;</span>sLogMessage<span style="color: #000000;">&#41;</span>
  objLogFile.<span style="color: #0000FF;">WriteLine</span><span style="color: #000000;">&#40;</span>sLogMessage<span style="color: #000000;">&#41;</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span>
&nbsp;
<span style="color: #0600FF;">Function</span> ConvertToWMIdate<span style="color: #000000;">&#40;</span>sDate<span style="color: #000000;">&#41;</span>
<span style="color: #008080; font-style: italic;">'Attempts to convert the date into a WMI date-time!</span>
<span style="color: #0600FF;">Dim</span> sYear, sMonth, sDay, sHour, sMinute
&nbsp;
sYear <span style="color: #008000;">=</span> <span style="color: #0600FF;">year</span><span style="color: #000000;">&#40;</span>sDate<span style="color: #000000;">&#41;</span>
sMonth <span style="color: #008000;">=</span> <span style="color: #0600FF;">month</span><span style="color: #000000;">&#40;</span>sDate<span style="color: #000000;">&#41;</span>
sDay <span style="color: #008000;">=</span> <span style="color: #0600FF;">day</span><span style="color: #000000;">&#40;</span>sDate<span style="color: #000000;">&#41;</span>
sHour <span style="color: #008000;">=</span> <span style="color: #0600FF;">hour</span><span style="color: #000000;">&#40;</span>sDate<span style="color: #000000;">&#41;</span>
sMinute <span style="color: #008000;">=</span> <span style="color: #0600FF;">minute</span><span style="color: #000000;">&#40;</span>sDate<span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #0600FF;">If</span> <span style="color: #FF8000;">len</span><span style="color: #000000;">&#40;</span>sMonth<span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span> <span style="color: #FF8000;">Then</span>
  sMonth <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;0&quot;</span> <span style="color: #008000;">&amp;</span> sMonth
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
<span style="color: #0600FF;">If</span> <span style="color: #FF8000;">len</span><span style="color: #000000;">&#40;</span>sDay<span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span> <span style="color: #FF8000;">Then</span>
  sDay <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;0&quot;</span> <span style="color: #008000;">&amp;</span> sDay
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
<span style="color: #0600FF;">If</span> <span style="color: #FF8000;">len</span><span style="color: #000000;">&#40;</span>sHour<span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span> <span style="color: #FF8000;">Then</span>
  sHour <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;0&quot;</span> <span style="color: #008000;">&amp;</span> sHour
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
<span style="color: #0600FF;">If</span> <span style="color: #FF8000;">len</span><span style="color: #000000;">&#40;</span>sMinute<span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span> <span style="color: #FF8000;">Then</span>
  sMinute <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;0&quot;</span> <span style="color: #008000;">&amp;</span> sMinute
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
&nbsp;
ConvertToWMIdate <span style="color: #008000;">=</span> sYear <span style="color: #008000;">&amp;</span> sMonth <span style="color: #008000;">&amp;</span> sDay <span style="color: #008000;">&amp;</span> sHour <span style="color: #008000;">&amp;</span> sMinute <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;00.000000+***&quot;</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span>
&nbsp;
&nbsp;
<span style="color: #0600FF;">Function</span> CreateCollections<span style="color: #000000;">&#40;</span>sColInput<span style="color: #000000;">&#41;</span>
<span style="color: #008080; font-style: italic;">'Attempts to check if the collection already exists. If it does, </span>
<span style="color: #008080; font-style: italic;">'the script will skip this creation!</span>
<span style="color: #FF8000;">Set</span> <span style="color: #008000;">Collection</span> <span style="color: #008000;">=</span> swbemconnection.<span style="color: #0000FF;">ExecQuery</span> <span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;select * from SMS_Collection where Name='&quot;</span> <span style="color: #008000;">&amp;</span> sParent <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;'&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">For</span> <span style="color: #0600FF;">Each</span> objCollection In <span style="color: #008000;">Collection</span>
  sColCheck <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;This collection exists with the collection ID of: &quot;</span> <span style="color: #008000;">&amp;</span> objCollection.<span style="color: #0000FF;">CollectionID</span>
<span style="color: #FF8000;">Next</span>
&nbsp;
<span style="color: #0600FF;">If</span> sColCheck <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;&quot;</span> <span style="color: #FF8000;">Then</span>
  WScript.<span style="color: #0000FF;">Echo</span> <span style="color: #808080;">&quot;ParentFolder &quot;</span> <span style="color: #008000;">+</span> sParent <span style="color: #008000;">+</span> <span style="color: #808080;">&quot; is not present in Collections - &quot;</span> <span style="color: #008000;">&amp;</span> _
               <span style="color: #808080;">&quot;Management Collections - Special Collections - SMS Cleanup &quot;</span> <span style="color: #008000;">&amp;</span> _ 
               <span style="color: #808080;">&quot;, please create that folder first. The script will be stopped now.&quot;</span>
  WScript.<span style="color: #0000FF;">Quit</span>
<span style="color: #FF8000;">Else</span>
  <span style="color: #008080; font-style: italic;">'Attempts to create the new collections.</span>
  <span style="color: #FF8000;">Set</span> newCollection <span style="color: #008000;">=</span> swbemconnection.<span style="color: #FF8000;">Get</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;SMS_Collection&quot;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">SpawnInstance_</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
&nbsp;
  newCollection.<span style="color: #0000FF;">Name</span> <span style="color: #008000;">=</span> sColInput
  newCollection.<span style="color: #0000FF;">OwnedByThisSite</span> <span style="color: #008000;">=</span> <span style="color: #0600FF;">True</span>
  newCollection.<span style="color: #0000FF;">Comment</span> <span style="color: #008000;">=</span> sComment
  <span style="color: #FF8000;">Set</span> collectionPath <span style="color: #008000;">=</span> newCollection.<span style="color: #0000FF;">Put_</span>
&nbsp;
  <span style="color: #008080; font-style: italic;">'Attempts to obtain the collection ID of the </span>
  <span style="color: #008080; font-style: italic;">'newly created collection!</span>
  <span style="color: #FF8000;">Set</span> <span style="color: #008000;">Collection</span> <span style="color: #008000;">=</span> swbemconnection.<span style="color: #0000FF;">ExecQuery</span> <span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;select * from SMS_Collection where Name='&quot;</span> <span style="color: #008000;">&amp;</span> sColInput <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;'&quot;</span><span style="color: #000000;">&#41;</span>
  <span style="color: #FF8000;">For</span> <span style="color: #0600FF;">Each</span> objCollection in <span style="color: #008000;">Collection</span>
    sCollectionID <span style="color: #008000;">=</span> objCollection.<span style="color: #0000FF;">CollectionID</span>
  <span style="color: #FF8000;">Next</span>
&nbsp;
  <span style="color: #0600FF;">If</span> sCollectionID <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;&quot;</span> <span style="color: #FF8000;">Then</span>
    WScript.<span style="color: #0000FF;">Echo</span> <span style="color: #808080;">&quot;Unable to obtain a collection ID for the newly created collection.&quot;</span>
    WScript.<span style="color: #0000FF;">Quit</span>
  <span style="color: #FF8000;">Else</span>
    <span style="color: #008080; font-style: italic;">'WScript.Echo sCollectionID</span>
  <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
&nbsp;
  <span style="color: #0600FF;">If</span> sColInput <span style="color: #008000;">=</span> sAll <span style="color: #FF8000;">Then</span>
    <span style="color: #FF8000;">Set</span> objContainerNode <span style="color: #008000;">=</span> swbemconnection.<span style="color: #0000FF;">ExecQuery</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;select * from SMS_Collection where Name='&quot;</span> <span style="color: #008000;">&amp;</span> sParent <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;'&quot;</span><span style="color: #000000;">&#41;</span>
  <span style="color: #FF8000;">Else</span>
    <span style="color: #FF8000;">Set</span> objContainerNode <span style="color: #008000;">=</span> swbemconnection.<span style="color: #0000FF;">ExecQuery</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;select * from SMS_Collection where Name='&quot;</span> <span style="color: #008000;">&amp;</span> sAll <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;'&quot;</span><span style="color: #000000;">&#41;</span>
  <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
&nbsp;
  <span style="color: #008080; font-style: italic;">'ParentFolderID = &quot;&quot;</span>
  <span style="color: #FF8000;">For</span> <span style="color: #0600FF;">Each</span> Container In objContainerNode
    <span style="color: #0600FF;">If</span> Container.<span style="color: #0000FF;">name</span> <span style="color: #008000;">=</span> sParent <span style="color: #FF8000;">Then</span>
      ParentFolderID <span style="color: #008000;">=</span> Container.<span style="color: #0000FF;">CollectionID</span>
    <span style="color: #FF8000;">Elseif</span> Container.<span style="color: #0000FF;">name</span> <span style="color: #008000;">=</span> sAll <span style="color: #FF8000;">Then</span>
      ParentFolderID <span style="color: #008000;">=</span> Container.<span style="color: #0000FF;">CollectionID</span>
    <span style="color: #FF8000;">Else</span>
      <span style="color: #008080; font-style: italic;">'WScript.Echo ParentFolderID</span>
    <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
  <span style="color: #FF8000;">Next</span>
&nbsp;
  <span style="color: #008080; font-style: italic;">'Attempts to move the newly created collection into the </span>
  <span style="color: #008080; font-style: italic;">'desired parent collection.</span>
  <span style="color: #FF8000;">Set</span> newCollectionRelation <span style="color: #008000;">=</span> swbemconnection.<span style="color: #FF8000;">Get</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;SMS_CollectToSubCollect&quot;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">SpawnInstance_</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
  newCollectionRelation.<span style="color: #0000FF;">parentCollectionID</span> <span style="color: #008000;">=</span> ParentFolderID
  newCollectionRelation.<span style="color: #0000FF;">subCollectionID</span> <span style="color: #008000;">=</span> sCollectionID
  newCollectionRelation.<span style="color: #0000FF;">Put_</span>
&nbsp;
  <span style="color: #008080; font-style: italic;">'Attempts to create and add the query rule group</span>
  <span style="color: #008080; font-style: italic;">'to the collection!</span>
  <span style="color: #0600FF;">If</span> sColInput <span style="color: #008000;">=</span> sC2R OR sColInput <span style="color: #008000;">=</span> sInstalls OR sColInput <span style="color: #008000;">=</span> sUsers <span style="color: #FF8000;">Then</span>
    <span style="color: #FF8000;">Set</span> <span style="color: #008000;">Collection</span> <span style="color: #008000;">=</span> swbemconnection.<span style="color: #0000FF;">ExecQuery</span> <span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;select * from SMS_Collection where Name='All Managed Workstations'&quot;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #FF8000;">For</span> <span style="color: #0600FF;">Each</span> objCollection in <span style="color: #008000;">Collection</span>
      sLimitID <span style="color: #008000;">=</span> objCollection.<span style="color: #0000FF;">CollectionID</span>
    <span style="color: #FF8000;">Next</span>
&nbsp;
    <span style="color: #FF8000;">Set</span> newQueryRule <span style="color: #008000;">=</span> swbemconnection.<span style="color: #FF8000;">Get</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;SMS_CollectionRuleQuery&quot;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">SpawnInstance_</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #0600FF;">If</span> sColInput <span style="color: #008000;">=</span> sC2R <span style="color: #FF8000;">Then</span>
      newQueryRule.<span style="color: #0000FF;">QueryExpression</span>     <span style="color: #008000;">=</span> sQueryC2R
      newQueryRule.<span style="color: #0000FF;">LimitToCollectionID</span> <span style="color: #008000;">=</span> sLimitID
    <span style="color: #FF8000;">Elseif</span> sColInput <span style="color: #008000;">=</span> sInstalls <span style="color: #FF8000;">Then</span>
      newQueryRule.<span style="color: #0000FF;">QueryExpression</span>     <span style="color: #008000;">=</span> sQueryInstalls
      newQueryRule.<span style="color: #0000FF;">LimitToCollectionID</span> <span style="color: #008000;">=</span> sLimitID
    <span style="color: #FF8000;">Elseif</span> sColInput <span style="color: #008000;">=</span> sUsers <span style="color: #FF8000;">Then</span>
      newQueryRule.<span style="color: #0000FF;">QueryExpression</span>     <span style="color: #008000;">=</span> sQueryUsers
    <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
    newQueryRule.<span style="color: #0000FF;">RuleName</span> <span style="color: #008000;">=</span> sColInput
&nbsp;
    <span style="color: #008080; font-style: italic;">'Add the new query rule to a variable.</span>
    <span style="color: #FF8000;">Set</span> newCollectionRule <span style="color: #008000;">=</span> newQueryRule
    <span style="color: #008080; font-style: italic;">'Get the collection.</span>
    <span style="color: #FF8000;">Set</span> newCollection <span style="color: #008000;">=</span> swbemconnection.<span style="color: #FF8000;">Get</span><span style="color: #000000;">&#40;</span>collectionPath.<span style="color: #0000FF;">RelPath</span><span style="color: #000000;">&#41;</span>
    <span style="color: #008080; font-style: italic;">'Add the rules to the collection.</span>
    newCollection.<span style="color: #0000FF;">AddMembershipRule</span> newCollectionRule
    newCollection.<span style="color: #0000FF;">RequestRefresh</span> <span style="color: #0600FF;">False</span> 
  <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
&nbsp;
  <span style="color: #008080; font-style: italic;">'Attempts to set the membership update schedule on the </span>
  <span style="color: #008080; font-style: italic;">'collection (weekly recurrance)!</span>
  <span style="color: #FF8000;">Set</span> Token <span style="color: #008000;">=</span> swbemconnection.<span style="color: #FF8000;">Get</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;SMS_ST_RecurWeekly&quot;</span><span style="color: #000000;">&#41;</span>
  Token.<span style="color: #0000FF;">StartTime</span> <span style="color: #008000;">=</span> ConvertToWMIdate<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Now</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
&nbsp;
  <span style="color: #FF8000;">Set</span> objNewCollection <span style="color: #008000;">=</span> swbemconnection.<span style="color: #FF8000;">Get</span> <span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;SMS_Collection.CollectionID='&quot;</span> <span style="color: #008000;">&amp;</span> sCollectionID <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;'&quot;</span><span style="color: #000000;">&#41;</span>
  objNewCollection.<span style="color: #0000FF;">RefreshSchedule</span> <span style="color: #008000;">=</span> <span style="color: #0600FF;">Array</span><span style="color: #000000;">&#40;</span>Token<span style="color: #000000;">&#41;</span>
  objNewCollection.<span style="color: #0000FF;">RefreshType</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">2</span>
  objNewCollection.<span style="color: #0000FF;">Put_</span>
&nbsp;
  WriteToLog <span style="color: #808080;">&quot;CREATED: &quot;</span> <span style="color: #008000;">&amp;</span> sColInput
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span></pre></div></div>

<p>The input.csv has a format like this:<br />
&lt;PARENT_SCCM_FOLDER&gt;;&lt;APPLICATION_NAME&gt;;&lt;PRODUCT_ID&gt;;&lt;AD_GROUP_NAME&gt;<br />
<br />
<strong>Example input.csv</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbnet" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">'MicrosoftProducts;Microsoft_MapPoint_2007;{C82185E8-C27B-4EF4-2010-2222BC2C2B6D};GG.APP.MICROSOFT_MAPPOINT_2007</span>
<span style="color: #008080; font-style: italic;">'AdobeProducts;Adobe_Reader_X;{C82185E8-C27B-4EF4-2010-2222BC2C2B6D};GG.APP.ADOBE_READER_X</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.hican.net/2012/03/06/vbscript-auto-create-sccm-collections/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell: Count AD Users In Active Directory OU&#8217;s</title>
		<link>http://www.hican.net/2012/02/21/powershell-count-ad-users-in-active-directory-ous/</link>
		<comments>http://www.hican.net/2012/02/21/powershell-count-ad-users-in-active-directory-ous/#comments</comments>
		<pubDate>Tue, 21 Feb 2012 07:38:17 +0000</pubDate>
		<dc:creator>hicannet</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Organizational Unit]]></category>
		<category><![CDATA[OU]]></category>

		<guid isPermaLink="false">http://www.hican.net/?p=172</guid>
		<description><![CDATA[<p>For a large customer I had to count the amount of users in different kind of OU&#8217;s which were member of different kind of country OU&#8217;s. This was needed because the under laying OU&#8217;s were used as some sort of Profile Groups. Different people with different roles got added to these groups and we wanted to know how many users would get certain (licensed) applications when we would add an application group to these Profile Groups.<br /> <br /> Just  <a href="http://www.hican.net/2012/02/21/powershell-count-ad-users-in-active-directory-ous/" class="continueRead" >Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>For a large customer I had to count the amount of users in different kind of OU&#8217;s which were member of different kind of country OU&#8217;s. This was needed because the under laying OU&#8217;s were used as some sort of Profile Groups. Different people with different roles got added to these groups and we wanted to know how many users would get certain (licensed) applications when we would add an application group to these Profile Groups.<br />
<br />
Just change the variables in the script for logfile, country and of course the domain to make this work. You could also extend it by adding more variables or change the current ones. If you need help with this, feel free to <a href="http://www.hican.net/contact/" title="Contact | Hican.net | IT Blog about all that is interesting.">contact</a> me.<br />
<br />
<strong>Note #1:</strong> This script makes use of the Active Directory Module for PowerShell.<br />
<strong>Note #2:</strong> I made some extra variables like $usercount and $groupname for the readability and to make the reporting to a logfile easier. This could be written shortened, but I chose for more readability.<br />
<br />
<strong>count_ad_users_OU_array.ps1</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
</pre></td><td class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008000;">#######################################################</span>
<span style="color: #008000;"># AUTHOR  : http://www.hican.net - @hicannet</span>
<span style="color: #008000;"># DATE    : 21-02-2012</span>
<span style="color: #008000;"># COMMENT : This script retrieves and counts all users</span>
<span style="color: #008000;">#           from an array of OU's (countries in this</span>
<span style="color: #008000;">#           specific case) in Active Directory.</span>
Import<span style="color: pink;">-</span>Module ActiveDirectory
<span style="color: #008000;"># Logfile</span>
<span style="color: #800080;">$log</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;&lt;LOGFILE&gt;&quot;</span>
<span style="color: #008000;"># OU Array</span>
<span style="color: #800080;">$country</span>  <span style="color: pink;">=</span> <span style="color: #800000;">&quot;NL&quot;</span><span style="color: pink;">,</span><span style="color: #800000;">&quot;DE&quot;</span><span style="color: pink;">,</span><span style="color: #800000;">&quot;FR&quot;</span><span style="color: pink;">,</span><span style="color: #800000;">&quot;ES&quot;</span><span style="color: pink;">,</span><span style="color: #800000;">&quot;UK&quot;</span>
<span style="color: #800080;">$country</span> <span style="color: pink;">+=</span> <span style="color: #800000;">&quot;AT&quot;</span><span style="color: pink;">,</span><span style="color: #800000;">&quot;RU&quot;</span><span style="color: pink;">,</span><span style="color: #800000;">&quot;PT&quot;</span><span style="color: pink;">,</span><span style="color: #800000;">&quot;SE&quot;</span><span style="color: pink;">,</span><span style="color: #800000;">&quot;US&quot;</span>
<span style="color: #008000;"># FUNCTIONS</span>
<span style="color: #0000FF;">Function</span> getUsers
<span style="color: #000000;">&#123;</span>
  <span style="color: #008000;"># Loop through all countries in the $country array</span>
  <span style="color: #800000;">&quot;-- User Count for sub OU's in each country OU --&quot;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Out<span style="color: #FF0000;">-File</span></span> <span style="color: #800080;">$log</span>
  <span style="color: #0000FF;">Foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$cntry</span> <span style="color: #0000FF;">In</span> <span style="color: #800080;">$country</span><span style="color: #000000;">&#41;</span>
  <span style="color: #000000;">&#123;</span>
    <span style="color: #800000;">&quot;<span style="color: #008080; font-weight: bold;">`r</span><span style="color: #008080; font-weight: bold;">`n</span>&quot;</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot;-- Country - &quot;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$cntry</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Out<span style="color: #FF0000;">-File</span></span> <span style="color: #800080;">$log</span> <span style="color: #008080; font-style: italic;">-append</span>
    <span style="color: #800080;">$rbacs</span> <span style="color: pink;">=</span> Get<span style="color: pink;">-</span>ADGroup <span style="color: pink;">-</span><span style="color: #0000FF;">Filter</span> <span style="color: pink;">*</span> <span style="color: pink;">-</span>SearchBase <span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;OU=Profiles,OU=&quot;</span><span style="color: pink;">+</span><span style="color: #800080;">$cntry</span><span style="color: pink;">+</span><span style="color: #800000;">&quot;,OU=Groups,,DC=hican,DC=net&quot;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #0000FF;">Foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$rbac</span> <span style="color: #0000FF;">In</span> <span style="color: #800080;">$rbacs</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
      <span style="color: #0000FF;">If</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$rbac</span> <span style="color: pink;">|</span> <span style="color: pink;">%</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.Name<span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF0000;">-like</span> <span style="color: #800000;">&quot;$cntry-Management*&quot;</span> <span style="color: #FF0000;">-Or</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$rbac</span> <span style="color: pink;">|</span> <span style="color: pink;">%</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.Name<span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF0000;">-like</span> <span style="color: #800000;">&quot;$cntry-Sales*&quot;</span><span style="color: #000000;">&#41;</span>
      <span style="color: #000000;">&#123;</span>
        <span style="color: #800080;">$users</span>   <span style="color: pink;">=</span> Get<span style="color: pink;">-</span>ADGroupMember <span style="color: #800080;">$rbac</span> <span style="color: pink;">-</span>recursive <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Measure-Object</span>
        <span style="color: #800080;">$usercount</span> <span style="color: pink;">=</span> <span style="color: #800080;">$users</span> <span style="color: pink;">|</span> <span style="color: pink;">%</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.Count<span style="color: #000000;">&#125;</span>
        <span style="color: #800080;">$groupname</span> <span style="color: pink;">=</span> <span style="color: #800080;">$rbac</span> <span style="color: pink;">|</span> <span style="color: pink;">%</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.Name<span style="color: #000000;">&#125;</span>
        <span style="color: #800080;">$groupname</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot; (&quot;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$usercount</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot;)&quot;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Out<span style="color: #FF0000;">-File</span></span> <span style="color: #800080;">$log</span> <span style="color: #008080; font-style: italic;">-append</span>
        <span style="color: #800080;">$usersub</span>   <span style="color: pink;">+=</span> <span style="color: #800080;">$usercount</span>
        <span style="color: #800080;">$usertotal</span> <span style="color: pink;">+=</span> <span style="color: #800080;">$usercount</span>
      <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
    <span style="color: #800080;">$cntry</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot; User Count: &quot;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$usersub</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Out<span style="color: #FF0000;">-File</span></span> <span style="color: #800080;">$log</span> <span style="color: #008080; font-style: italic;">-append</span>
    <span style="color: #800080;">$usersub</span> <span style="color: pink;">=</span> <span style="color: #804000;">0</span>
  <span style="color: #000000;">&#125;</span>
  <span style="color: #800000;">&quot;<span style="color: #008080; font-weight: bold;">`r</span><span style="color: #008080; font-weight: bold;">`n</span>&quot;</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot;Total User Count: &quot;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$usertotal</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Out<span style="color: #FF0000;">-File</span></span> <span style="color: #800080;">$log</span> <span style="color: #008080; font-style: italic;">-append</span>
  <span style="color: #800000;">&quot;<span style="color: #008080; font-weight: bold;">`r</span><span style="color: #008080; font-weight: bold;">`n</span>&quot;</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot;--------------------------------------------&quot;</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot;<span style="color: #008080; font-weight: bold;">`r</span><span style="color: #008080; font-weight: bold;">`n</span>&quot;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Out<span style="color: #FF0000;">-File</span></span> <span style="color: #800080;">$log</span> <span style="color: #008080; font-style: italic;">-append</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #008000;"># RUN SCRIPT</span>
getUsers
<span style="color: #800000;">&quot;SCRIPT FINISHED&quot;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.hican.net/2012/02/21/powershell-count-ad-users-in-active-directory-ous/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VBScript: Adjust Program Attributes SCCM</title>
		<link>http://www.hican.net/2012/02/13/vbscript-adjust-program-attributes-sccm/</link>
		<comments>http://www.hican.net/2012/02/13/vbscript-adjust-program-attributes-sccm/#comments</comments>
		<pubDate>Mon, 13 Feb 2012 12:29:15 +0000</pubDate>
		<dc:creator>hicannet</dc:creator>
				<category><![CDATA[VBScript]]></category>
		<category><![CDATA[SCCM]]></category>

		<guid isPermaLink="false">http://www.hican.net/?p=157</guid>
		<description><![CDATA[<p>During our current project we needed to change some program attributes for <strong>all</strong> programs / applications. The amount of packages was well over 300 and the amount of programs was even more. Therefore I decided a script had to be made.<br /> <br /> This script loops through the SMS_Package table / view in SCCM (database) and adjusts all programs based on the input in the script. The script can also be adjusted that it skips certain groups / folders,  <a href="http://www.hican.net/2012/02/13/vbscript-adjust-program-attributes-sccm/" class="continueRead" >Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>During our current project we needed to change some program attributes for <strong>all</strong> programs / applications. The amount of packages was well over 300 and the amount of programs was even more. Therefore I decided a script had to be made.<br />
<br />
This script loops through the SMS_Package table / view in SCCM (database) and adjusts all programs based on the input in the script. The script can also be adjusted that it skips certain groups / folders, but that wasn&#8217;t needed for this project.<br />
<br />
<strong>Note</strong>: Check the subscript at the bottom of the page for the &#8216;skip folder&#8217; addition.<br />
<br />
<strong>adjust_program_attributes.vbs</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbnet" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">'''''''''''''''''''''''''''''''''''''''''''''''''''''''</span>
<span style="color: #008080; font-style: italic;">' AUTHOR  : http://www.hican.net - @hicannet</span>
<span style="color: #008080; font-style: italic;">' DATE    : 13-02-2012</span>
<span style="color: #008080; font-style: italic;">' COMMENT : This script adjusts the properties of</span>
<span style="color: #008080; font-style: italic;">'           Application / Package Programs in SCCM.</span>
<span style="color: #008080; font-style: italic;">'''''''''''''''''''''''''''''''''''''''''''''''''''''''</span>
<span style="color: #FF8000;">Option</span> Explicit
&nbsp;
<span style="color: #0600FF;">Dim</span> swbemLocator, swbemconnection, providerLoc, Location
<span style="color: #0600FF;">Dim</span> sConnect, PackageFound, ProgramFound, Packages, Package
<span style="color: #0600FF;">Dim</span> PackageID, Programs, Program, adjustProgram, programQuery
<span style="color: #0600FF;">Dim</span> RUN_ON_SPECIFIED_PLATFORMS, wbemFlagForwardOnly
<span style="color: #0600FF;">Dim</span> wbemFlagReturnImmediately, tempSupportedPlatform<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">3</span><span style="color: #000000;">&#41;</span>
<span style="color: #0600FF;">Dim</span> tempSupportedPlatformsArray, programPath, checkPlatformValue
<span style="color: #0600FF;">Dim</span> allProgramsForPackage
&nbsp;
sConnect <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;&lt;SERVERNAME&gt;&quot;</span>
&nbsp;
ConnectToSCCM
AdjustPrograms<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
&nbsp;
Wscript.<span style="color: #0000FF;">Echo</span> <span style="color: #808080;">&quot;Finished!&quot;</span>
Wscript.<span style="color: #0000FF;">Quit</span>
&nbsp;
<span style="color: #008080; font-style: italic;">'''''''''''''''''''''''''''''</span>
<span style="color: #008080; font-style: italic;">'         FUNCTIONS         '</span>
<span style="color: #008080; font-style: italic;">'''''''''''''''''''''''''''''</span>
<span style="color: #0600FF;">Function</span> ConnectToSCCM
<span style="color: #FF8000;">On</span> <span style="color: #FF8000;">Error</span> <span style="color: #FF8000;">Resume</span> <span style="color: #FF8000;">Next</span>
<span style="color: #FF8000;">Set</span> swbemLocator <span style="color: #008000;">=</span> <span style="color: #0600FF;">CreateObject</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;WbemScripting.SWbemLocator&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Set</span> swbemconnection <span style="color: #008000;">=</span> swbemLocator.<span style="color: #0000FF;">ConnectServer</span><span style="color: #000000;">&#40;</span>sConnect, <span style="color: #808080;">&quot;root\sms&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Set</span> providerLoc <span style="color: #008000;">=</span> swbemconnection.<span style="color: #0000FF;">InstancesOf</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;SMS_ProviderLocation&quot;</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #FF8000;">For</span> <span style="color: #0600FF;">Each</span> Location In providerLoc
  <span style="color: #0600FF;">If</span> location.<span style="color: #0000FF;">ProviderForLocalSite</span> <span style="color: #008000;">=</span> <span style="color: #0600FF;">True</span> <span style="color: #FF8000;">Then</span>
    <span style="color: #FF8000;">Set</span> swbemconnection <span style="color: #008000;">=</span> swbemLocator.<span style="color: #0000FF;">ConnectServer</span><span style="color: #000000;">&#40;</span>Location.<span style="color: #0000FF;">Machine</span>, <span style="color: #808080;">&quot;root\sms\site_&quot;</span> <span style="color: #008000;">+</span> Location.<span style="color: #0000FF;">SiteCode</span><span style="color: #000000;">&#41;</span>
    <span style="color: #0600FF;">Exit</span> <span style="color: #FF8000;">For</span>
  <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
<span style="color: #FF8000;">Next</span>
<span style="color: #0600FF;">If</span> <span style="color: #008000;">Err</span>.<span style="color: #0000FF;">Number</span> &lt;&gt; <span style="color: #FF0000;">0</span> <span style="color: #FF8000;">Then</span>
  Wscript.<span style="color: #0000FF;">echo</span> <span style="color: #808080;">&quot;Unable to connect to the SCCM provider. &quot;</span> <span style="color: #008000;">&amp;</span> _
               <span style="color: #808080;">&quot;Check the connection and / or the settings in the script!&quot;</span> <span style="color: #008000;">&amp;</span> _
               <span style="color: #808080;">&quot;The script will be stopped now.&quot;</span>
  WScript.<span style="color: #0000FF;">Quit</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
<span style="color: #FF8000;">On</span> <span style="color: #FF8000;">Error</span> GoTo <span style="color: #FF0000;">0</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span>
&nbsp;
<span style="color: #0600FF;">Function</span> AdjustPrograms<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Set</span> Packages <span style="color: #008000;">=</span> swbemconnection.<span style="color: #0000FF;">ExecQuery</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Select * From SMS_Package&quot;</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #FF8000;">For</span> <span style="color: #0600FF;">Each</span> Package In Packages
  PackageID <span style="color: #008000;">=</span> Package.<span style="color: #0000FF;">PackageID</span>
&nbsp;
  programQuery <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;SELECT * FROM SMS_Program WHERE PackageID='&quot;</span> <span style="color: #008000;">&amp;</span> PackageID <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;'&quot;</span>
  <span style="color: #FF8000;">Set</span> allProgramsForPackage <span style="color: #008000;">=</span> swbemconnection.<span style="color: #0000FF;">ExecQuery</span><span style="color: #000000;">&#40;</span>programQuery, , wbemFlagForwardOnly Or wbemFlagReturnImmediately<span style="color: #000000;">&#41;</span>
&nbsp;
  <span style="color: #FF8000;">For</span> <span style="color: #0600FF;">Each</span> program In allProgramsForPackage
&nbsp;
    <span style="color: #008080; font-style: italic;">'Set the flags according to your environment!</span>
    <span style="color: #008080; font-style: italic;">'program.ProgramFlags = &quot;&quot;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">'All x86 Windows XP</span>
    <span style="color: #FF8000;">Set</span> tempSupportedPlatform<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">0</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> swbemconnection.<span style="color: #FF8000;">Get</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;SMS_OS_Details&quot;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">SpawnInstance_</span>
        tempSupportedPlatform<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">0</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">MaxVersion</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;5.10.9999.9999&quot;</span>
        tempSupportedPlatform<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">0</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">MinVersion</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;5.10.0000.0&quot;</span>
        tempSupportedPlatform<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">0</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Name</span>       <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Win NT&quot;</span>
        tempSupportedPlatform<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">0</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Platform</span>   <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;I386&quot;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">'All x86 Windows 7</span>
    <span style="color: #FF8000;">Set</span> tempSupportedPlatform<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> swbemconnection.<span style="color: #FF8000;">Get</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;SMS_OS_Details&quot;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">SpawnInstance_</span>
        tempSupportedPlatform<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">MaxVersion</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;6.10.9999.9999&quot;</span>
        tempSupportedPlatform<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">MinVersion</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;6.10.0000.0&quot;</span>
        tempSupportedPlatform<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Name</span>       <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Win NT&quot;</span>
        tempSupportedPlatform<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Platform</span>   <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;I386&quot;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">'All x64 Windows XP Professional</span>
    <span style="color: #FF8000;">Set</span> tempSupportedPlatform<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">2</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> swbemconnection.<span style="color: #FF8000;">Get</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;SMS_OS_Details&quot;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">SpawnInstance_</span>
        tempSupportedPlatform<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">2</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">MaxVersion</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;5.20.9999.9999&quot;</span>
        tempSupportedPlatform<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">2</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">MinVersion</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;5.20.3790.0&quot;</span>
        tempSupportedPlatform<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">2</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Name</span>       <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Win NT&quot;</span>
        tempSupportedPlatform<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">2</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Platform</span>   <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;x64&quot;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">'All x64 Windows 7 Professional</span>
    <span style="color: #FF8000;">Set</span> tempSupportedPlatform<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">3</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> swbemconnection.<span style="color: #FF8000;">Get</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;SMS_OS_Details&quot;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">SpawnInstance_</span>
        tempSupportedPlatform<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">3</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">MaxVersion</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;6.10.9999.9999&quot;</span>
        tempSupportedPlatform<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">3</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">MinVersion</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;6.10.0000.0&quot;</span>
        tempSupportedPlatform<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">3</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Name</span>       <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Win NT&quot;</span>
        tempSupportedPlatform<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">3</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Platform</span>   <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;x64&quot;</span>
&nbsp;
    program.<span style="color: #0000FF;">SupportedOperatingSystems</span> <span style="color: #008000;">=</span> tempSupportedPlatform
    program.<span style="color: #0000FF;">Put_</span>                    
  <span style="color: #FF8000;">Next</span>
<span style="color: #FF8000;">Next</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span></pre></div></div>

<p>
To get this working with the above script, replace AdjustPrograms() with CheckFolder and as you can see, AdjustPrograms() will be called from within this new function.<br />
<br />
<strong>Addition to above script to skip certain folders in SCCM:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbnet" style="font-family:monospace;"><span style="color: #0600FF;">Dim</span> <span style="color: #008000;">Folders</span>, <span style="color: #008000;">Folder</span>, objConnectionDB
<span style="color: #0600FF;">Dim</span> objCommand, objRecordSet, objOutput
<span style="color: #0600FF;">Dim</span> sSplit, n, objQuery, sPackageName
&nbsp;
<span style="color: #FF8000;">Set</span> objRecordSet <span style="color: #008000;">=</span> <span style="color: #0600FF;">CreateObject</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;ADODB.Recordset&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Set</span> objConnectionDB <span style="color: #008000;">=</span> <span style="color: #0600FF;">CreateObject</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;ADODB.Connection&quot;</span><span style="color: #000000;">&#41;</span>
objConnectionDB.<span style="color: #0600FF;">Open</span> <span style="color: #808080;">&quot;Provider=SQLOLEDB;Data Source=&lt;SERVER&gt;;&quot;</span> <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;Trusted_Connection=Yes;Initial Catalog=&lt;SITE&gt;;&quot;</span>
&nbsp;
<span style="color: #0600FF;">Function</span> CheckFolder<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
&nbsp;
objQuery <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;SELECT * FROM vPackage &quot;</span> <span style="color: #008000;">&amp;</span> _
           <span style="color: #808080;">&quot;INNER JOIN vFolderMembers ON vPackage.PkgID = vFolderMembers.InstanceKey &quot;</span> <span style="color: #008000;">&amp;</span> _
           <span style="color: #808080;">&quot;INNER JOIN vSMS_Folders ON vFolderMembers.ContainerNodeID = vSMS_Folders.ContainerNodeID &quot;</span> <span style="color: #008000;">&amp;</span> _
           <span style="color: #808080;">&quot;WHERE vSMS_Folders.Name &lt;&gt; 'Server Tooling' &quot;</span> <span style="color: #008000;">&amp;</span> _
           <span style="color: #808080;">&quot;AND vSMS_Folders.Name &lt;&gt; 'Decommissioned'&quot;</span>
&nbsp;
objRecordSet.<span style="color: #0600FF;">Open</span> objQuery, objConnectionDB, adOpenStatic, adLockOptimistic
objRecordSet.<span style="color: #0000FF;">MoveFirst</span>
&nbsp;
<span style="color: #0600FF;">Do</span> Until objRecordSet.<span style="color: #0600FF;">EOF</span>
objOutput <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;&quot;</span>
<span style="color: #FF8000;">For</span> n <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span> <span style="color: #FF8000;">To</span> objRecordSet.<span style="color: #0000FF;">Fields</span>.<span style="color: #0000FF;">Count</span> <span style="color: #008000;">-</span> <span style="color: #FF0000;">1</span>
  objOutput <span style="color: #008000;">=</span> objOutput <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;;&quot;</span> <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Trim</span><span style="color: #000000;">&#40;</span>objRecordSet.<span style="color: #0000FF;">Fields</span><span style="color: #000000;">&#40;</span>n<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Next</span>
&nbsp;
sSplit <span style="color: #008000;">=</span> <span style="color: #0600FF;">Split</span><span style="color: #000000;">&#40;</span>objOutput, <span style="color: #808080;">&quot;;&quot;</span><span style="color: #000000;">&#41;</span>
sPackageName <span style="color: #008000;">=</span> sSplit<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">2</span><span style="color: #000000;">&#41;</span>
&nbsp;
AdjustPrograms<span style="color: #000000;">&#40;</span>sPackageName<span style="color: #000000;">&#41;</span>
&nbsp;
objRecordSet.<span style="color: #0000FF;">MoveNext</span>
<span style="color: #0600FF;">Loop</span>
&nbsp;
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.hican.net/2012/02/13/vbscript-adjust-program-attributes-sccm/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>VBScript: Auto Create SCCM Software Metering Rules</title>
		<link>http://www.hican.net/2012/01/30/vbscript-auto-create-sccm-software-metering-rules/</link>
		<comments>http://www.hican.net/2012/01/30/vbscript-auto-create-sccm-software-metering-rules/#comments</comments>
		<pubDate>Mon, 30 Jan 2012 12:12:42 +0000</pubDate>
		<dc:creator>hicannet</dc:creator>
				<category><![CDATA[VBScript]]></category>
		<category><![CDATA[SCCM]]></category>
		<category><![CDATA[SMS]]></category>
		<category><![CDATA[Software Metering]]></category>

		<guid isPermaLink="false">http://www.hican.net/?p=148</guid>
		<description><![CDATA[<p>During a previous project, we had a big bunch of Software Metering Rules defined in SMS and on paper. Since the import / migrate to SCCM not always seemed to work and we didn&#8217;t want to manually create all the rules, I decided to make a script for it.<br /> <br /> The script uses an input.csv file as, you guessed it, input. The format of this file can be seen beneath the script and can of course be adjusted  <a href="http://www.hican.net/2012/01/30/vbscript-auto-create-sccm-software-metering-rules/" class="continueRead" >Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>During a previous project, we had a big bunch of Software Metering Rules defined in SMS and on paper. Since the import / migrate to SCCM not always seemed to work and we didn&#8217;t want to manually create all the rules, I decided to make a script for it.<br />
<br />
The script uses an input.csv file as, you guessed it, input. The format of this file can be seen beneath the script and can of course be adjusted / extended.<br />
<br />
<strong>create_software_metering_rules.vbs</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbnet" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">'''''''''''''''''''''''''''''''''''''''''''''''''''''''</span>
<span style="color: #008080; font-style: italic;">' AUTHOR  : http://www.hican.net - @hicannet</span>
<span style="color: #008080; font-style: italic;">' DATE    : 30-01-2012</span>
<span style="color: #008080; font-style: italic;">' COMMENT : This script auto creates Software Metering </span>
<span style="color: #008080; font-style: italic;">'           Rules, based on an input file.</span>
<span style="color: #008080; font-style: italic;">'''''''''''''''''''''''''''''''''''''''''''''''''''''''</span>
<span style="color: #FF8000;">Option</span> Explicit
&nbsp;
<span style="color: #0600FF;">Const</span> <span style="color: #0600FF;">ForWriting</span>   <span style="color: #008000;">=</span> <span style="color: #FF0000;">2</span>
<span style="color: #0600FF;">Const</span> <span style="color: #0600FF;">ForReading</span>   <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span>
<span style="color: #0600FF;">Const</span> <span style="color: #0600FF;">ForAppending</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">8</span>
&nbsp;
<span style="color: #0600FF;">Dim</span> swbemLocator, swbemConnection, providerLoc, Location
<span style="color: #0600FF;">Dim</span> connectValue, returnValue, strInputFile
<span style="color: #0600FF;">Dim</span> objFso, objFile, strNextLine, strSplit
<span style="color: #0600FF;">Dim</span> checkExists, checkExist, strNameExists, newSWMRule
<span style="color: #0600FF;">Dim</span> newProductName, newFileName, newOriginalFileName, newFileVersion
<span style="color: #0600FF;">Dim</span> newLanguageID, newSiteCode, newApplyToChildSites
&nbsp;
strInputFile  <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;&lt;INPUTFILE&gt;&quot;</span>
connectValue  <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;&lt;SERVERNAME&gt;&quot;</span>
&nbsp;
WScript.<span style="color: #0000FF;">Echo</span> <span style="color: #808080;">&quot;Script Started...&quot;</span>
<span style="color: #008080; font-style: italic;">'***********************************'</span>
<span style="color: #008080; font-style: italic;">'* This is where the magic happens *'</span>
<span style="color: #008080; font-style: italic;">'***********************************'</span>
<span style="color: #FF8000;">On</span> <span style="color: #FF8000;">Error</span> <span style="color: #FF8000;">Resume</span> <span style="color: #FF8000;">Next</span>
<span style="color: #008000;">Err</span>.<span style="color: #0000FF;">Clear</span>
returnValue <span style="color: #008000;">=</span> ConnectToSCCM
<span style="color: #0600FF;">If</span> <span style="color: #008000;">Err</span>.<span style="color: #0000FF;">Number</span> &lt;&gt; <span style="color: #FF0000;">0</span> <span style="color: #FF8000;">Then</span>
  Wscript.<span style="color: #0000FF;">echo</span> <span style="color: #808080;">&quot;Unable to connect.&quot;</span>
<span style="color: #FF8000;">Else</span>
  CreateSWMRule<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
<span style="color: #008080; font-style: italic;">'***********************************'</span>
<span style="color: #008080; font-style: italic;">'***********************************'</span>
WScript.<span style="color: #0000FF;">Echo</span> <span style="color: #808080;">&quot;Script Finished..&quot;</span>
&nbsp;
<span style="color: #0600FF;">Function</span> ConnectToSCCM
<span style="color: #FF8000;">Set</span> swbemLocator <span style="color: #008000;">=</span> <span style="color: #0600FF;">CreateObject</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;WbemScripting.SWbemLocator&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Set</span> swbemConnection <span style="color: #008000;">=</span> swbemLocator.<span style="color: #0000FF;">ConnectServer</span><span style="color: #000000;">&#40;</span>connectValue, <span style="color: #808080;">&quot;root\sms&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Set</span> providerLoc <span style="color: #008000;">=</span> swbemConnection.<span style="color: #0000FF;">InstancesOf</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;SMS_ProviderLocation&quot;</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #FF8000;">For</span> <span style="color: #0600FF;">Each</span> Location In providerLoc
  <span style="color: #0600FF;">If</span> Location.<span style="color: #0000FF;">ProviderForLocalSite</span> <span style="color: #008000;">=</span> <span style="color: #0600FF;">True</span> <span style="color: #FF8000;">Then</span>
    <span style="color: #FF8000;">Set</span> swbemConnection <span style="color: #008000;">=</span> swbemLocator.<span style="color: #0000FF;">ConnectServer</span><span style="color: #000000;">&#40;</span>Location.<span style="color: #0000FF;">Machine</span>, <span style="color: #808080;">&quot;root\sms\site_&quot;</span> <span style="color: #008000;">+</span> Location.<span style="color: #0000FF;">SiteCode</span><span style="color: #000000;">&#41;</span>
    <span style="color: #0600FF;">Exit</span> <span style="color: #FF8000;">For</span>
  <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
<span style="color: #FF8000;">Next</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span>
&nbsp;
<span style="color: #0600FF;">Function</span> CreateSWMRule<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Set</span> objFso <span style="color: #008000;">=</span> <span style="color: #0600FF;">CreateObject</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Scripting.FileSystemObject&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Set</span> objFile <span style="color: #008000;">=</span> objFso.<span style="color: #0000FF;">OpenTextFile</span><span style="color: #000000;">&#40;</span>strInputFile, <span style="color: #0600FF;">ForReading</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #0600FF;">Do</span> Until objFile.<span style="color: #0000FF;">AtEndOfStream</span>
  strNextLine <span style="color: #008000;">=</span> objFile.<span style="color: #0000FF;">Readline</span>
  strSplit <span style="color: #008000;">=</span> <span style="color: #0600FF;">Split</span><span style="color: #000000;">&#40;</span>strNextLine, <span style="color: #808080;">&quot;;&quot;</span><span style="color: #000000;">&#41;</span>
&nbsp;
  newProductName       <span style="color: #008000;">=</span> strSplit<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">0</span><span style="color: #000000;">&#41;</span>
  newFileName          <span style="color: #008000;">=</span> strSplit<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span>
  newOriginalFileName  <span style="color: #008000;">=</span> strSplit<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">2</span><span style="color: #000000;">&#41;</span>
  newFileVersion       <span style="color: #008000;">=</span> strSplit<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">3</span><span style="color: #000000;">&#41;</span>
  newLanguageID        <span style="color: #008000;">=</span> strSplit<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">4</span><span style="color: #000000;">&#41;</span>
  newSiteCode          <span style="color: #008000;">=</span> strSplit<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">5</span><span style="color: #000000;">&#41;</span>
  newApplyToChildSites <span style="color: #008000;">=</span> strSplit<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">6</span><span style="color: #000000;">&#41;</span>
&nbsp;
  <span style="color: #0600FF;">If</span> <span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Left</span><span style="color: #000000;">&#40;</span>strNextLine, <span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;*&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
    WScript.<span style="color: #0000FF;">Echo</span> <span style="color: #808080;">&quot;DISABLED: &quot;</span> <span style="color: #008000;">&amp;</span> newProductName 
  <span style="color: #FF8000;">Else</span>
    <span style="color: #FF8000;">Set</span> checkExists <span style="color: #008000;">=</span> swbemConnection.<span style="color: #0000FF;">ExecQuery</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Select * From SMS_MeteredProductRule Where OriginalFileName='&quot;</span> <span style="color: #008000;">&amp;</span> newOriginalFileName <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;'&quot;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #FF8000;">For</span> <span style="color: #0600FF;">Each</span> checkExist In checkExists
      strNameExists <span style="color: #008000;">=</span> checkExist.<span style="color: #0000FF;">FileName</span>
    <span style="color: #FF8000;">Next</span>
    <span style="color: #0600FF;">If</span> strNameExists &lt;&gt; newOriginalFileName <span style="color: #FF8000;">Then</span>
      <span style="color: #008080; font-style: italic;">' Create the new MeteredProductRule object.</span>
      <span style="color: #FF8000;">Set</span> newSWMRule <span style="color: #008000;">=</span> swbemConnection.<span style="color: #FF8000;">Get</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;SMS_MeteredProductRule&quot;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">SpawnInstance_</span>
      <span style="color: #008080; font-style: italic;">' Populate the SMS_MeteredProductRule properties.</span>
      newSWMRule.<span style="color: #0000FF;">ProductName</span><span style="color: #008000;">=</span> newProductName
      newSWMRule.<span style="color: #0000FF;">FileName</span> <span style="color: #008000;">=</span> newFileName
      newSWMRule.<span style="color: #0000FF;">OriginalFileName</span> <span style="color: #008000;">=</span>  newOriginalFileName
      newSWMRule.<span style="color: #0000FF;">FileVersion</span> <span style="color: #008000;">=</span> newFileVersion
      newSWMRule.<span style="color: #0000FF;">LanguageID</span> <span style="color: #008000;">=</span> newLanguageID
      newSWMRule.<span style="color: #0000FF;">SiteCode</span> <span style="color: #008000;">=</span> newSiteCode
      newSWMRule.<span style="color: #0000FF;">ApplyToChildSites</span> <span style="color: #008000;">=</span> newApplyToChildSites
      <span style="color: #008080; font-style: italic;">' Save the new rule and properties.</span>
      newSWMRule.<span style="color: #0000FF;">Put_</span>
&nbsp;
      <span style="color: #008080; font-style: italic;">' Output new rule name.</span>
      WScript.<span style="color: #0000FF;">Echo</span> <span style="color: #808080;">&quot;CREATED: &quot;</span> <span style="color: #008000;">&amp;</span> newProductName
    <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
  <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
<span style="color: #0600FF;">Loop</span>
objFile.<span style="color: #0600FF;">Close</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span></pre></div></div>

<p>
In the Input CSV the following (general) structure was used (the values are example values).<br />
<br />
<strong>input.csv</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="vbnet" style="font-family:monospace;">All Adobe Reader;AcroRd32.<span style="color: #0000FF;">exe</span>;AcroRd32.<span style="color: #0000FF;">exe</span>;<span style="color: #008000;">*</span>;;HIC1;True
All Microsoft Project;WINPROJ.<span style="color: #0000FF;">exe</span>;WINPROJ.<span style="color: #0000FF;">exe</span>;<span style="color: #008000;">*</span>;;HIC1;True</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.hican.net/2012/01/30/vbscript-auto-create-sccm-software-metering-rules/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Miscellaneous: List Of Often Used Products And Their GUID&#8217;s</title>
		<link>http://www.hican.net/2012/01/23/miscellaneous-list-of-often-used-products-and-their-guids/</link>
		<comments>http://www.hican.net/2012/01/23/miscellaneous-list-of-often-used-products-and-their-guids/#comments</comments>
		<pubDate>Mon, 23 Jan 2012 07:03:00 +0000</pubDate>
		<dc:creator>hicannet</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[GUID]]></category>
		<category><![CDATA[Product Code]]></category>
		<category><![CDATA[Product ID]]></category>
		<category><![CDATA[Unattended]]></category>

		<guid isPermaLink="false">http://www.hican.net/?p=140</guid>
		<description><![CDATA[<p>In many projects I have been in, the migration of the Applications was one of the most important and complex tasks. We often encountered very old (legacy) applications, applications that had a hard time upgrading and old version, conflicting applications and more.</p> <p>It was more than often required to write some uninstall scripts which killed specific running processes / programs and then uninstall the previous version(s) of the application(s). Sometimes we had a hard time finding the right program, because  <a href="http://www.hican.net/2012/01/23/miscellaneous-list-of-often-used-products-and-their-guids/" class="continueRead" >Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>In many projects I have been in, the migration of the Applications was one of the most important and complex tasks. We often encountered very old (legacy) applications, applications that had a hard time upgrading and old version, conflicting applications and more.</p>
<p>It was more than often required to write some uninstall scripts which killed specific running processes / programs and then uninstall the previous version(s) of the application(s). Sometimes we had a hard time finding the right program, because of bad written program code, corrupted installations, etc.</p>
<p>To ease up this process a bit, I made a short overview of often / common used applications and their respective ProductCode (GUID), Version and Language. This list can be used to create uninstall strings, scripts or just as an informative reference <img src='http://www.hican.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><em>Product / GUID Overview:</em></p>
<p><strong>ADOBE READER</strong><br />
ProductName : Adobe Reader X<br />
ProductCode : {AC76BA86-7AD7-1033-7B44-AA0000000001}<br />
ProductVersion : 10.0.0<br />
Language : ENGLISH</p>
<p>ProductName : Adobe Reader X &#8211; Français<br />
ProductCode : {AC76BA86-7AD7-1036-7B44-AA0000000001}<br />
ProductVersion : 10.0.0<br />
Language : FRENCH</p>
<p>ProductName : Adobe Reader X &#8211; Deutsch<br />
ProductCode : {AC76BA86-7AD7-1031-7B44-AA0000000001}<br />
ProductVersion : 10.0.0<br />
Language : GERMAN</p>
<p>ProductName : Adobe Reader X &#8211; Italiano<br />
ProductCode : {AC76BA86-7AD7-1040-7B44-AA0000000001}<br />
ProductVersion : 10.0.0<br />
Language : ITALIAN</p>
<p>ProductName : Adobe Reader X &#8211; Japanese<br />
ProductCode : {AC76BA86-7AD7-1041-7B44-AA0000000001}<br />
ProductVersion : 10.0.0<br />
Language : JAPANESE</p>
<p>ProductName : Adobe Reader X &#8211; Español<br />
ProductCode : {AC76BA86-7AD7-1034-7B44-AA0000000001}<br />
ProductVersion : 10.0.0<br />
Language : SPANISH</p>
<p>ProductName : Adobe Reader X<br />
ProductCode : {AC76BA86-7AD7-1033-7B44-AA1000000001}<br />
ProductVersion : 10.1.0<br />
Language : ENGLISH</p>
<p>ProductName : Adobe Reader X &#8211; Français<br />
ProductCode : {AC76BA86-7AD7-1036-7B44-AA1000000001}<br />
ProductVersion : 10.1.0<br />
Language : FRENCH</p>
<p>ProductName : Adobe Reader X &#8211; Deutsch<br />
ProductCode : {AC76BA86-7AD7-1031-7B44-AA1000000001}<br />
ProductVersion : 10.1.0<br />
Language : GERMAN</p>
<p>ProductName : Adobe Reader X &#8211; Italiano<br />
ProductCode : {AC76BA86-7AD7-1040-7B44-AA1000000001}<br />
ProductVersion : 10.1.0<br />
Language : ITALIAN</p>
<p>ProductName : Adobe Reader X &#8211; Japanese<br />
ProductCode : {AC76BA86-7AD7-1041-7B44-AA1000000001}<br />
ProductVersion : 10.1.0<br />
Language : JAPANESE</p>
<p>ProductName : Adobe Reader X &#8211; Español<br />
ProductCode : {AC76BA86-7AD7-1034-7B44-AA1000000001}<br />
ProductVersion : 10.1.0<br />
Language : SPANISH</p>
<p>&nbsp;</p>
<p><strong>ADOBE ACROBAT</strong><br />
ProductName : Adobe Acrobat X Pro<br />
ProductCode : {AC76BA86-1040-7D70-7760-000000000005}<br />
ProductVersion : 10.0.0<br />
Language : ITALIAN, SPANISH, DUTCH, PORTUGESE</p>
<p>ProductName : Adobe Acrobat X Pro<br />
ProductCode : {AC76BA86-1033-F400-7760-000000000005}<br />
ProductVersion : 10.0.0<br />
Language : ENGLISH, FRENCH, GERMAN</p>
<p>&nbsp;</p>
<p><strong>ADOBE PHOTOSHOP ELEMENTS</strong><br />
ProductName : Adobe Photoshop Elements 1.0<br />
ProductCode : {EDC10357-5A31-4142-8629-0EA84FF0623B}<br />
ProductVersion : 1.0<br />
Language : GERMAN</p>
<p>ProductName : Adobe Photoshop Elements 6.0<br />
ProductCode : {F54AC413-D2C6-4A24-B324-370C223C6250}<br />
ProductVersion : 6.0<br />
Language : GERMAN</p>
<p>ProductName : Adobe Photoshop Elements 9<br />
ProductCode : {007F778D-F15C-4EAB-AE92-071D21FAF632}<br />
ProductVersion : 9.0<br />
Language : ENGLISH</p>
<p>&nbsp;</p>
<p><strong>ADOBE PHOTOSHOP</strong><br />
ProductName : Adobe Photoshop CS2<br />
ProductCame : {236BB7C4-4419-42FD-0407-1E257A25E34D}<br />
ProductVersion : 9.0<br />
Language : GERMAN</p>
<p>ProductName : Adobe Photoshop CS2<br />
ProductCame : {236BB7C4-4419-42FD-040C-1E257A25E34D}<br />
ProductVersion : 9.0<br />
Language : FRENCH</p>
<p>ProductName : Adobe Photoshop CS2<br />
ProductCame : {236BB7C4-4419-42FD-0409-1E257A25E34D}<br />
ProductVersion : 9.0<br />
Language : ENGLISH</p>
<p>ProductName : Adobe Photoshop CS5<br />
ProductCame : {7AA40E69-5BD9-44B1-9B73-4FCD194D507C}<br />
ProductVersion : 1.2.0000<br />
Language : FRENCH</p>
<p>ProductName : Adobe Photoshop CS5<br />
ProductCame : {9E5A78BE-4CD7-4C35-85F8-520B7DF6535B}<br />
ProductVersion : 1.2.0000<br />
Language : ENGLISH</p>
<p>&nbsp;</p>
<p><strong>MIRCOSOFT MAPPOINT</strong><br />
ProductName : Microsoft MapPoint Europe 2006<br />
ProductCame : {83ED1E80-A1B7-4256-BCF1-AC4A88151A6B}<br />
ProductVersion : 13.00.18.1200<br />
Language : ENGLISH</p>
<p>ProductName : Microsoft MapPoint Europe 2010<br />
ProductCame : {C82185E8-C27B-4EF4-2010-2222BC2C2B6D}<br />
ProductVersion : 17.0.22.1400<br />
Language : ENGLISH</p>
<p>&nbsp;</p>
<p><strong>MIRCOSOFT PROJECT</strong><br />
ProductName : Microsoft Office Project 2003 MUI<br />
ProductCame : {90B40407-6000-11D3-8CFE-0150048383C9}<br />
ProductVersion : 11.0.8173.0<br />
Language : GERMAN</p>
<p>ProductName : Microsoft Office Project 2003 MUI<br />
ProductCame : {90B40C0A-6000-11D3-8CFE-0150048383C9}<br />
ProductVersion : 11.0.8173.0<br />
Language : SPANISH</p>
<p>ProductName : Microsoft Office Project 2003 MUI<br />
ProductCame : {90B4040C-6000-11D3-8CFE-0150048383C9}<br />
ProductVersion : 11.0.8173.0<br />
Language : FRENCH</p>
<p>ProductName : Microsoft Office Project Std 2003<br />
ProductCame : {903A0409-6000-11D3-8CFE-0150048383C9}<br />
ProductVersion : 11.0.8173.0<br />
Language : ENGLISH</p>
<p>ProductName : Microsoft Office Project Pro 2003<br />
ProductCame : {903B0407-6000-11D3-8CFE-0150048383C9}<br />
ProductVersion : 11.0.8173.0<br />
Language : GERMAN</p>
<p>ProductName : Microsoft Office Project Pro 2003<br />
ProductCame : {903B0409-6000-11D3-8CFE-0150048383C9}<br />
ProductVersion : 11.0.7969.0<br />
Language : ENGLISH</p>
<p>&nbsp;</p>
<p><strong>MIRCOSOFT VISIO</strong><br />
ProductName : Microsoft Office Visio Std 2003<br />
ProductCame : {90530409-6000-11D3-8CFE-0150048383C9}<br />
ProductVersion : 11.0.7969.0<br />
Language : ENGLISH</p>
<p>ProductName : Microsoft Office Visio Pro 2003<br />
ProductCame : {90510407-6000-11D3-8CFE-0150048383C9}<br />
ProductVersion : 11.0.8173.0<br />
Language : GERMAN</p>
<p>ProductName : Microsoft Office Visio Pro 2003<br />
ProductCame : {90510409-6000-11D3-8CFE-0150048383C9}<br />
ProductVersion : 11.0.7969.0<br />
Language : ENGLISH</p>
<p>ProductName : Microsoft Office Visio 2003 MUI<br />
ProductCame : {905E0407-6000-11D3-8CFE-0150048383C9}<br />
ProductVersion : 11.0.3216.5614<br />
Language : GERMAN</p>
<p>ProductName : Microsoft Office Visio 2003 MUI<br />
ProductCame : {905E0C0A-6000-11D3-8CFE-0150048383C9}<br />
ProductVersion : 11.0.3216.5614<br />
Language : SPANISH</p>
<p>ProductName : Microsoft Office Visio 2003 MUI<br />
ProductCame : {905E040C-6000-11D3-8CFE-0150048383C9}<br />
ProductVersion : 11.0.3216.5614<br />
Language : FRENCH</p>
<p>ProductName : Microsoft Office Visio 2003 MUI<br />
ProductCame : {905E0410-6000-11D3-8CFE-0150048383C9}<br />
ProductVersion : 11.0.3216.5614<br />
Language : ITALIAN</p>
<p>ProductName : Microsoft Visio Std 2010<br />
ProductCame : {329B57A6-048C-43BB-93BE-7BBF8BA55C03}<br />
ProductVersion : 3.0<br />
Language : ENGLISH</p>
<p>ProductName : Microsoft Visio Std 2010<br />
ProductCame : {41D5DCDB-FEB1-4AC4-8A02-816CC1D07975}<br />
ProductVersion : 4.0<br />
Language : FRENCH</p>
<p>ProductName : Microsoft Visio Std 2010<br />
ProductCame : {D7BEC8BB-C5E9-426E-966F-94BD2A88C395}<br />
ProductVersion : 2.0<br />
Language : GERMAN</p>
<p>ProductName : Microsoft Visio Std 2010<br />
ProductCame : {BA913A9D-8DEC-4C73-B8F5-6D1AE74D201B}<br />
ProductVersion : 6.0<br />
Language : SPANISH</p>
<p>&nbsp;</p>
<p><strong>VMWare</strong><br />
ProductName : VMware Player<br />
ProductCame : {A53A11EA-0095-493F-86FA-A15E8A86A405}<br />
ProductVersion : 3.0.0.9911<br />
Language : ENGLISH</p>
<p>ProductName : VMware Workstation<br />
ProductCame : {A3FF5CB2-FB35-4658-8751-9EDE1D65B3AA}<br />
ProductVersion : 7.0.1.11056<br />
Language : ENGLISH</p>
<p>ProductName : VMware Workstation<br />
ProductCame : {0D94F75A-0EA6-4951-B3AF-B145FA9E05C6}<br />
ProductVersion : 8.0.1.27038<br />
Language : ENGLISH</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hican.net/2012/01/23/miscellaneous-list-of-often-used-products-and-their-guids/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>VBScript: Install Oracle Webclient (Kill Predeploy.htm)</title>
		<link>http://www.hican.net/2012/01/17/vbscript-install-oracle-webclient-kill-predeploy-htm/</link>
		<comments>http://www.hican.net/2012/01/17/vbscript-install-oracle-webclient-kill-predeploy-htm/#comments</comments>
		<pubDate>Tue, 17 Jan 2012 11:13:11 +0000</pubDate>
		<dc:creator>hicannet</dc:creator>
				<category><![CDATA[VBScript]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[predeploy.htm]]></category>
		<category><![CDATA[Siebel]]></category>
		<category><![CDATA[Unattended Install]]></category>

		<guid isPermaLink="false">http://www.hican.net/?p=130</guid>
		<description><![CDATA[<p>Finally, after a long holiday, a new blog post and script again.<br /> The script below is a very neat script which does a full silent (unattended) install of the Oracle Webclient / Siebel Mobile Client <strong>and</strong> kills the <a href="https://forums.oracle.com/forums/thread.jspa?threadID=2306227" title="predeploy.htm &#124; Where it goes wrong">predeploy.htm</a>! There aren&#8217;t much scripts on the internet which can do it like this script does.<br /> <br /> Apart from some minor changes, the script is mainly written by a colleague of mine  <a href="http://www.hican.net/2012/01/17/vbscript-install-oracle-webclient-kill-predeploy-htm/" class="continueRead" >Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Finally, after a long holiday, a new blog post and script again.<br />
The script below is a very neat script which does a full silent (unattended) install of the Oracle Webclient / Siebel Mobile Client <strong>and</strong> kills the <a href="https://forums.oracle.com/forums/thread.jspa?threadID=2306227" title="predeploy.htm | Where it goes wrong">predeploy.htm</a>! There aren&#8217;t much scripts on the internet which can do it like this script does.<br />
<br />
Apart from some minor changes, the script is mainly written by a colleague of mine (who likes to stay low on the radar <img src='http://www.hican.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  ). The script was written because a silent install was needed in the project we are working on. Oracle doesn&#8217;t support a silent install, therefore we had to write it ourselves (Oracle is lightyears behind with all kinds of stuff by the way).<br />
<br />
<strong>Note #1</strong>: Change the <IP_ADDRESS> value, on line 39, to the remote webserver in your environment!<br />
<strong>Note #2</strong>: The script uses different kind of hta files, to give output / status information. These are just basic hta files. If you want an example, please <a href="http://www.hican.net/contact/" title="Contact | Hican.net">contact</a> me.<br />
<br />
<strong>install_oracle_webclient.vbs (silent + kill predeploy.htm)</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
</pre></td><td class="code"><pre class="vbnet" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">'''''''''''''''''''''''''''''''''''''''''''''''''''''''</span>
<span style="color: #008080; font-style: italic;">' AUTHOR  : http://www.hican.net - @hicannet</span>
<span style="color: #008080; font-style: italic;">' DATE    : 17-01-2012</span>
<span style="color: #008080; font-style: italic;">' COMMENT : This script installs the Oracle / Siebel</span>
<span style="color: #008080; font-style: italic;">'           webclient and it kills the predeploy.htm</span>
<span style="color: #008080; font-style: italic;">'''''''''''''''''''''''''''''''''''''''''''''''''''''''</span>
<span style="color: #FF8000;">Set</span> objShell      <span style="color: #008000;">=</span> <span style="color: #0600FF;">CreateObject</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Wscript.Shell&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Set</span> objFSO        <span style="color: #008000;">=</span> <span style="color: #0600FF;">CreateObject</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Scripting.FileSystemObject&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Set</span> objLogFileFSO <span style="color: #008000;">=</span> <span style="color: #0600FF;">CreateObject</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Scripting.FileSystemObject&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Set</span> wshSystemEnv  <span style="color: #008000;">=</span> objShell.<span style="color: #0000FF;">Environment</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;SYSTEM&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Set</span> objProcessEnv <span style="color: #008000;">=</span> objShell.<span style="color: #0000FF;">Environment</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;PROCESS&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Set</span> objReg        <span style="color: #008000;">=</span> GetObject<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;winmgmts:{impersonationLevel=&quot;</span> _ 
                    <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;impersonate}!\\.\root\default:StdRegProv&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Set</span> objWMIService <span style="color: #008000;">=</span> GetObject<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;winmgmts:\\.\root\cimv2&quot;</span><span style="color: #000000;">&#41;</span>
&nbsp;
CurrentDir        <span style="color: #008000;">=</span> <span style="color: #0600FF;">Left</span><span style="color: #000000;">&#40;</span>Wscript.<span style="color: #0000FF;">ScriptFullname</span>, <span style="color: #0600FF;">InstrRev</span><span style="color: #000000;">&#40;</span>Wscript.<span style="color: #0000FF;">ScriptFullname</span>, <span style="color: #808080;">&quot;\&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
strLogLocation    <span style="color: #008000;">=</span> objShell.<span style="color: #0000FF;">ExpandEnvironmentStrings</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;%WinDir%&quot;</span><span style="color: #000000;">&#41;</span> _ 
                    <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;\system32\logfiles&quot;</span>
&nbsp;
<span style="color: #0600FF;">Const</span> SilentParam        <span style="color: #008000;">=</span> <span style="color: #808080;">&quot; /qb!&quot;</span>
<span style="color: #0600FF;">Const</span> AllUsers           <span style="color: #008000;">=</span> <span style="color: #808080;">&quot; ALLUSERS=1&quot;</span>
<span style="color: #0600FF;">Const</span> HKEY_LOCAL_MACHINE <span style="color: #008000;">=</span> <span style="color: #008000;">&amp;</span>H80000002
<span style="color: #0600FF;">Const</span> <span style="color: #0600FF;">ForWriting</span>         <span style="color: #008000;">=</span> <span style="color: #FF0000;">2</span>
<span style="color: #0600FF;">Const</span> <span style="color: #0600FF;">ForReading</span>         <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span>
<span style="color: #0600FF;">Const</span> <span style="color: #0600FF;">ForAppending</span>       <span style="color: #008000;">=</span> <span style="color: #FF0000;">8</span>
<span style="color: #0600FF;">Const</span> OverWriteFiles     <span style="color: #008000;">=</span> <span style="color: #0600FF;">True</span>
&nbsp;
CreateFolderStructure<span style="color: #000000;">&#40;</span>strLogLocation<span style="color: #000000;">&#41;</span>
strLogLocation           <span style="color: #008000;">=</span> strLogLocation <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;\&quot;</span>
strSiebelInstallLogFile  <span style="color: #008000;">=</span> strLogLocation <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;Siebel_Web_Client_&quot;</span> _ 
                           <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Replace</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">FormatDateTime</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Now</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>, <span style="color: #FF0000;">2</span><span style="color: #000000;">&#41;</span>,<span style="color: #808080;">&quot;/&quot;</span>,<span style="color: #808080;">&quot;-&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;.log&quot;</span>
&nbsp;
<span style="color: #0600FF;">If</span>  objLogFileFSO.<span style="color: #0000FF;">FileExists</span><span style="color: #000000;">&#40;</span>strSiebelInstallLogFile<span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
  <span style="color: #FF8000;">Set</span> objLogFile <span style="color: #008000;">=</span> objLogFileFSO.<span style="color: #0000FF;">OpenTextFile</span><span style="color: #000000;">&#40;</span>strSiebelInstallLogFile, <span style="color: #0600FF;">ForWriting</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Else</span>
  <span style="color: #FF8000;">Set</span> objLogFile <span style="color: #008000;">=</span> objLogFileFSO.<span style="color: #0000FF;">CreateTextFile</span><span style="color: #000000;">&#40;</span>strSiebelInstallLogFile<span style="color: #000000;">&#41;</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
&nbsp;
strremoteServerMobileClient <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;&lt;IP_ADDRESS&gt;&quot;</span>
strORACLE_HOME              <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;C:\Siebel\8.1\Client_1&quot;</span>
strORACLE_HOME_NAME         <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Siebel8_home1&quot;</span>
strINVENTORY_LOCATION       <span style="color: #008000;">=</span> strLogLocation <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;Siebel_Web_Client_&quot;</span> _ 
                              <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Replace</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">FormatDateTime</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Now</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>, <span style="color: #FF0000;">2</span><span style="color: #000000;">&#41;</span>,<span style="color: #808080;">&quot;/&quot;</span>,<span style="color: #808080;">&quot;-&quot;</span><span style="color: #000000;">&#41;</span>
strArchitecture             <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;&quot;</span>
strOperatingSystemCaption   <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;&quot;</span>
strOperatingSystemVersion   <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;&quot;</span>
&nbsp;
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
<span style="color: #008080; font-style: italic;">' Find the processor architecture</span>
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
<span style="color: #FF8000;">Set</span> colItems <span style="color: #008000;">=</span> objWMIService.<span style="color: #0000FF;">ExecQuery</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Select Architecture from Win32_Processor&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">For</span> <span style="color: #0600FF;">Each</span> objItem In colItems
  <span style="color: #0600FF;">If</span> objItem.<span style="color: #0000FF;">Architecture</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span> <span style="color: #FF8000;">Then</span> strArchitecture <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;x86&quot;</span>
  <span style="color: #0600FF;">If</span> objItem.<span style="color: #0000FF;">Architecture</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">9</span> <span style="color: #FF8000;">Then</span> strArchitecture <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;x64&quot;</span>
<span style="color: #FF8000;">Next</span>
&nbsp;
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
<span style="color: #008080; font-style: italic;">' Step 1: Checks the prerequisites. Windows Vista (and above) is not supported </span>
<span style="color: #008080; font-style: italic;">' by Oracle.</span>
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
PrerequisiteChecks
&nbsp;
<span style="color: #008080; font-style: italic;">' Avoid the File Open dialog.</span>
objProcessEnv<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;SEE_MASK_NOZONECHECKS&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span>
&nbsp;
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
<span style="color: #008080; font-style: italic;">' Step 2: Install ActivePerl</span>
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
InstallActivePerl
&nbsp;
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
<span style="color: #008080; font-style: italic;">' Step 3: Force shutdown of internet explorer</span>
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
WriteToLog <span style="color: #808080;">&quot;Action: -&gt; Executing: Kill both IE and Java processes (if running)&quot;</span>
fnKillProcess<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;iexplore.exe&quot;</span><span style="color: #000000;">&#41;</span>
fnKillProcess<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;java.exe&quot;</span><span style="color: #000000;">&#41;</span>
fnKillProcess<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;javaw.exe&quot;</span><span style="color: #000000;">&#41;</span>
fnKillProcess<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;mshta.exe&quot;</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
<span style="color: #008080; font-style: italic;">' Step 4: Install the Oracle Web Client 8.1 Silent</span>
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
InstallOracleWebClient81Silent
&nbsp;
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
<span style="color: #008080; font-style: italic;">' Step 5: Install the Oracle Web Client 8.1.1.3 Silent</span>
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
InstallOracleWebClient8113Silent
&nbsp;
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
<span style="color: #008080; font-style: italic;">' Step 6: Set the ORACLE_HOME system environment variable</span>
<span style="color: #008080; font-style: italic;">' Step 7: Modify the PATH system and process environment variable.</span>
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
ModifyEnvironmentVariables
&nbsp;
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
<span style="color: #008080; font-style: italic;">' Step 8: Copy the Oracle Patches to a folder under ORACLE_HOME</span>
<span style="color: #008080; font-style: italic;">' Step 9: Run 'OPatch' to upgrade the installation</span>
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
InstallOraclePatches
&nbsp;
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
<span style="color: #008080; font-style: italic;">' Step 10: Modify the start menu</span>
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
ModifyStartMenu
&nbsp;
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
<span style="color: #008080; font-style: italic;">' Step 11: Predeploy all the ocx, dll files for Internet Explorer. Also process </span>
<span style="color: #008080; font-style: italic;">' the .inf files.</span>
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
PredeployOracleCABFiles
PredeployOracleINFFiles
&nbsp;
WriteToLog <span style="color: #808080;">&quot;-------------------------------------------------------------------&quot;</span>
WriteToLog <span style="color: #808080;">&quot;Installation has completed.&quot;</span>
WriteToLog <span style="color: #808080;">&quot;-------------------------------------------------------------------&quot;</span>
&nbsp;
objProcessEnv.<span style="color: #0000FF;">Remove</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;SEE_MASK_NOZONECHECKS&quot;</span><span style="color: #000000;">&#41;</span>
fnKillProcess<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;mshta.exe&quot;</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #0600FF;">Sub</span> PrerequisiteChecks
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
<span style="color: #008080; font-style: italic;">' Subroutine: PrerequisiteChecks</span>
<span style="color: #008080; font-style: italic;">' Checks the OS version. If Windows 7 (or higher) then quit.</span>
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
&nbsp;
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
<span style="color: #008080; font-style: italic;">' Step 1: find the OS version</span>
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
<span style="color: #FF8000;">Set</span> colItems <span style="color: #008000;">=</span> objWMIService.<span style="color: #0000FF;">ExecQuery</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Select Version from Win32_OperatingSystem&quot;</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #FF8000;">For</span> <span style="color: #0600FF;">Each</span> objItem In colItems
  strOperatingSystemVersion <span style="color: #008000;">=</span> objItem.<span style="color: #0000FF;">Version</span>
<span style="color: #FF8000;">Next</span>
&nbsp;
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
<span style="color: #008080; font-style: italic;">' Step 2: find the OS Caption</span>
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
<span style="color: #FF8000;">Set</span> colItems <span style="color: #008000;">=</span> objWMIService.<span style="color: #0000FF;">ExecQuery</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Select Caption from Win32_OperatingSystem&quot;</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #FF8000;">For</span> <span style="color: #0600FF;">Each</span> objItem In colItems
  strOperatingSystemCaption <span style="color: #008000;">=</span> objItem.<span style="color: #0000FF;">caption</span>
<span style="color: #FF8000;">Next</span>
&nbsp;
strMessage <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Found OS '&quot;</span> <span style="color: #008000;">&amp;</span> strOperatingSystemCaption <span style="color: #008000;">&amp;</span> _ 
             <span style="color: #808080;">&quot;' (&quot;</span> <span style="color: #008000;">&amp;</span> strOperatingSystemVersion <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;) (&quot;</span> <span style="color: #008000;">&amp;</span> strArchitecture <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;)&quot;</span>
WriteToLog strMessage
&nbsp;
<span style="color: #0600FF;">If</span> <span style="color: #0600FF;">Left</span><span style="color: #000000;">&#40;</span>strOperatingSystemVersion,<span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span> &gt; <span style="color: #FF0000;">5</span> <span style="color: #FF8000;">Then</span>
  strMessage <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;The OS '&quot;</span> <span style="color: #008000;">&amp;</span> strOperatingSystemCaption <span style="color: #008000;">&amp;</span> _ 
               <span style="color: #808080;">&quot;' is not supported by Oracle. The installation will be aborted.&quot;</span>
  WriteToLog strMessage
  <span style="color: #0600FF;">MsgBox</span> strMessage,<span style="color: #FF0000;">16</span>,<span style="color: #808080;">&quot;Oracle Web Client&quot;</span>
  WScript.<span style="color: #0000FF;">Quit</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span>
&nbsp;
<span style="color: #0600FF;">Sub</span> ShowHTA<span style="color: #000000;">&#40;</span>strHTAFile<span style="color: #000000;">&#41;</span>
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
<span style="color: #008080; font-style: italic;">' Subroutine: ShowHTA(strHTAFile)</span>
<span style="color: #008080; font-style: italic;">' Shows a HTA file on the screen.</span>
<span style="color: #008080; font-style: italic;">' trHTAFile = &quot;c:\folder\folder1\folder2\filename.hta&quot;</span>
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
fnKillProcess<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;mshta.exe&quot;</span><span style="color: #000000;">&#41;</span>
strCommand <span style="color: #008000;">=</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> strHTAFile <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span>
WriteToLog <span style="color: #808080;">&quot;Action: -&gt; Executing: &quot;</span> <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> strHTAFile <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span>
objshell.<span style="color: #0000FF;">run</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> strHTAFile <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span>,<span style="color: #FF0000;">0</span>,<span style="color: #0600FF;">False</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span>
&nbsp;
<span style="color: #0600FF;">Sub</span> CreateFolderStructure<span style="color: #000000;">&#40;</span>strFolderNameToBeCreated<span style="color: #000000;">&#41;</span>
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
<span style="color: #008080; font-style: italic;">' Subroutine: CreateFolderStructure(strFolderNameToBeCreated)</span>
<span style="color: #008080; font-style: italic;">' Creates the folderstructure as mentioned. Do not add a trailing '\'</span>
<span style="color: #008080; font-style: italic;">' strFolderNameToBeCreated = &quot;c:\folder\folder1\folder2&quot;</span>
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
<span style="color: #0600FF;">Dim</span> arrFolders : arrFolders <span style="color: #008000;">=</span> <span style="color: #0600FF;">split</span> <span style="color: #000000;">&#40;</span>strFolderNameToBeCreated,<span style="color: #808080;">&quot;\&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #0600FF;">Dim</span> strFolder  : strFolder  <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;&quot;</span>
<span style="color: #0600FF;">Dim</span> objFolder
&nbsp;
<span style="color: #FF8000;">For</span> <span style="color: #0600FF;">Each</span> objFolder In arrFolders
  strFolder <span style="color: #008000;">=</span> strFolder <span style="color: #008000;">&amp;</span> objFolder
  <span style="color: #0600FF;">If</span> <span style="color: #804040;">NOT</span> objFSO.<span style="color: #0000FF;">FolderExists</span><span style="color: #000000;">&#40;</span>strFolder<span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
    objFSO.<span style="color: #0000FF;">CreateFolder</span><span style="color: #000000;">&#40;</span>strFolder<span style="color: #000000;">&#41;</span>
  <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
  strFolder <span style="color: #008000;">=</span> strFolder <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;\&quot;</span>
<span style="color: #FF8000;">Next</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span>
&nbsp;
<span style="color: #0600FF;">Function</span> fnKillProcess<span style="color: #000000;">&#40;</span>strProcessName<span style="color: #000000;">&#41;</span>
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
<span style="color: #008080; font-style: italic;">' Function: fnKillProcess(strProcessName)</span>
<span style="color: #008080; font-style: italic;">' Terminates the given processname.</span>
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
<span style="color: #FF8000;">Set</span> fn_objWMIService <span style="color: #008000;">=</span> GetObject<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;winmgmts:{impersonationLevel=&quot;</span> _
                       <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;impersonate}!\\.\root\cimv2&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Set</span> colProcess <span style="color: #008000;">=</span> fn_objWMIService.<span style="color: #0000FF;">ExecQuery</span> <span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Select * From Win32_Process&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">For</span> <span style="color: #0600FF;">Each</span> objProcess In colProcess
  <span style="color: #0600FF;">If</span> <span style="color: #0600FF;">LCase</span><span style="color: #000000;">&#40;</span>objProcess.<span style="color: #0000FF;">Name</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #0600FF;">LCase</span><span style="color: #000000;">&#40;</span>strProcessName<span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
     objProcess.<span style="color: #0600FF;">Terminate</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
  <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
<span style="color: #FF8000;">Next</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span>
&nbsp;
<span style="color: #0600FF;">Function</span> fn_WaitForProcessToStart<span style="color: #000000;">&#40;</span>strProcessName<span style="color: #000000;">&#41;</span>
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
<span style="color: #008080; font-style: italic;">' Function: fn_WaitForProcessToStart(strProcessName)</span>
<span style="color: #008080; font-style: italic;">' This function waits for a process to start. If the given processname is </span>
<span style="color: #008080; font-style: italic;">' running, then the function is quit.</span>
<span style="color: #008080; font-style: italic;">' strProcessName = the process to be checked.</span>
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
blnProcessFound <span style="color: #008000;">=</span> <span style="color: #0600FF;">False</span>
<span style="color: #FF8000;">Set</span> fn_objSWbemServices <span style="color: #008000;">=</span> GetObject<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;winmgmts:\\.\root\cimv2&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #0600FF;">Do</span> 
  WScript.<span style="color: #0000FF;">Sleep</span> <span style="color: #FF0000;">2500</span>
  <span style="color: #FF8000;">Set</span> colSWbemObjectSet <span style="color: #008000;">=</span> fn_objSWbemServices.<span style="color: #0000FF;">InstancesOf</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Win32_Process&quot;</span><span style="color: #000000;">&#41;</span>
  <span style="color: #FF8000;">For</span> <span style="color: #0600FF;">Each</span> objSWbemObject In colSWbemObjectSet
    <span style="color: #0600FF;">If</span> <span style="color: #000000;">&#40;</span><span style="color: #0600FF;">LCase</span><span style="color: #000000;">&#40;</span>objSWbemObject.<span style="color: #0000FF;">Name</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #0600FF;">LCase</span><span style="color: #000000;">&#40;</span>strProcessName<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
      blnProcessFound <span style="color: #008000;">=</span> <span style="color: #0600FF;">True</span>
    <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
  <span style="color: #FF8000;">Next</span>
<span style="color: #0600FF;">Loop</span> Until blnProcessFound
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span>
&nbsp;
<span style="color: #0600FF;">Function</span> fn_WaitForARunningProcess<span style="color: #000000;">&#40;</span>strProcessName<span style="color: #000000;">&#41;</span>
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
<span style="color: #008080; font-style: italic;">' Function: fn_WaitForARunningProcess(strProcessName)</span>
<span style="color: #008080; font-style: italic;">' This function waits for a process to stop. When the processname is not </span>
<span style="color: #008080; font-style: italic;">' running anymore, this function will quit.</span>
<span style="color: #008080; font-style: italic;">' strProcessName = the process to be checked.</span>
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
<span style="color: #FF8000;">Set</span> fn_objSWbemServices <span style="color: #008000;">=</span> GetObject<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;winmgmts:\\.\root\cimv2&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Set</span> colSWbemObjectSet <span style="color: #008000;">=</span> fn_objSWbemServices.<span style="color: #0000FF;">InstancesOf</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Win32_Process&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">For</span> <span style="color: #0600FF;">Each</span> objSWbemObject In colSWbemObjectSet
  <span style="color: #0600FF;">If</span> <span style="color: #000000;">&#40;</span><span style="color: #0600FF;">LCase</span><span style="color: #000000;">&#40;</span>objSWbemObject.<span style="color: #0000FF;">Name</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #0600FF;">LCase</span><span style="color: #000000;">&#40;</span>strProcessName<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
    Wscript.<span style="color: #0000FF;">Sleep</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">2500</span><span style="color: #000000;">&#41;</span>
    fn_WaitForARunningProcess<span style="color: #000000;">&#40;</span>strProcessName<span style="color: #000000;">&#41;</span>
  <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
<span style="color: #FF8000;">Next</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span>
&nbsp;
<span style="color: #0600FF;">Function</span> WriteToLog<span style="color: #000000;">&#40;</span>sLogMessage<span style="color: #000000;">&#41;</span>
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
<span style="color: #008080; font-style: italic;">' Function: WriteToLog(sLogMessage)</span>
<span style="color: #008080; font-style: italic;">' This function writes an entry in a log file.</span>
<span style="color: #008080; font-style: italic;">' sLogMessage = The message to be written in the log file.</span>
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
  objLogFile.<span style="color: #0000FF;">WriteLine</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Time: &quot;</span> <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">now</span> <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;  &quot;</span> <span style="color: #008000;">&amp;</span> sLogMessage<span style="color: #000000;">&#41;</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span>
&nbsp;
<span style="color: #0600FF;">Function</span> fnWriterunningProcessesToLogFile<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
<span style="color: #008080; font-style: italic;">' Function: fnWriterunningProcessesToLogFile</span>
<span style="color: #008080; font-style: italic;">' Writes all the running processes to a log file.</span>
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
<span style="color: #FF8000;">Set</span> fn_objWMIService <span style="color: #008000;">=</span> GetObject<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;winmgmts:{impersonationLevel=&quot;</span> _
                       <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;impersonate}!\\.\root\cimv2&quot;</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #FF8000;">Set</span> colProcess <span style="color: #008000;">=</span> fn_objWMIService.<span style="color: #0000FF;">ExecQuery</span> <span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Select * From Win32_Process&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">For</span> <span style="color: #0600FF;">Each</span> objProcess In colProcess
  WriteToLog<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot; --&gt; Running process: &quot;</span> <span style="color: #008000;">&amp;</span> objProcess.<span style="color: #0000FF;">Name</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Next</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span>
&nbsp;
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
<span style="color: #008080; font-style: italic;">' The following subroutines are used to install the components.</span>
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
<span style="color: #0600FF;">Sub</span> InstallActivePerl
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
<span style="color: #008080; font-style: italic;">' Sub InstallActivePerl</span>
<span style="color: #008080; font-style: italic;">' Only installs ActivePerl if not already installed.</span>
<span style="color: #008080; font-style: italic;">' Use WMI to find the processor architecture.</span>
<span style="color: #008080; font-style: italic;">' The variable %PROCESSOR_ARCHITECTURE% always returns x86 (under sytem </span>
<span style="color: #008080; font-style: italic;">' context). That is why WMI is used.</span>
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
<span style="color: #0600FF;">If</span> strArchitecture <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;x86&quot;</span> <span style="color: #FF8000;">Then</span>
  strMSIFileName <span style="color: #008000;">=</span> CurrentDir <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;1-ActivePerl&quot;</span> <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">92</span><span style="color: #000000;">&#41;</span> _ 
                   <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;ActivePerl-5.14.2.1402-MSWin32-x86-295342.msi&quot;</span>
  strLogfile <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;ActivePerl-5.14.2.1402-MSWin32-x86-295342.log&quot;</span>
  strExecuteCommand <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;msiexec.exe /i &quot;</span> <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> strMSIFileName _ 
                      <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> SilentParam <span style="color: #008000;">&amp;</span> Allusers <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot; /l*v &quot;</span> _ 
                      <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> strLogLocation <span style="color: #008000;">&amp;</span> strLogfile <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span>
  WriteToLog <span style="color: #808080;">&quot;Action: -&gt; Executing: &quot;</span> <span style="color: #008000;">&amp;</span> strExecuteCommand
  objShell.<span style="color: #0000FF;">Run</span> strExecuteCommand,<span style="color: #FF0000;">0</span>,<span style="color: #0600FF;">True</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
&nbsp;
<span style="color: #0600FF;">If</span> strArchitecture <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;x64&quot;</span> <span style="color: #FF8000;">Then</span>
  strMSIFileName <span style="color: #008000;">=</span> CurrentDir <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;1-ActivePerl&quot;</span> <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">92</span><span style="color: #000000;">&#41;</span> _ 
                   <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;ActivePerl-5.14.2.1402-MSWin32-x64-295342.msi&quot;</span>
  strLogfile <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;ActivePerl-5.14.2.1402-MSWin32-x64-295342.log&quot;</span>
  strExecuteCommand <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;msiexec.exe /i &quot;</span> <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> strMSIFileName <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span> _ 
                      <span style="color: #008000;">&amp;</span> SilentParam <span style="color: #008000;">&amp;</span> Allusers <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot; /l*v &quot;</span> <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span> _ 
                      <span style="color: #008000;">&amp;</span> strLogLocation <span style="color: #008000;">&amp;</span> strLogfile <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span>
  WriteToLog <span style="color: #808080;">&quot;Action: -&gt; Executing: &quot;</span> <span style="color: #008000;">&amp;</span> strExecuteCommand
  objShell.<span style="color: #0000FF;">Run</span> strExecuteCommand,<span style="color: #FF0000;">0</span>,<span style="color: #0600FF;">True</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span>
&nbsp;
<span style="color: #0600FF;">Sub</span> InstallOracleWebClient81Silent
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
<span style="color: #008080; font-style: italic;">' Sub InstallOracleWebClient81Silent</span>
<span style="color: #008080; font-style: italic;">' Installs the Oracle Web Client 8.1</span>
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
ShowHTA<span style="color: #000000;">&#40;</span>CurrentDir <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;step_1_Installing_8.1.hta&quot;</span><span style="color: #000000;">&#41;</span>
&nbsp;
strFROM_LOCATION  <span style="color: #008000;">=</span> CurrentDir <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;2-8.1\Siebel_Web_Client\Disk1\stage\products.xml&quot;</span>
strExecuteCommand <span style="color: #008000;">=</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> CurrentDir _
                    <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;2-8.1\Siebel_Web_Client\Disk1\install\oui.exe&quot;</span> <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span> _ 
                    <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot; -ignoreSysPrereqs -noconsole -silent -nowait -force&quot;</span> _ 
                    <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot; -responseFile &quot;</span> <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> CurrentDir _ 
                    <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;6-RSPFiles\Siebel81.rsp&quot;</span> <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span> _ 
                    <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot; FROM_LOCATION=&quot;</span> <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> strFROM_LOCATION <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span> _ 
                    <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot; remoteServerMobileClient=&quot;</span> <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span> _ 
                    <span style="color: #008000;">&amp;</span> strremoteServerMobileClient <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot; ORACLE_HOME=&quot;</span> _ 
                    <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> strORACLE_HOME <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot; ORACLE_HOME_NAME=&quot;</span> _ 
                    <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> strORACLE_HOME_NAME <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span> _ 
                    <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot; INVENTORY_LOCATION=&quot;</span> <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> strINVENTORY_LOCATION _ 
                    <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span>
WriteToLog <span style="color: #808080;">&quot;Action: -&gt; Executing: &quot;</span> <span style="color: #008000;">&amp;</span> strExecuteCommand
blnResult <span style="color: #008000;">=</span> objShell.<span style="color: #0000FF;">Run</span> <span style="color: #000000;">&#40;</span>strExecuteCommand<span style="color: #000000;">&#41;</span>
&nbsp;
WriteToLog <span style="color: #808080;">&quot;Action: -&gt; Now wait for Internet Explorer screen to come up&quot;</span>
fn_WaitForProcessToStart<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;iexplore.exe&quot;</span><span style="color: #000000;">&#41;</span>
WriteToLog <span style="color: #808080;">&quot;Action: -&gt; Executing: Kill Internet Explorer process&quot;</span>
fnKillProcess <span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;iexplore.exe&quot;</span><span style="color: #000000;">&#41;</span>
&nbsp;
WriteToLog <span style="color: #808080;">&quot;Action: -&gt; Now wait for Java to finish.&quot;</span>
<span style="color: #008080; font-style: italic;">' If run without the -noconsole parameter, then wait for java.exe</span>
fn_WaitForARunningProcess<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;javaw.exe&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span>
&nbsp;
<span style="color: #0600FF;">Sub</span> InstallOracleWebClient8113Silent
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
<span style="color: #008080; font-style: italic;">' Sub InstallOracleWebClient8113Silent</span>
<span style="color: #008080; font-style: italic;">' Installs the Oracle Web Client 8.1.1.3</span>
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
ShowHTA<span style="color: #000000;">&#40;</span>CurrentDir <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;step_2_Installing_8.1.1.3.hta&quot;</span><span style="color: #000000;">&#41;</span>
&nbsp;
strFROM_LOCATION  <span style="color: #008000;">=</span> CurrentDir _
                    <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;3-8.1.1.3\Client\Siebel_Web_Client\Disk1\stage\products.xml&quot;</span>
strExecuteCommand <span style="color: #008000;">=</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> CurrentDir _ 
                    <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;3-8.1.1.3\Client\Siebel_Web_Client\Disk1\install\oui.exe&quot;</span> _ 
                    <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot; -ignoreSysPrereqs -noconsole -silent -nowait&quot;</span> _ 
                    <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot; -force -responseFile &quot;</span> <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> CurrentDir _ 
                    <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;6-RSPFiles\Siebel8113.rsp&quot;</span> <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span> _ 
                    <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot; FROM_LOCATION=&quot;</span> <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> strFROM_LOCATION <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span> _ 
                    <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot; ORACLE_HOME=&quot;</span> <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> strORACLE_HOME <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span> _ 
                    <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot; ORACLE_HOME_NAME=&quot;</span> <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> strORACLE_HOME_NAME _ 
                    <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot; INVENTORY_LOCATION=&quot;</span> <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span> _ 
                    <span style="color: #008000;">&amp;</span> strINVENTORY_LOCATION <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span>
WriteToLog <span style="color: #808080;">&quot;Action: -&gt; Executing: &quot;</span> <span style="color: #008000;">&amp;</span> strExecuteCommand
blnResult <span style="color: #008000;">=</span> objShell.<span style="color: #0000FF;">Run</span> <span style="color: #000000;">&#40;</span>strExecuteCommand<span style="color: #000000;">&#41;</span>
&nbsp;
WriteToLog <span style="color: #808080;">&quot;Action: -&gt; Wait for Oracle Universal Installer and Java to finish.&quot;</span>
fn_WaitForARunningProcess<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;oui.exe&quot;</span><span style="color: #000000;">&#41;</span>
WScript.<span style="color: #0000FF;">Sleep</span> <span style="color: #FF0000;">10000</span>
<span style="color: #008080; font-style: italic;">'If run without the -noconsole parameter, then wait for java.exe</span>
fn_WaitForARunningProcess<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;javaw.exe&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span>
&nbsp;
<span style="color: #0600FF;">Sub</span> ModifyEnvironmentVariables
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
<span style="color: #008080; font-style: italic;">' Sub ModifyEnvironmentVariables</span>
<span style="color: #008080; font-style: italic;">' Modifies the System Environment variables. </span>
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
wshSystemEnv<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;ORACLE_HOME&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> strORACLE_HOME
WriteToLog <span style="color: #808080;">&quot;The system environment value 'ORACLE_HOME' has been set to &quot;</span> _ 
           <span style="color: #008000;">&amp;</span> strORACLE_HOME
&nbsp;
strPATH <span style="color: #008000;">=</span> wshSystemEnv<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;PATH&quot;</span><span style="color: #000000;">&#41;</span>
WriteToLog <span style="color: #808080;">&quot;The system environment variable PATH has as value: &quot;</span> <span style="color: #008000;">&amp;</span> strPATH
<span style="color: #0600FF;">If</span> <span style="color: #0600FF;">InStr</span><span style="color: #000000;">&#40;</span>strPATH,<span style="color: #808080;">&quot;perl&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span> <span style="color: #FF8000;">Then</span>
  wshSystemEnv<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;PATH&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">=</span><span style="color: #808080;">&quot;C:\Perl\bin;&quot;</span> <span style="color: #008000;">&amp;</span> strPATH
  WriteToLog <span style="color: #808080;">&quot;The system environment variable PATH has been modified. The &quot;</span> _ 
	           <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;new value is &quot;</span> <span style="color: #008000;">&amp;</span> wshSystemEnv<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;PATH&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Else</span>
  WriteToLog <span style="color: #808080;">&quot;The system environment variable PATH has not been modified.&quot;</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span>
&nbsp;
<span style="color: #0600FF;">Sub</span> InstallOraclePatches
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
<span style="color: #008080; font-style: italic;">' Sub InstallOraclePatches</span>
<span style="color: #008080; font-style: italic;">' Copies the files to ORACLE_HOME. Then installs 2 oracle Patches. </span>
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
ShowHTA<span style="color: #000000;">&#40;</span>CurrentDir <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;step_3_Copy_files.hta&quot;</span><span style="color: #000000;">&#41;</span>
objFSO.<span style="color: #0000FF;">CopyFolder</span> CurrentDir <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;4-QF0312&quot;</span> , strORACLE_HOME <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;\&quot;</span>,OverWriteFiles
objFSO.<span style="color: #0000FF;">CopyFolder</span> CurrentDir <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;5-QF1302&quot;</span> , strORACLE_HOME <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;\&quot;</span>,OverWriteFiles
objFSO.<span style="color: #0000FF;">CopyFile</span> CurrentDir <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;6-RSPFiles\ocm.rsp&quot;</span> , strORACLE_HOME _ 
                           <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;\&quot;</span>,OverWriteFiles
ShowHTA<span style="color: #000000;">&#40;</span>CurrentDir <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;step_4_Installing_Patch_QF0312.hta&quot;</span><span style="color: #000000;">&#41;</span>
&nbsp;
strCommand <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;c:\Perl\bin\perl.exe &quot;</span> <span style="color: #008000;">&amp;</span> strORACLE_HOME _
             <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;\4-QF0312\Siebel_Web_Client\OPatch\opatch.pl apply &quot;</span> _
             <span style="color: #008000;">&amp;</span> strORACLE_HOME <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;\4-QF0312\Siebel_Web_Client -silent -force &quot;</span> _
             <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;-ocmrf &quot;</span> <span style="color: #008000;">&amp;</span> strORACLE_HOME <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;\ocm.rsp -oh &quot;</span> <span style="color: #008000;">&amp;</span> strORACLE_HOME
WriteToLog <span style="color: #808080;">&quot;Action: -&gt; Executing: 'objShell.Run &quot;</span> <span style="color: #008000;">&amp;</span> strCommand <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;,0,True'&quot;</span>
objShell.<span style="color: #0000FF;">Run</span> strCommand,<span style="color: #FF0000;">0</span>,<span style="color: #0600FF;">True</span>
&nbsp;
ShowHTA<span style="color: #000000;">&#40;</span>CurrentDir <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;step_5_Installing_Patch_QF1302.hta&quot;</span><span style="color: #000000;">&#41;</span>
&nbsp;
strCommand <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;c:\Perl\bin\perl.exe &quot;</span> <span style="color: #008000;">&amp;</span> strORACLE_HOME _
             <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;\5-QF1302\Siebel_Web_Client\OPatch\opatch.pl apply &quot;</span> _
             <span style="color: #008000;">&amp;</span> strORACLE_HOME <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;\5-QF1302\Siebel_Web_Client -silent -force &quot;</span> _
             <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;-ocmrf &quot;</span> <span style="color: #008000;">&amp;</span> strORACLE_HOME <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;\ocm.rsp -oh &quot;</span> <span style="color: #008000;">&amp;</span> strORACLE_HOME
WriteToLog <span style="color: #808080;">&quot;Action: -&gt; Executing: 'objShell.Run &quot;</span> <span style="color: #008000;">&amp;</span> strCommand <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;,0,True'&quot;</span>
objShell.<span style="color: #0000FF;">Run</span> strCommand,<span style="color: #FF0000;">0</span>,<span style="color: #0600FF;">True</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span>
&nbsp;
<span style="color: #0600FF;">Sub</span> ModifyStartMenu
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
<span style="color: #008080; font-style: italic;">' Sub ModifyStartMenu</span>
<span style="color: #008080; font-style: italic;">' Removes all unneeded entries from the Start menu and add one shortcut.  </span>
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
ShowHTA<span style="color: #000000;">&#40;</span>CurrentDir <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;step_6_Modifying_start_menu.hta&quot;</span><span style="color: #000000;">&#41;</span>
&nbsp;
strKeyPath   <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders&quot;</span>
strValueName <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Common Programs&quot;</span>
objReg.<span style="color: #0000FF;">GetStringValue</span> HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strCommonPrograms
&nbsp;
<span style="color: #0600FF;">If</span> objFSO.<span style="color: #0000FF;">FolderExists</span> <span style="color: #000000;">&#40;</span>strCommonPrograms <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;\ActivePerl 5.14.2 Build 1402&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
  WriteToLog <span style="color: #808080;">&quot;Action: -&gt; Deleting: &quot;</span> <span style="color: #008000;">&amp;</span> strCommonPrograms _
	           <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;\ActivePerl 5.14.2 Build 1402&quot;</span>
  objFSO.<span style="color: #0000FF;">DeleteFolder</span> <span style="color: #000000;">&#40;</span>strCommonPrograms <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;\ActivePerl 5.14.2 Build 1402&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
&nbsp;
<span style="color: #0600FF;">If</span> objFSO.<span style="color: #0000FF;">FolderExists</span> <span style="color: #000000;">&#40;</span>strCommonPrograms <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;\Oracle - &quot;</span> <span style="color: #008000;">&amp;</span> strORACLE_HOME_NAME<span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
  WriteToLog <span style="color: #808080;">&quot;Action: -&gt; Deleting: &quot;</span> <span style="color: #008000;">&amp;</span> strCommonPrograms <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;\Oracle - &quot;</span> _ 
	           <span style="color: #008000;">&amp;</span> strORACLE_HOME_NAME
  objFSO.<span style="color: #0000FF;">DeleteFolder</span> <span style="color: #000000;">&#40;</span>strCommonPrograms <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;\Oracle - &quot;</span> <span style="color: #008000;">&amp;</span> strORACLE_HOME_NAME<span style="color: #000000;">&#41;</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
&nbsp;
<span style="color: #0600FF;">If</span> objFSO.<span style="color: #0000FF;">FolderExists</span> <span style="color: #000000;">&#40;</span>strCommonPrograms <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">92</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> strORACLE_HOME_NAME<span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span> 
  WriteToLog <span style="color: #808080;">&quot;Action: -&gt; Deleting: &quot;</span> <span style="color: #008000;">&amp;</span> strCommonPrograms <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;\&quot;</span> <span style="color: #008000;">&amp;</span> strORACLE_HOME_NAME
  objFSO.<span style="color: #0000FF;">DeleteFolder</span> <span style="color: #000000;">&#40;</span>strCommonPrograms <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;\&quot;</span> <span style="color: #008000;">&amp;</span> strORACLE_HOME_NAME<span style="color: #000000;">&#41;</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span> 
&nbsp;
<span style="color: #FF8000;">Set</span> objLink              <span style="color: #008000;">=</span> objShell.<span style="color: #0000FF;">CreateShortcut</span><span style="color: #000000;">&#40;</span>strCommonPrograms _ 
                           <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;\Siebel Field Service - ENU.lnk&quot;</span><span style="color: #000000;">&#41;</span>
objLink.<span style="color: #0000FF;">Description</span>      <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Siebel Field Service - ENU&quot;</span>
objLink.<span style="color: #0000FF;">IconLocation</span>     <span style="color: #008000;">=</span> strORACLE_HOME <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;\bin\siebel.exe,0&quot;</span>
objLink.<span style="color: #0000FF;">TargetPath</span>       <span style="color: #008000;">=</span> strORACLE_HOME <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;\bin\siebel.exe&quot;</span> 
objLink.<span style="color: #0000FF;">Arguments</span>        <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;/c &quot;</span> <span style="color: #008000;">&amp;</span> strORACLE_HOME <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;\bin\enu\sfs.cfg&quot;</span>
objLink.<span style="color: #0000FF;">WindowStyle</span>      <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span>
objLink.<span style="color: #0000FF;">WorkingDirectory</span> <span style="color: #008000;">=</span> strORACLE_HOME <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;\bin&quot;</span>
objLink.<span style="color: #0000FF;">Save</span>
&nbsp;
WriteToLog <span style="color: #808080;">&quot;Action: -&gt; Created: icon 'Siebel Field Service - ENU' in &quot;</span> _ 
           <span style="color: #008000;">&amp;</span> strCommonPrograms
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span>
&nbsp;
<span style="color: #0600FF;">Sub</span> PredeployOracleCABFiles
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
<span style="color: #008080; font-style: italic;">' Sub PredeployOracleCABFiles</span>
<span style="color: #008080; font-style: italic;">' Extracts all the cab files to C:\Windows\Downloaded Program Files.  </span>
<span style="color: #008080; font-style: italic;">' Then the files are registered. </span>
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
ShowHTA<span style="color: #000000;">&#40;</span>CurrentDir <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;step_7_predeploy.hta&quot;</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #FF8000;">Set</span> strFolderwithCABFiles <span style="color: #008000;">=</span> objFSO.<span style="color: #0000FF;">GetFolder</span><span style="color: #000000;">&#40;</span>strORACLE_HOME _ 
                            <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;\PUBLIC\enu\21219\APPLETS&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Set</span> arrCABFiles           <span style="color: #008000;">=</span> strFolderwithCABFiles.<span style="color: #008000;">Files</span>
strKeyPathDPF             <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;SOFTWARE\Microsoft\Windows\CurrentVersion&quot;</span> _ 
                            <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;\Internet Settings\ActiveX Cache&quot;</span>
strValueNameDPF           <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;0&quot;</span>
objReg.<span style="color: #0000FF;">GetStringValue</span> HKEY_LOCAL_MACHINE,strKeyPathDPF,strValueNameDPF,strValueDPF
WriteToLog <span style="color: #808080;">&quot;Folder for Downloaded Program Files is: &quot;</span> <span style="color: #008000;">&amp;</span> strValueDPF
&nbsp;
<span style="color: #FF8000;">For</span> <span style="color: #0600FF;">Each</span> objCABFile In arrCABFiles
  <span style="color: #0600FF;">If</span> <span style="color: #0600FF;">LCase</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Right</span><span style="color: #000000;">&#40;</span>objCABFile.<span style="color: #0000FF;">Name</span>,<span style="color: #FF0000;">4</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;.cab&quot;</span> <span style="color: #FF8000;">Then</span>
    strCommand <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;expand -f:*.* &quot;</span> <span style="color: #008000;">&amp;</span> strORACLE_HOME <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;\PUBLIC\enu\21219\APPLETS\&quot;</span> _ 
		             <span style="color: #008000;">&amp;</span> objCABFile.<span style="color: #0000FF;">Name</span> <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot; &quot;</span> <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> strValueDPF <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span>
    WriteToLog <span style="color: #808080;">&quot;Action: - Executing: objShell.Run &quot;</span> <span style="color: #008000;">&amp;</span> strCommand <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;,0,True&quot;</span>
    objShell.<span style="color: #0000FF;">Run</span> StrCommand,<span style="color: #FF0000;">0</span>,<span style="color: #0600FF;">True</span>
  <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
<span style="color: #FF8000;">Next</span>
&nbsp;
<span style="color: #FF8000;">Set</span> strFolderwithDPFiles <span style="color: #008000;">=</span> objFSO.<span style="color: #0000FF;">GetFolder</span><span style="color: #000000;">&#40;</span>strValueDPF<span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Set</span> arrDPFiles           <span style="color: #008000;">=</span> strFolderwithDPFiles.<span style="color: #008000;">Files</span>
WriteToLog <span style="color: #808080;">&quot;Action: -&gt; Registering or deleting the files in &quot;</span> <span style="color: #008000;">&amp;</span> strValueDPF
&nbsp;
<span style="color: #FF8000;">For</span> <span style="color: #0600FF;">Each</span> objDPFile In arrDPFiles
  strDPFile <span style="color: #008000;">=</span> <span style="color: #0600FF;">lcase</span><span style="color: #000000;">&#40;</span>objDPFile.<span style="color: #0000FF;">Name</span><span style="color: #000000;">&#41;</span>
  <span style="color: #0600FF;">If</span> <span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Left</span><span style="color: #000000;">&#40;</span>strDPFile,<span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">=</span><span style="color: #808080;">&quot;s&quot;</span> <span style="color: #804040;">AND</span> <span style="color: #0600FF;">Right</span><span style="color: #000000;">&#40;</span>strDPFile,<span style="color: #FF0000;">4</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">=</span><span style="color: #808080;">&quot;.dll&quot;</span><span style="color: #000000;">&#41;</span> OR _ 
     <span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Left</span><span style="color: #000000;">&#40;</span>strDPFile,<span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">=</span><span style="color: #808080;">&quot;s&quot;</span> <span style="color: #804040;">AND</span> <span style="color: #0600FF;">Right</span><span style="color: #000000;">&#40;</span>strDPFile,<span style="color: #FF0000;">4</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">=</span><span style="color: #808080;">&quot;.ocx&quot;</span><span style="color: #000000;">&#41;</span> OR _ 
     <span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Left</span><span style="color: #000000;">&#40;</span>strDPFile,<span style="color: #FF0000;">4</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">=</span><span style="color: #808080;">&quot;ieop&quot;</span> <span style="color: #804040;">AND</span> <span style="color: #0600FF;">Right</span><span style="color: #000000;">&#40;</span>strDPFile,<span style="color: #FF0000;">4</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">=</span><span style="color: #808080;">&quot;.dll&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
    strCommand <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;regsvr32 /s &quot;</span> <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> strValueDPF <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;\&quot;</span> <span style="color: #008000;">&amp;</span> strDPFile <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span>
    valResult  <span style="color: #008000;">=</span> objShell.<span style="color: #0000FF;">Run</span><span style="color: #000000;">&#40;</span>strCommand,<span style="color: #FF0000;">6</span>,<span style="color: #0600FF;">True</span><span style="color: #000000;">&#41;</span>
    <span style="color: #0600FF;">If</span> valResult <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span> <span style="color: #FF8000;">Then</span>
      WriteToLog <span style="color: #808080;">&quot;Action: 'objShell.Run(&quot;</span> <span style="color: #008000;">&amp;</span> strCommand <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;,6,True)' succeeded.&quot;</span>
    <span style="color: #FF8000;">Else</span>
      WriteToLog <span style="color: #808080;">&quot;Action: 'objShell.Run(&quot;</span> <span style="color: #008000;">&amp;</span> strCommand <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;,6,True)' failed.&quot;</span>
    <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
  <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
  <span style="color: #0600FF;">If</span> <span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Left</span><span style="color: #000000;">&#40;</span>strDPFile,<span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">=</span><span style="color: #808080;">&quot;s&quot;</span> <span style="color: #804040;">AND</span> <span style="color: #0600FF;">Right</span><span style="color: #000000;">&#40;</span>strDPFile,<span style="color: #FF0000;">4</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">=</span><span style="color: #808080;">&quot;.exe&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
    strCommand <span style="color: #008000;">=</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> strValueDPF <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;\&quot;</span> <span style="color: #008000;">&amp;</span> strDPFile <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">34</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot; /regserver&quot;</span>
    valResult  <span style="color: #008000;">=</span> objShell.<span style="color: #0000FF;">Run</span><span style="color: #000000;">&#40;</span>strCommand,<span style="color: #FF0000;">1</span>,<span style="color: #0600FF;">True</span><span style="color: #000000;">&#41;</span>
    <span style="color: #0600FF;">If</span> valResult <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span> <span style="color: #FF8000;">Then</span>
      WriteToLog <span style="color: #808080;">&quot;Action: 'objShell.Run(&quot;</span> <span style="color: #008000;">&amp;</span> strCommand <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;,6,True)' succeeded.&quot;</span>
    <span style="color: #FF8000;">Else</span>
      WriteToLog <span style="color: #808080;">&quot;Action: 'objShell.Run(&quot;</span> <span style="color: #008000;">&amp;</span> strCommand <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;,6,True)' failed.&quot;</span>
    <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
  <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
  <span style="color: #0600FF;">If</span> <span style="color: #0600FF;">Right</span><span style="color: #000000;">&#40;</span>strDPFile,<span style="color: #FF0000;">6</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">=</span><span style="color: #808080;">&quot;.class&quot;</span> <span style="color: #FF8000;">Then</span>
    objFSO.<span style="color: #0000FF;">DeleteFile</span> strValueDPF <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;\&quot;</span> <span style="color: #008000;">&amp;</span> strDPFile
    WriteToLog <span style="color: #808080;">&quot;Action: The file '&quot;</span> <span style="color: #008000;">&amp;</span> strValueDPF <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">92</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> strDPFile _ 
               <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;' has been deleted.&quot;</span>
  <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
<span style="color: #FF8000;">Next</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span>
&nbsp;
<span style="color: #0600FF;">Sub</span> PredeployOracleINFFiles
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
<span style="color: #008080; font-style: italic;">' Sub PredeployOracleINFFiles</span>
<span style="color: #008080; font-style: italic;">' Reads all the .inf files in C:\Windows\Downloaded Program Files. Finds the </span>
<span style="color: #008080; font-style: italic;">' dll file in the inf file</span>
<span style="color: #008080; font-style: italic;">' and then adds the registration in the registry.</span>
<span style="color: #008080; font-style: italic;">' ------------------------------------------------------------------------------</span>
strKeyPathDPF             <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;SOFTWARE\Microsoft\Windows\CurrentVersion&quot;</span> _ 
                            <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;\Internet Settings\ActiveX Cache&quot;</span>
strKeyPathModuleUsage     <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;SOFTWARE\Microsoft\Windows\CurrentVersion\ModuleUsage\&quot;</span>
strValueNameDPF           <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;0&quot;</span>
objReg.<span style="color: #0000FF;">GetStringValue</span> HKEY_LOCAL_MACHINE,strKeyPathDPF,strValueNameDPF,strValueDPF
WriteToLog <span style="color: #808080;">&quot;Folder for Downloaded Program Files is: &quot;</span> <span style="color: #008000;">&amp;</span> strValueDPF
&nbsp;
<span style="color: #FF8000;">Set</span> strFolderwithINFFiles <span style="color: #008000;">=</span> objFSO.<span style="color: #0000FF;">GetFolder</span><span style="color: #000000;">&#40;</span>strValueDPF<span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Set</span> arrINFFiles           <span style="color: #008000;">=</span> strFolderwithINFFiles.<span style="color: #008000;">Files</span>
WriteToLog <span style="color: #808080;">&quot;Action: -&gt; Processing the INF files in &quot;</span> <span style="color: #008000;">&amp;</span> strValueDPF
&nbsp;
<span style="color: #FF8000;">For</span> <span style="color: #0600FF;">Each</span> objINFFile In arrINFFiles
  strINFFile <span style="color: #008000;">=</span> <span style="color: #0600FF;">LCase</span><span style="color: #000000;">&#40;</span>objINFFile.<span style="color: #0000FF;">Name</span><span style="color: #000000;">&#41;</span>
  <span style="color: #0600FF;">If</span> <span style="color: #0600FF;">Right</span><span style="color: #000000;">&#40;</span>strINFFile,<span style="color: #FF0000;">4</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;.inf&quot;</span> <span style="color: #FF8000;">Then</span>
    strINFFile <span style="color: #008000;">=</span> strValueDPF <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;\&quot;</span> <span style="color: #008000;">&amp;</span> strINFFile
    WriteToLog <span style="color: #808080;">&quot;Action: -&gt; Processing INF File: &quot;</span> <span style="color: #008000;">&amp;</span> strINFFile
    <span style="color: #FF8000;">Set</span> objINFFileToRead <span style="color: #008000;">=</span> objFSO.<span style="color: #0000FF;">OpenTextFile</span><span style="color: #000000;">&#40;</span>strINFFile, <span style="color: #0600FF;">ForReading</span>, <span style="color: #0600FF;">False</span><span style="color: #000000;">&#41;</span>
    <span style="color: #0600FF;">Do</span> <span style="color: #0600FF;">While</span> <span style="color: #804040;">NOT</span> objINFFileToRead.<span style="color: #0000FF;">AtEndOfStream</span>
      strLine <span style="color: #008000;">=</span> <span style="color: #0600FF;">Trim</span><span style="color: #000000;">&#40;</span>objINFFileToRead.<span style="color: #0000FF;">ReadLine</span><span style="color: #000000;">&#41;</span>
      strLine <span style="color: #008000;">=</span> <span style="color: #0600FF;">lcase</span><span style="color: #000000;">&#40;</span>strLine<span style="color: #000000;">&#41;</span>
      <span style="color: #0600FF;">If</span> <span style="color: #0600FF;">Left</span><span style="color: #000000;">&#40;</span>strLine,<span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;[&quot;</span> <span style="color: #804040;">AND</span> <span style="color: #0600FF;">Right</span><span style="color: #000000;">&#40;</span>strLine,<span style="color: #FF0000;">5</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">=</span><span style="color: #808080;">&quot;.dll]&quot;</span> <span style="color: #FF8000;">Then</span>
        strDLLFileName      <span style="color: #008000;">=</span> strLine
        <span style="color: #008080; font-style: italic;">' Remove first '['</span>
        strDLLFileName      <span style="color: #008000;">=</span> <span style="color: #0600FF;">Right</span><span style="color: #000000;">&#40;</span>strDLLFileName,<span style="color: #FF8000;">Len</span><span style="color: #000000;">&#40;</span>strDLLFileName<span style="color: #000000;">&#41;</span><span style="color: #008000;">-</span><span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span>
        <span style="color: #008080; font-style: italic;">' Remove last ']'</span>
        strDLLFileName      <span style="color: #008000;">=</span> <span style="color: #0600FF;">Left</span> <span style="color: #000000;">&#40;</span>strDLLFileName,<span style="color: #FF8000;">Len</span><span style="color: #000000;">&#40;</span>strDLLFileName<span style="color: #000000;">&#41;</span><span style="color: #008000;">-</span><span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span>
        WriteToLog <span style="color: #808080;">&quot;Action: -&gt; Found dll file &quot;</span> <span style="color: #008000;">&amp;</span> strDLLFileName <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot; in &quot;</span> _ 
                   <span style="color: #008000;">&amp;</span> strINFFile <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;.&quot;</span>
        strDLLFileName <span style="color: #008000;">=</span> strValueDPF <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">Chr</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">92</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> strDLLFileName
      <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
      <span style="color: #0600FF;">If</span> <span style="color: #0600FF;">Left</span><span style="color: #000000;">&#40;</span>strLine,<span style="color: #FF0000;">5</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;clsid&quot;</span> <span style="color: #FF8000;">Then</span>
        arrCLSID <span style="color: #008000;">=</span> <span style="color: #0600FF;">Split</span><span style="color: #000000;">&#40;</span>strLine,<span style="color: #808080;">&quot;=&quot;</span><span style="color: #000000;">&#41;</span>
        strCLSID <span style="color: #008000;">=</span> arrCLSID<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span>
        WriteToLog <span style="color: #808080;">&quot;Action: -&gt; Found CLSID &quot;</span> <span style="color: #008000;">&amp;</span> strCLSID  <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot; in &quot;</span> <span style="color: #008000;">&amp;</span> strINFFile <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;.&quot;</span>
      <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
      strDLLFileName <span style="color: #008000;">=</span> <span style="color: #0600FF;">replace</span><span style="color: #000000;">&#40;</span>strDLLFileName, <span style="color: #808080;">&quot;\&quot;</span>,<span style="color: #808080;">&quot;/&quot;</span><span style="color: #000000;">&#41;</span>
      objReg.<span style="color: #0000FF;">CreateKey</span> HKEY_LOCAL_MACHINE,strKeyPathModuleUsage <span style="color: #008000;">&amp;</span> strDLLFileName
      WriteToLog <span style="color: #808080;">&quot;Action: -&gt; Created registry key: HKEY_LOCAL_MACHINE\&quot;</span> _ 
                 <span style="color: #008000;">&amp;</span> strKeyPathModuleUsage <span style="color: #008000;">&amp;</span> strDLLFileName
      objReg.<span style="color: #0000FF;">SetStringValue</span> HKEY_LOCAL_MACHINE,strKeyPathModuleUsage _ 
      <span style="color: #008000;">&amp;</span> strDLLFileName , <span style="color: #808080;">&quot;.Owner&quot;</span> , strCLSID
      WriteToLog <span style="color: #808080;">&quot;Action: -&gt; Created hive '.Owner' with value &quot;</span> <span style="color: #008000;">&amp;</span> strCLSID _ 
                 <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot; in HKEY_LOCAL_MACHINE\&quot;</span> <span style="color: #008000;">&amp;</span> strKeyPathModuleUsage <span style="color: #008000;">&amp;</span> strDLLFileName
      objReg.<span style="color: #0000FF;">SetStringValue</span> HKEY_LOCAL_MACHINE,strKeyPathModuleUsage _ 
      <span style="color: #008000;">&amp;</span> strDLLFileName , strCLSID , <span style="color: #808080;">&quot;&quot;</span>
      WriteToLog <span style="color: #808080;">&quot;Action: -&gt; Created hive '&quot;</span> <span style="color: #008000;">&amp;</span> strCLSID _ 
                 <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;' with an empty value in HKEY_LOCAL_MACHINE\&quot;</span> _ 
                 <span style="color: #008000;">&amp;</span> strKeyPathModuleUsage <span style="color: #008000;">&amp;</span> strDLLFileName
    <span style="color: #0600FF;">Loop</span>
  <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
<span style="color: #FF8000;">Next</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.hican.net/2012/01/17/vbscript-install-oracle-webclient-kill-predeploy-htm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell: Create Active Directory Users Based On Excel Input</title>
		<link>http://www.hican.net/2011/12/23/powershell-create-active-directory-users-based-on-excel-input/</link>
		<comments>http://www.hican.net/2011/12/23/powershell-create-active-directory-users-based-on-excel-input/#comments</comments>
		<pubDate>Fri, 23 Dec 2011 09:42:40 +0000</pubDate>
		<dc:creator>hicannet</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[Microsoft]]></category>

		<guid isPermaLink="false">http://www.hican.net/?p=125</guid>
		<description><![CDATA[<p>The last script / message just before I leave on a 2 week skiing holiday! Sooo, make good use of this, because you won&#8217;t hear from me earlier than the 8th or 9th of January <br /> <br /> About the script now. This script will create users in Active Directory based on the settings in the input file (see the Excel / CSV file below this script for an example of the input file used). These settings can, of  <a href="http://www.hican.net/2011/12/23/powershell-create-active-directory-users-based-on-excel-input/" class="continueRead" >Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>The last script / message just before I leave on a 2 week skiing holiday! Sooo, make good use of this, because you won&#8217;t hear from me earlier than the 8th or 9th of January <img src='http://www.hican.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
<br />
About the script now. This script will create users in Active Directory based on the settings in the input file (see the Excel / CSV file below this script for an example of the input file used). These settings can, of course, be changed or extended (check this <a href="http://technet.microsoft.com/en-us/library/ee617253.aspx" title="PowerShell New-ADUser Cmdlet">Microsoft Technet Link</a> to get an overview of all the settings that can be set with the PowerShell New-ADUser Cmdlet).<br />
<br />
Not only can the file be extended (or decreased) it can also be altered. The column names can be changed (note that you also need to change it in the PowerShell script), the columns can be re-ordered, etc. The script will keep working, because it uses the column names!<br />
<br />
<strong>Note #1:</strong> This script makes use of the Active Directory Module for PowerShell.<br />
<strong>Note #2:</strong> Feel free to <a href="http://www.hican.net/contact/" title="Contact | Hican.net">contact</a> me if anything isn&#8217;t clear, doesn&#8217;t work or to see something changed.<br />
<br />
<strong>create_ad_users.ps1</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
</pre></td><td class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008000;">#######################################################</span>
<span style="color: #008000;"># AUTHOR  : http://www.hican.net - @hicannet</span>
<span style="color: #008000;"># DATE    : 28-11-2011</span>
<span style="color: #008000;"># COMMENT : This script creates new Active Directory users</span>
<span style="color: #008000;">#           including different kind of properties based</span>
<span style="color: #008000;">#           on an input_create_ad_users.csv.</span>
Import<span style="color: pink;">-</span>Module ActiveDirectory
<span style="color: #008000;"># Get current directory and set import file in variable</span>
<span style="color: #800080;">$path</span>     <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">Split-Path</span> <span style="color: #008080; font-style: italic;">-parent</span> <span style="color: #800080;">$MyInvocation</span>.MyCommand.Definition
<span style="color: #800080;">$newpath</span>  <span style="color: pink;">=</span> <span style="color: #800080;">$path</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot;\import_create_ad_users.csv&quot;</span>
<span style="color: #008000;"># Define variables</span>
<span style="color: #800080;">$log</span>      <span style="color: pink;">=</span> <span style="color: #800080;">$path</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot;\create_ad_users.log&quot;</span>
<span style="color: #800080;">$date</span>     <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">Get-Date</span>
<span style="color: #800080;">$i</span>        <span style="color: pink;">=</span> <span style="color: #804000;">0</span>
<span style="color: #008000;"># Change this to the location you want the users to be created in your AD</span>
<span style="color: #800080;">$location</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;OU=Test,OU=Users,DC=hican,DC=net&quot;</span>
<span style="color: #008000;"># FUNCTIONS</span>
<span style="color: #0000FF;">Function</span> createUsers
<span style="color: #000000;">&#123;</span>
  <span style="color: #800000;">&quot;Created following users (on &quot;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$date</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot;): &quot;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Out<span style="color: #FF0000;">-File</span></span> <span style="color: #800080;">$log</span> <span style="color: #008080; font-style: italic;">-append</span>
  <span style="color: #800000;">&quot;--------------------------------------------&quot;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Out<span style="color: #FF0000;">-File</span></span> <span style="color: #800080;">$log</span> <span style="color: #008080; font-style: italic;">-append</span>
  <span style="color: #008080; font-weight: bold;">Import-CSV</span> <span style="color: #800080;">$newpath</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">ForEach-Object</span> <span style="color: #000000;">&#123;</span> 
    <span style="color: #008000;"># A check for the country, because those were full names and need </span>
    <span style="color: #008000;"># to be landcodes in order for AD to accept them. I used Netherlands </span>
    <span style="color: #008000;"># as example</span>
    <span style="color: #0000FF;">If</span><span style="color: #000000;">&#40;</span><span style="color: #000080;">$_</span>.CO <span style="color: #FF0000;">-eq</span> <span style="color: #800000;">&quot;Netherlands&quot;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
      <span style="color: #000080;">$_</span>.CO <span style="color: pink;">=</span> <span style="color: #800000;">&quot;NL&quot;</span>
    <span style="color: #000000;">&#125;</span>
    <span style="color: #008000;"># Replace dots / points (.) in names, because AD will error when a </span>
    <span style="color: #008000;"># name ends with a dot (and it looks cleaner as well)</span>
    <span style="color: #800080;">$replace</span> <span style="color: pink;">=</span> <span style="color: #000080;">$_</span>.CN.Replace<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;.&quot;</span><span style="color: pink;">,</span><span style="color: #800000;">&quot;&quot;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #0000FF;">If</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$replace</span>.length <span style="color: #FF0000;">-lt</span> <span style="color: #804000;">4</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
      <span style="color: #800080;">$lastname</span> <span style="color: pink;">=</span> <span style="color: #800080;">$replace</span>
    <span style="color: #000000;">&#125;</span>
    <span style="color: #0000FF;">Else</span>
    <span style="color: #000000;">&#123;</span>
      <span style="color: #800080;">$lastname</span> <span style="color: pink;">=</span> <span style="color: #800080;">$replace</span>.substring<span style="color: #000000;">&#40;</span><span style="color: #804000;">0</span><span style="color: pink;">,</span><span style="color: #804000;">4</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#125;</span>
    <span style="color: #008000;"># Create sAMAccountName according to this 'naming convention':</span>
    <span style="color: #008000;"># &lt;FirstLetterInitials&gt;&lt;FirstFourLettersLastName&gt; for example</span>
    <span style="color: #008000;"># hhica</span>
    <span style="color: #800080;">$sam</span> <span style="color: pink;">=</span> <span style="color: #000080;">$_</span>.Initials.substring<span style="color: #000000;">&#40;</span><span style="color: #804000;">0</span><span style="color: pink;">,</span><span style="color: #804000;">1</span><span style="color: #000000;">&#41;</span>.ToLower<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$lastname</span>.ToLower<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
    Try   <span style="color: #000000;">&#123;</span> <span style="color: #800080;">$exists</span> <span style="color: pink;">=</span> Get<span style="color: pink;">-</span>ADUser <span style="color: pink;">-</span>LDAPFilter <span style="color: #800000;">&quot;(sAMAccountName=$sam)&quot;</span> <span style="color: #000000;">&#125;</span>
    Catch <span style="color: #000000;">&#123;</span> <span style="color: #000000;">&#125;</span>
    <span style="color: #0000FF;">If</span><span style="color: #000000;">&#40;</span><span style="color: pink;">!</span><span style="color: #800080;">$exists</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
      <span style="color: #800080;">$i</span><span style="color: pink;">++</span>
      <span style="color: #008000;"># Set all variables according to the table names in the Excel </span>
      <span style="color: #008000;"># sheet / import CSV. The names can differ in every project, but </span>
      <span style="color: #008000;"># if the names change, make sure to change it below as well.</span>
      <span style="color: #800080;">$setpass</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">ConvertTo-SecureString</span> <span style="color: #008080; font-style: italic;">-AsPlainText</span> <span style="color: #000080;">$_</span>.Password <span style="color: #008080; font-style: italic;">-force</span>
      New<span style="color: pink;">-</span>ADUser <span style="color: #800080;">$sam</span> <span style="color: pink;">-</span>GivenName <span style="color: #000080;">$_</span>.GivenName <span style="color: pink;">-</span>Initials <span style="color: #000080;">$_</span>.Initials ` 
      <span style="color: pink;">-</span>Surname <span style="color: #000080;">$_</span>.SN <span style="color: #008080; font-style: italic;">-DisplayName</span> <span style="color: #000080;">$_</span>.DisplayName <span style="color: pink;">-</span>Office <span style="color: #000080;">$_</span>.OfficeName `
      <span style="color: #008080; font-style: italic;">-Description</span> <span style="color: #000080;">$_</span>.Description <span style="color: pink;">-</span>EmailAddress <span style="color: #000080;">$_</span>.Mail ` 
      <span style="color: pink;">-</span>StreetAddress <span style="color: #000080;">$_</span>.StreetAddress <span style="color: pink;">-</span>City <span style="color: #000080;">$_</span>.L `
      <span style="color: pink;">-</span>PostalCode <span style="color: #000080;">$_</span>.PostalCode <span style="color: pink;">-</span>Country <span style="color: #000080;">$_</span>.CO <span style="color: pink;">-</span>UserPrincipalName <span style="color: #000080;">$_</span>.UPN ` 
      <span style="color: pink;">-</span>Company <span style="color: #000080;">$_</span>.Company <span style="color: pink;">-</span>Department <span style="color: #000080;">$_</span>.Department <span style="color: pink;">-</span>EmployeeID <span style="color: #000080;">$_</span>.ID ` 
      <span style="color: #008080; font-style: italic;">-Title</span> <span style="color: #000080;">$_</span>.Title <span style="color: pink;">-</span>OfficePhone <span style="color: #000080;">$_</span>.Phone <span style="color: pink;">-</span>AccountPassword <span style="color: #800080;">$setpass</span>
&nbsp;
      <span style="color: #008000;"># Set an ExtensionAttribute</span>
      <span style="color: #800080;">$dn</span>  <span style="color: pink;">=</span> <span style="color: #000000;">&#40;</span>Get<span style="color: pink;">-</span>ADUser <span style="color: #800080;">$sam</span><span style="color: #000000;">&#41;</span>.DistinguishedName
      <span style="color: #800080;">$ext</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>ADSI<span style="color: #000000;">&#93;</span><span style="color: #800000;">&quot;LDAP://$dn&quot;</span>
      <span style="color: #800080;">$ext</span>.Put<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;extensionAttribute1&quot;</span><span style="color: pink;">,</span> <span style="color: #000080;">$_</span>.ExtensionAttribute1<span style="color: #000000;">&#41;</span>
      <span style="color: #800080;">$ext</span>.SetInfo<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
&nbsp;
      <span style="color: #008000;"># Move the user to the OU you set above. If you don't want to</span>
      <span style="color: #008000;"># move the user(s) and just create them in the global Users</span>
      <span style="color: #008000;"># OU, comment the string below</span>
      Move<span style="color: pink;">-</span>ADObject <span style="color: pink;">-</span>Identity <span style="color: #800080;">$dn</span> <span style="color: pink;">-</span>TargetPath <span style="color: #800080;">$location</span>
&nbsp;
      <span style="color: #008000;"># Rename the object to a good looking name (otherwise you see</span>
      <span style="color: #008000;"># the 'ugly' shortened sAMAccountNames as a name in AD. This </span>
      <span style="color: #008000;"># can't be set right away (as sAMAccountName) due to the 20</span>
      <span style="color: #008000;"># character restriction</span>
      <span style="color: #800080;">$newdn</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#40;</span>Get<span style="color: pink;">-</span>ADUser <span style="color: #800080;">$sam</span><span style="color: #000000;">&#41;</span>.DistinguishedName
      Rename<span style="color: pink;">-</span>ADObject <span style="color: pink;">-</span>Identity <span style="color: #800080;">$newdn</span> <span style="color: #008080; font-style: italic;">-NewName</span> <span style="color: #000080;">$_</span>.CN
&nbsp;
      <span style="color: #800080;">$output</span>  <span style="color: pink;">=</span> <span style="color: #800080;">$i</span>.ToString<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot;) Name: &quot;</span> <span style="color: pink;">+</span> <span style="color: #000080;">$_</span>.CN <span style="color: pink;">+</span> <span style="color: #800000;">&quot;  sAMAccountName: &quot;</span> 
      <span style="color: #800080;">$output</span> <span style="color: pink;">+=</span> <span style="color: #800080;">$sam</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot;  Pass: &quot;</span> <span style="color: pink;">+</span> <span style="color: #000080;">$_</span>.Password
      <span style="color: #800080;">$output</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Out<span style="color: #FF0000;">-File</span></span> <span style="color: #800080;">$log</span> <span style="color: #008080; font-style: italic;">-append</span>
    <span style="color: #000000;">&#125;</span>
    <span style="color: #0000FF;">Else</span>
    <span style="color: #000000;">&#123;</span>
      <span style="color: #800000;">&quot;SKIPPED - ALREADY EXISTS OR ERROR: &quot;</span> <span style="color: pink;">+</span> <span style="color: #000080;">$_</span>.CN <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Out<span style="color: #FF0000;">-File</span></span> <span style="color: #800080;">$log</span> <span style="color: #008080; font-style: italic;">-append</span>
    <span style="color: #000000;">&#125;</span>
  <span style="color: #000000;">&#125;</span>
  <span style="color: #800000;">&quot;----------------------------------------&quot;</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot;<span style="color: #008080; font-weight: bold;">`n</span>&quot;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Out<span style="color: #FF0000;">-File</span></span> <span style="color: #800080;">$log</span> <span style="color: #008080; font-style: italic;">-append</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #008000;"># RUN SCRIPT</span>
createUsers
<span style="color: #008000;">#Finished</span></pre></td></tr></table></div>

<p>
In the Excel file / Input CSV the following (general) structure was used (the values are example values).<br />
<br />
<strong>import_create_ad_users.csv</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008000;"># LINE1 (the table headings in the Excel)</span>
&nbsp;
<span style="color: #008000;"># Already_In_AD,CN,GivenName,Initials,SN,DisplayName,OfficeName,</span>
<span style="color: #008000;"># Description,Mail,StreetAddress,L,PostalCode,</span>
<span style="color: #008000;"># CO,UPN,Title-i,Company,Department,ID,ExtensionAttribute1,Title,</span>
<span style="color: #008000;"># Phone,Manager,Password</span>
&nbsp;
<span style="color: #008000;"># LINE2 (first entry, all other entries look the same. As you can see</span>
<span style="color: #008000;"># there are also tables which aren't used, but are no problem for</span>
<span style="color: #008000;"># the script to work!</span>
&nbsp;
<span style="color: #008000;"># NO,Net.Hican,Hican,H.,Net,&quot;Net, H. - Hican -&quot;,Hican Building,</span>
<span style="color: #008000;"># Hican Net,info@hican.net,Hicanstreet 1,Hicancity,1337,</span>
<span style="color: #008000;"># Netherlands,info@hican,i-CEO,Hican.net,*,HIC1337,Staff,CEO,</span>
<span style="color: #008000;"># +0000000000,,IDDQD</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.hican.net/2011/12/23/powershell-create-active-directory-users-based-on-excel-input/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell: Migrate Active Directory Group Memberships Between Global Groups</title>
		<link>http://www.hican.net/2011/12/19/powershell-migrate-active-directory-group-memberships-between-global-groups/</link>
		<comments>http://www.hican.net/2011/12/19/powershell-migrate-active-directory-group-memberships-between-global-groups/#comments</comments>
		<pubDate>Mon, 19 Dec 2011 12:21:33 +0000</pubDate>
		<dc:creator>hicannet</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Active Directory]]></category>

		<guid isPermaLink="false">http://www.hican.net/?p=116</guid>
		<description><![CDATA[<p>During one of my projects at a customer the Active Directory setup needed to change. In this particular AD, they had defined Job Titles (Global Groups) in a Job Title OU. Specific Application Groups were members of these Job Titles to make sure that people who were in any of those Job Titles got the applications they needed to do their jobs.<br /> <br /> Along the way it was decided that these Job Titles didn&#8217;t fit the purpose anymore  <a href="http://www.hican.net/2011/12/19/powershell-migrate-active-directory-group-memberships-between-global-groups/" class="continueRead" >Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>During one of my projects at a customer the Active Directory setup needed to change. In this particular AD, they had defined Job Titles (Global Groups) in a Job Title OU. Specific Application Groups were members of these Job Titles to make sure that people who were in any of those Job Titles got the applications they needed to do their jobs.<br />
<br />
Along the way it was decided that these Job Titles didn&#8217;t fit the purpose anymore and a decision was made to use Job Profiles instead. This caused quite an extreme reduction of (Global) Groups in AD (approximately from 350+ per country OU to 12+).<br />
<br />
In order to make the Job Title applications available to the matching profiles, a AD Group Migration had to be done. I decided to do that in Powershell (without any knowledge <img src='http://www.hican.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ) instead of <a href="http://www.hican.net/category/vbscript/" title="Hican.net | VBScript Collection">VBScript</a> this time. Below is the result which, I am sure, can be written shorter and more logical, but it&#8217;s a start.<br />
<br />
The script makes use of an input.csv which contained a &#8216;translation table&#8217; to match the new Profile Groups with the old Job Title Groups.<br />
<br />
<strong>Note #1:</strong> This is part one of a batch of 6 scripts. The other scripts will be posted later on, since some are still under development and all scripts can be run separately.<br />
<strong>Note #2:</strong> This script makes use of the Active Directory Module for PowerShell.<br />
<br />
<strong>migrate_ad_group_membership.ps1</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
</pre></td><td class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008000;">#######################################################</span>
<span style="color: #008000;"># AUTHOR  : http://www.hican.net - @hicannet</span>
<span style="color: #008000;"># DATE    : 24-11-2011</span>
<span style="color: #008000;"># COMMENT : This script populates the new RBAC Profile </span>
<span style="color: #008000;">#           groups with all the applications that can /</span>
<span style="color: #008000;">#           need to be linked to these groups (based </span>
<span style="color: #008000;">#           upon the RBAC JobTitle groups).</span>
<span style="color: #008000;">#######################################################</span>
Import<span style="color: pink;">-</span>Module ActiveDirectory
<span style="color: #008000;"># Dynamic fill of the input Array</span>
<span style="color: #008000;"># The input.csv looks like this (groups names without country code):</span>
<span style="color: #008000;"># &lt;JOB_TITLE_GROUP_NAME&gt;,&lt;NEW_PROFILE_GROUP_NAME&gt;</span>
<span style="color: #008000;"># &lt;JOB_TITLE_GROUP_NAME&gt;,&lt;NEW_PROFILE_GROUP_NAME&gt;</span>
<span style="color: #800080;">$path</span>     <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">Split-Path</span> <span style="color: #008080; font-style: italic;">-parent</span> <span style="color: #800080;">$MyInvocation</span>.MyCommand.Definition
<span style="color: #800080;">$path</span>     <span style="color: pink;">=</span> <span style="color: #800080;">$path</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot;\input.csv&quot;</span>
<span style="color: #800080;">$groups</span>   <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">Get-Content</span> <span style="color: #800080;">$path</span>
<span style="color: #008000;"># Country code array (due to the complexity of the AD OU structure)</span>
<span style="color: #800080;">$country</span>  <span style="color: pink;">=</span> <span style="color: #800000;">&quot;&lt;COUNTRY_OU_01&gt;&quot;</span><span style="color: pink;">,</span><span style="color: #800000;">&quot;&lt;COUNTRY_OU_02&gt;&quot;</span><span style="color: pink;">,</span><span style="color: #800000;">&quot;&lt;COUNTRY_OU_03&gt;&quot;</span>
<span style="color: #008000;"># FUNCTIONS</span>
<span style="color: #0000FF;">Function</span> populateRBACProfiles
<span style="color: #000000;">&#123;</span>
  <span style="color: #008000;"># Loop through all countries in the $country array</span>
  <span style="color: #0000FF;">Foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$cntry</span> <span style="color: #0000FF;">In</span> <span style="color: #800080;">$country</span><span style="color: #000000;">&#41;</span>
  <span style="color: #000000;">&#123;</span>
    <span style="color: #800080;">$rbacs</span> <span style="color: pink;">=</span> Get<span style="color: pink;">-</span>ADGroup <span style="color: pink;">-</span><span style="color: #0000FF;">Filter</span> <span style="color: pink;">*</span> <span style="color: pink;">-</span>SearchBase <span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;OU=RBAC Title Groups,OU=&quot;</span><span style="color: pink;">+</span><span style="color: #800080;">$cntry</span><span style="color: pink;">+</span><span style="color: #800000;">&quot;,OU=Groups,DC=hican,DC=net&quot;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #0000FF;">Foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$group</span> <span style="color: #0000FF;">In</span> <span style="color: #800080;">$groups</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
      <span style="color: #008000;"># Split the values of the input.csv and rename to match the projects AD.</span>
      <span style="color: #800080;">$split</span>   <span style="color: pink;">=</span> <span style="color: #800080;">$group</span>.split<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;,&quot;</span><span style="color: #000000;">&#41;</span>
      <span style="color: #800080;">$string</span>  <span style="color: pink;">=</span> <span style="color: #800080;">$cntry</span><span style="color: pink;">+</span><span style="color: #800000;">&quot;-GG.RBAC.&quot;</span><span style="color: pink;">+</span><span style="color: #800080;">$split</span><span style="color: #000000;">&#91;</span><span style="color: #804000;">0</span><span style="color: #000000;">&#93;</span>
      <span style="color: #800080;">$stringN</span> <span style="color: pink;">=</span> <span style="color: #800080;">$cntry</span><span style="color: pink;">+</span><span style="color: #800000;">&quot;-GG.&quot;</span><span style="color: pink;">+</span><span style="color: #800080;">$split</span><span style="color: #000000;">&#91;</span><span style="color: #804000;">1</span><span style="color: #000000;">&#93;</span>
      <span style="color: #0000FF;">Foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$rbac</span> <span style="color: #0000FF;">In</span> <span style="color: #800080;">$rbacs</span><span style="color: #000000;">&#41;</span>
      <span style="color: #000000;">&#123;</span>
        <span style="color: #0000FF;">If</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$string</span> <span style="color: #FF0000;">-eq</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$rbac</span> <span style="color: pink;">|</span> <span style="color: pink;">%</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.Name<span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
          <span style="color: #800080;">$apps</span> <span style="color: pink;">=</span> Get<span style="color: pink;">-</span>ADGroup <span style="color: pink;">-</span>Identity <span style="color: #800080;">$string</span> <span style="color: pink;">-</span>Properties memberof <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Select</span> <span style="color: #008080; font-style: italic;">-expandproperty</span> memberof
          <span style="color: #0000FF;">Foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$app</span> <span style="color: #0000FF;">In</span> <span style="color: #800080;">$apps</span><span style="color: #000000;">&#41;</span>
          <span style="color: #000000;">&#123;</span>
            <span style="color: #0000FF;">If</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$app</span><span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
              <span style="color: #008000;"># Trap any errors</span>
              Try   <span style="color: #000000;">&#123;</span> <span style="color: #800080;">$exists</span> <span style="color: pink;">=</span> Get<span style="color: pink;">-</span>ADGroupMember <span style="color: #800080;">$app</span> <span style="color: pink;">|</span> <span style="color: pink;">%</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.Name<span style="color: #000000;">&#125;</span> <span style="color: #000000;">&#125;</span>
              Catch <span style="color: #000000;">&#123;</span> <span style="color: #000000;">&#125;</span>
              <span style="color: #008000;"># If they match and are existant, add them to the appropriate RBAC Profile Group (mentioned in the input.csv)</span>
              <span style="color: #0000FF;">If</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$exists</span> <span style="color: #FF0000;">-notcontains</span> <span style="color: #800080;">$stringN</span><span style="color: #000000;">&#41;</span>
              <span style="color: #000000;">&#123;</span>
                Add<span style="color: pink;">-</span>ADGroupMember <span style="color: #800080;">$app</span> <span style="color: #800080;">$stringN</span> <span style="color: #008080; font-style: italic;">-Confirm</span>:<span style="color: #800080;">$false</span>
              <span style="color: #000000;">&#125;</span>
            <span style="color: #000000;">&#125;</span>
          <span style="color: #000000;">&#125;</span>
        <span style="color: #000000;">&#125;</span>
      <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
  <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #008000;"># RUN SCRIPT</span>
populateRBACProfiles
<span style="color: #800000;">&quot;SCRIPT FINISHED&quot;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.hican.net/2011/12/19/powershell-migrate-active-directory-group-memberships-between-global-groups/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VBScript: Output Active Directory User Information To Excel</title>
		<link>http://www.hican.net/2011/12/14/vbscript-output-active-directory-user-information-to-excel/</link>
		<comments>http://www.hican.net/2011/12/14/vbscript-output-active-directory-user-information-to-excel/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 13:07:56 +0000</pubDate>
		<dc:creator>hicannet</dc:creator>
				<category><![CDATA[VBScript]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Excel]]></category>

		<guid isPermaLink="false">http://www.hican.net/?p=110</guid>
		<description><![CDATA[<p>During a project I was asked to create reports about specific Active Directory values of all the users / members in a specific (application) group. I am quite sure that this script can be written in less code (especially in Powershell), but it does the trick.<br /> <br /> It first checks the &#8216;base&#8217; of the group you are targeting and reads all the members of that group. It then recursively retrieves all the members of any sub / linked  <a href="http://www.hican.net/2011/12/14/vbscript-output-active-directory-user-information-to-excel/" class="continueRead" >Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>During a project I was asked to create reports about specific Active Directory values of all the users / members in a specific (application) group. I am quite sure that this script can be written in less code (especially in Powershell), but it does the trick.<br />
<br />
It first checks the &#8216;base&#8217; of the group you are targeting and reads all the members of that group. It then recursively retrieves all the members of any sub / linked groups. All these results are written to a nice defined Excel sheet to handout to your Projectleader, Manager or whatever <img src='http://www.hican.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
<br />
If you want to add more (default) LDAP properties to the report, you can use the following link to look them up:<br />
<br />
- <a href="http://www.computerperformance.co.uk/Logon/LDAP_attributes_active_directory.htm" title="LDAP Properties">LDAP Properties</a><br />
<br />
<strong>create_group_report.vbs</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
</pre></td><td class="code"><pre class="vbnet" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">'''''''''''''''''''''''''''''''''''''''''''''''''''''''</span>
<span style="color: #008080; font-style: italic;">' AUTHOR  : http://www.hican.net - @hicannet</span>
<span style="color: #008080; font-style: italic;">' DATE    : 23-03-2011</span>
<span style="color: #008080; font-style: italic;">' COMMENT : This script creates an Excel with </span>
<span style="color: #008080; font-style: italic;">'           different kind of information about all</span>
<span style="color: #008080; font-style: italic;">'           the users / members of a specific AD Group.</span>
<span style="color: #008080; font-style: italic;">'''''''''''''''''''''''''''''''''''''''''''''''''''''''</span>
<span style="color: #FF8000;">Option</span> Explicit
&nbsp;
<span style="color: #0600FF;">Const</span> xlContinuous <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span>
<span style="color: #0600FF;">Const</span> xlThin       <span style="color: #008000;">=</span> <span style="color: #FF0000;">2</span>
&nbsp;
<span style="color: #0600FF;">Dim</span> objExcel, objWorkbook, objWorksheet
<span style="color: #0600FF;">Dim</span> objCommand, objRecordSet, objConnection
<span style="color: #0600FF;">Dim</span> objMember, sGroupDN, sTargetGroupDN, objGroup
<span style="color: #0600FF;">Dim</span> intRow, sCount, sOutputFile, objUAC
&nbsp;
<span style="color: #FF8000;">Set</span> objConnection      <span style="color: #008000;">=</span> <span style="color: #0600FF;">CreateObject</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;ADODB.Connection&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Set</span> objCommand         <span style="color: #008000;">=</span> <span style="color: #0600FF;">CreateObject</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;ADODB.Command&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Set</span> objRecordSet       <span style="color: #008000;">=</span> <span style="color: #0600FF;">CreateObject</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;ADODB.Recordset&quot;</span><span style="color: #000000;">&#41;</span>
objConnection.<span style="color: #0000FF;">Provider</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;ADsDSOObject&quot;</span>
objConnection.<span style="color: #0600FF;">Open</span> <span style="color: #808080;">&quot;Active Directory Provider&quot;</span>
<span style="color: #FF8000;">Set</span> objCommand.<span style="color: #0000FF;">ActiveConnection</span> <span style="color: #008000;">=</span> objConnection
&nbsp;
<span style="color: #008080; font-style: italic;">'Give the LDAP DN / CN for a group here, for example:</span>
<span style="color: #008080; font-style: italic;">'LDAP://CN=TestGroup,OU=Groups,DC=hican,DC=net</span>
sTargetGroupDN   <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;&lt;GROUPNAME&gt;&quot;</span>
sOutputFile      <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;&lt;FILENAME.XLS&gt;&quot;</span>
&nbsp;
<span style="color: #FF8000;">Set</span> objExcel     <span style="color: #008000;">=</span> <span style="color: #0600FF;">CreateObject</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Excel.Application&quot;</span><span style="color: #000000;">&#41;</span>
objExcel.<span style="color: #0000FF;">Visible</span> <span style="color: #008000;">=</span> <span style="color: #0600FF;">True</span>
<span style="color: #FF8000;">Set</span> objWorkbook  <span style="color: #008000;">=</span> objExcel.<span style="color: #0000FF;">Workbooks</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Set</span> objWorksheet <span style="color: #008000;">=</span> objWorkbook.<span style="color: #0000FF;">Worksheets</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span>
intRow           <span style="color: #008000;">=</span> <span style="color: #FF0000;">2</span>
sCount           <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span>
&nbsp;
createUserList<span style="color: #000000;">&#40;</span>sTargetGroupDN<span style="color: #000000;">&#41;</span>
&nbsp;
objExcel.<span style="color: #0000FF;">Range</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;A1:H1&quot;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">autofilter</span>
objExcel.<span style="color: #0000FF;">Range</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;A1&quot;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0600FF;">Select</span>
objExcel.<span style="color: #0000FF;">ActiveWorkbook</span>.<span style="color: #0000FF;">SaveAs</span> sOutputFile
objExcel.<span style="color: #0000FF;">ActiveWorkbook</span>.<span style="color: #0600FF;">Close</span>
objExcel.<span style="color: #0000FF;">Application</span>.<span style="color: #0000FF;">Quit</span>
&nbsp;
Wscript.<span style="color: #0000FF;">Quit</span>
&nbsp;
<span style="color: #0600FF;">Function</span> createUserList<span style="color: #000000;">&#40;</span>sGroupDN<span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Set</span> objGroup <span style="color: #008000;">=</span> GetObject<span style="color: #000000;">&#40;</span>sGroupDN<span style="color: #000000;">&#41;</span>
&nbsp;
objWorksheet.<span style="color: #0000FF;">Cells</span><span style="color: #000000;">&#40;</span>sCount,<span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;sAMAccountName&quot;</span>
objWorksheet.<span style="color: #0000FF;">Cells</span><span style="color: #000000;">&#40;</span>sCount,<span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">BorderAround</span> xlContinuous, xlThin
objWorksheet.<span style="color: #0000FF;">Cells</span><span style="color: #000000;">&#40;</span>sCount,<span style="color: #FF0000;">2</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;First Name&quot;</span>
objWorksheet.<span style="color: #0000FF;">Cells</span><span style="color: #000000;">&#40;</span>sCount,<span style="color: #FF0000;">2</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">BorderAround</span> xlContinuous, xlThin
objWorksheet.<span style="color: #0000FF;">Cells</span><span style="color: #000000;">&#40;</span>sCount,<span style="color: #FF0000;">3</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Last Name&quot;</span>
objWorksheet.<span style="color: #0000FF;">Cells</span><span style="color: #000000;">&#40;</span>sCount,<span style="color: #FF0000;">3</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">BorderAround</span> xlContinuous, xlThin
objWorksheet.<span style="color: #0000FF;">Cells</span><span style="color: #000000;">&#40;</span>sCount,<span style="color: #FF0000;">4</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Employee Number&quot;</span>
objWorksheet.<span style="color: #0000FF;">Cells</span><span style="color: #000000;">&#40;</span>sCount,<span style="color: #FF0000;">4</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">BorderAround</span> xlContinuous, xlThin
objWorksheet.<span style="color: #0000FF;">Cells</span><span style="color: #000000;">&#40;</span>sCount,<span style="color: #FF0000;">5</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Email Address&quot;</span>
objWorksheet.<span style="color: #0000FF;">Cells</span><span style="color: #000000;">&#40;</span>sCount,<span style="color: #FF0000;">5</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">BorderAround</span> xlContinuous, xlThin
objWorksheet.<span style="color: #0000FF;">Cells</span><span style="color: #000000;">&#40;</span>sCount,<span style="color: #FF0000;">6</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;IP Telephone Number&quot;</span>
objWorksheet.<span style="color: #0000FF;">Cells</span><span style="color: #000000;">&#40;</span>sCount,<span style="color: #FF0000;">6</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">BorderAround</span> xlContinuous, xlThin
objWorksheet.<span style="color: #0000FF;">Cells</span><span style="color: #000000;">&#40;</span>sCount,<span style="color: #FF0000;">7</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Country&quot;</span>
objWorksheet.<span style="color: #0000FF;">Cells</span><span style="color: #000000;">&#40;</span>sCount,<span style="color: #FF0000;">7</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">BorderAround</span> xlContinuous, xlThin
objWorksheet.<span style="color: #0000FF;">Cells</span><span style="color: #000000;">&#40;</span>sCount,<span style="color: #FF0000;">8</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Disabled&quot;</span>
objWorksheet.<span style="color: #0000FF;">Cells</span><span style="color: #000000;">&#40;</span>sCount,<span style="color: #FF0000;">8</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">BorderAround</span> xlContinuous, xlThin
&nbsp;
objWorksheet.<span style="color: #0000FF;">Range</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;A1:H1&quot;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Font</span>.<span style="color: #0000FF;">Bold</span> <span style="color: #008000;">=</span> <span style="color: #0600FF;">True</span>
objWorksheet.<span style="color: #0000FF;">Range</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;A1:H1&quot;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Interior</span>.<span style="color: #0000FF;">ColorIndex</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">15</span>
&nbsp;
<span style="color: #FF8000;">For</span> <span style="color: #0600FF;">Each</span> objMember in objGroup.<span style="color: #0000FF;">Members</span>
  <span style="color: #0600FF;">If</span> <span style="color: #000000;">&#40;</span><span style="color: #0600FF;">LCase</span><span style="color: #000000;">&#40;</span>objMember.<span style="color: #0600FF;">Class</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;user&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>  
    objWorksheet.<span style="color: #0000FF;">Cells</span><span style="color: #000000;">&#40;</span>intRow, <span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Value</span> <span style="color: #008000;">=</span> objMember.<span style="color: #0000FF;">sAMAccountName</span>
    objWorksheet.<span style="color: #0000FF;">Cells</span><span style="color: #000000;">&#40;</span>intRow, <span style="color: #FF0000;">2</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Value</span> <span style="color: #008000;">=</span> objMember.<span style="color: #0000FF;">GivenName</span>
    objWorksheet.<span style="color: #0000FF;">Cells</span><span style="color: #000000;">&#40;</span>intRow, <span style="color: #FF0000;">3</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Value</span> <span style="color: #008000;">=</span> objMember.<span style="color: #0000FF;">SN</span>
    objWorksheet.<span style="color: #0000FF;">Cells</span><span style="color: #000000;">&#40;</span>intRow, <span style="color: #FF0000;">4</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Value</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;&quot;</span>
    objWorksheet.<span style="color: #0000FF;">Cells</span><span style="color: #000000;">&#40;</span>intRow, <span style="color: #FF0000;">5</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Value</span> <span style="color: #008000;">=</span> objMember.<span style="color: #0000FF;">Mail</span>
    objWorksheet.<span style="color: #0000FF;">Cells</span><span style="color: #000000;">&#40;</span>intRow, <span style="color: #FF0000;">6</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Value</span> <span style="color: #008000;">=</span> objMember.<span style="color: #0000FF;">ipPhone</span>
    objWorksheet.<span style="color: #0000FF;">Cells</span><span style="color: #000000;">&#40;</span>intRow, <span style="color: #FF0000;">7</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Value</span> <span style="color: #008000;">=</span> objMember.<span style="color: #0000FF;">c</span> <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot; - &quot;</span> <span style="color: #008000;">&amp;</span> objMember.<span style="color: #0000FF;">l</span>
    <span style="color: #0600FF;">If</span> objMember.<span style="color: #0000FF;">userAccountControl</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">514</span> <span style="color: #FF8000;">Then</span>
      objUAC <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Yes&quot;</span>
    <span style="color: #FF8000;">Else</span>
      objUAC <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;&quot;</span>
    <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
    objWorksheet.<span style="color: #0000FF;">Cells</span><span style="color: #000000;">&#40;</span>intRow, <span style="color: #FF0000;">8</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Value</span> <span style="color: #008000;">=</span> objUAC
    objWorksheet.<span style="color: #0000FF;">Range</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;A1:H1&quot;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0600FF;">Select</span>
    objWorksheet.<span style="color: #0000FF;">Cells</span>.<span style="color: #0000FF;">EntireColumn</span>.<span style="color: #0000FF;">AutoFit</span>
  <span style="color: #FF8000;">Else</span>
    <span style="color: #008080; font-style: italic;">' This is to retrieve members recursively</span>
    <span style="color: #008080; font-style: italic;">' Comment the Function to only get the 'base'</span>
    createUserList<span style="color: #000000;">&#40;</span>objMember.<span style="color: #0000FF;">AdsPath</span><span style="color: #000000;">&#41;</span>
    intRow <span style="color: #008000;">=</span> intRow <span style="color: #008000;">-</span> <span style="color: #FF0000;">1</span>
  <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
&nbsp;
  intRow <span style="color: #008000;">=</span> intRow <span style="color: #008000;">+</span> <span style="color: #FF0000;">1</span>
<span style="color: #FF8000;">Next</span>
&nbsp;
<span style="color: #FF8000;">Set</span> objGroup <span style="color: #008000;">=</span> <span style="color: #FF8000;">Nothing</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.hican.net/2011/12/14/vbscript-output-active-directory-user-information-to-excel/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
