The Official Scripting Guys Forum! ForumEver been to the Script Center? You know, http://technet.microsoft.com/scriptcenter/. If your answer is "yes," you know what to do. Dive in and help somebody! If your answer is "no," welcome to our fun little world! We'd recommend that you first head over to the Script Center, get your feet wet, and then come back to either ask or answer questions. We can't be everywhere at once (we know—shocking!), so we will appreciate any and all help you can give to each other to get scripting problems solved. The Microsoft Scripting Guys© 2009 Microsoft Corporation. All rights reserved.Thu, 26 Nov 2009 05:38:34 Zf802a7a2-be54-4723-86b1-0024811ea199http://social.technet.microsoft.com/Forums/en/ITCG/thread/e18c467e-b092-4264-9c32-2350707de3a2http://social.technet.microsoft.com/Forums/en/ITCG/thread/e18c467e-b092-4264-9c32-2350707de3a2coolguy20http://social.technet.microsoft.com/Profile/en-US/?user=coolguy20IAG (Whale Client Components)Hi,<br/>    Can any one tell me which whale component is responsiable for running the batch file in iag. I need to know which dll it is. The name of that component.Thu, 26 Nov 2009 05:38:34 Z2009-11-26T05:38:34Zhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/b6c359eb-a1be-4c62-bd27-2f2c4abd25d7http://social.technet.microsoft.com/Forums/en/ITCG/thread/b6c359eb-a1be-4c62-bd27-2f2c4abd25d7Scottinct78http://social.technet.microsoft.com/Profile/en-US/?user=Scottinct78Clean up folders 2 days old<p>I am trying to create a VB Script to clean up temp folders created by one of my internal websites.  This is what I came up with from googling examples, but it does not work.   I would like all folders &gt; subfolders &amp; files to be removed from &quot;C:\Inetpub\AMM\amtemp\&quot;  which are less then &quot;X&quot; days old.  <br/><br/>Dim oFSO<br/>Dim sDirectoryPath<br/>Dim oFolder<br/>Dim oDelFolder<br/>Dim oFileCollection<br/>Dim oFile<br/>Dim oFolderCollection<br/><br/>Set oFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)<br/>sDirectoryPath = &quot;C:\Inetpub\AMM\amtemp&quot;<br/>set oFolder = oFSO.GetFolder(sDirectoryPath)<br/>set oFolderCollection = oFolder.SubFolders<br/>set oFileCollection = oFolder.Files<br/><br/>For each oDelFolder in oFolderCollection<br/>  If DateDiff(&quot;D&quot;, oDelFolder.DateLastModified, Now) &gt; 2 Then oDelFolder.Delete<br/>Next<br/><br/><br/><br/>Thanks, Scott.</p>Wed, 25 Nov 2009 21:09:13 Z2009-11-26T01:36:38Zhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/96b82ae1-abf2-40d1-9f8c-7ecb6ff7f336http://social.technet.microsoft.com/Forums/en/ITCG/thread/96b82ae1-abf2-40d1-9f8c-7ecb6ff7f336Jergerhttp://social.technet.microsoft.com/Profile/en-US/?user=Jergerscript: cannot empty recycling bin - all options corrupt the binAfter further research these options may empty it upon the next reboot. I need it to make the bin appear empty without rebooting. I have commented out the code I have tried below. Each option appears to delete the recycling bin files but does not make the icon appear empty. newly deleted items after the script is ran do not appear in the bin, it remains to appear empty even if the files are in the bin. i have to use ccleaner to fix the bin afterwards. any ideas? <div><br/></div> <div>similar code in windows 7 works without issues: del c:\$Recycle.Bin\. /f /s /q /a</div> <div><br/></div> <div> <div>echo ******************************************</div> <div>echo emptying c:\windows\prefetch</div> <div>echo ******************************************</div> <div>echo  *** enter to continue *** CTRL+C to quit</div> <div>rem pause</div> <div>rd c:\windows\Prefetch /s /q </div> <div>md C:\windows\Prefetch</div> <div>cls</div> <div>echo windows prefetch folder cleaned</div> <div>rem pause</div> <div>cls</div> <div>rem echo ******************************************</div> <div>rem echo emptying recycling bin</div> <div>rem echo ******************************************</div> <div>rem deltree /y c:\recycled</div> <div>rem mkdir &quot;c:\recycled&quot;</div> <div>rem echo  *** enter to continue *** CTRL+C to quit</div> <div>rem pause</div> <div>rem for /f %q in ('dir /b /a:s C:\Recycler') do (rd /s C:\Recycler\%q)</div> <div>rem RD c:\recycler /q /s</div> <div>rem DEL /f /s /q C:\RECYCLER\*.*</div> <div>rem rd c:\RECYCLER /s /q</div> <div>rem del /f/s/q/a c:\RECYCLER\*.* </div> <div>rem del /f/s/q/a c:\RECYCLER </div> <div><br/></div> <div>rem del C:\RECYCLER\. /f /s /q /a</div> <div>rem del /s /f /q c:\Recycled\*</div> <div>rem del /s /f /q c:\Recycler\*</div> <div><br/></div> </div>Wed, 25 Nov 2009 15:41:40 Z2009-11-25T21:59:11Zhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/f064191c-e0f4-4ffc-b928-0365ec6482d5http://social.technet.microsoft.com/Forums/en/ITCG/thread/f064191c-e0f4-4ffc-b928-0365ec6482d5jonathanbrickman0000http://social.technet.microsoft.com/Profile/en-US/?user=jonathanbrickman0000Create Windows 7 library in VBScript, PowerShell, CMD, other login script?We are just starting to look at rolling out Windows 7 desktops in AD environments.  We would like to be able to create Windows 7 libraries using login scripts.  Anyone have a way?Wed, 25 Nov 2009 17:37:23 Z2009-11-25T20:43:23Zhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/46cc6083-0455-4ddf-b39a-6f1ae004042chttp://social.technet.microsoft.com/Forums/en/ITCG/thread/46cc6083-0455-4ddf-b39a-6f1ae004042cTOMMYDEEhttp://social.technet.microsoft.com/Profile/en-US/?user=TOMMYDEEvb scripting for renaming a file with reuters dateHi, <br/><br/>I'm wondering if anyone can assit me with a renaming script.  I need it to rename an existing file i.e 'test31122009.txt' to 'ABCDE.X31'.  In this case x represents the month of november.  So the charachter generated will be driven by the MM (in this case '11') part of the file name.  <br/>I'm guessing some kind of lookup table will be required and the reuters months tables are as follows;<br/><br/>Jan - F<br/>Feb - G<br/>Mar - H<br/>Apr - J<br/>May - K<br/>Jun - M<br/>Jul - N<br/>Aug - Q<br/>Sep - U<br/>Oct - V<br/>Nov - X<br/>Dec - Z<br/><br/>Any help greatly appreciated.<br/><br/>TomWed, 25 Nov 2009 15:51:11 Z2009-11-25T18:23:02Zhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/4a77a398-9fae-4c30-b10b-89130d9637c2http://social.technet.microsoft.com/Forums/en/ITCG/thread/4a77a398-9fae-4c30-b10b-89130d9637c2KroneMarvzhttp://social.technet.microsoft.com/Profile/en-US/?user=KroneMarvzScript to query mapped drive information from multiple computers in domainHey Scripting Guy,<br/> <br/> Good day to you and hope all is well. <br/> <br/> I'm currently conducting an audit to multiple computers in one domain. I need to get their information with regards to their mapped drive. I want to know what drive letter are they pointing to and what path are they assigning each drive letter.<br/> <br/> Hoping for your favorable response.<br/> <br/> Best Regards,<br/> -Krone-Wed, 25 Nov 2009 02:17:04 Z2009-11-25T17:33:08Zhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/fbbdb5a5-ee41-4f93-9878-af651da37ac9http://social.technet.microsoft.com/Forums/en/ITCG/thread/fbbdb5a5-ee41-4f93-9878-af651da37ac9droglifehttp://social.technet.microsoft.com/Profile/en-US/?user=droglifeScript to identify stale computer accounts in AD. Help Needed<p>Ive tried many iterations of this script but not working. Any help much appreciated. Ive blanked out the DC details<br/><br/>'http://www.microsoft.com/technet/scriptcenter/guide/sas_srv_ifcf.mspx?mfr=true<br/>'Resetting Computer Account Passwords</p> <p>On Error Resume Next</p> <p>Set objFS = CreateObject(&quot;Scripting.FileSystemObject&quot;)<br/>Set objNewFile = objFS.CreateTextFile(&quot;TEST_Computers.csv&quot;)</p> <p>Const ADS_SCOPE_SUBTREE = 2</p> <p>Set objConnection = CreateObject(&quot;ADODB.Connection&quot;)<br/>Set objCommand =   CreateObject(&quot;ADODB.Command&quot;)<br/>objConnection.Provider = &quot;ADsDSOObject&quot;<br/>objConnection.Open &quot;Active Directory Provider&quot;<br/>Set objCommand.ActiveConnection = objConnection</p> <p>objCommand.Properties(&quot;Page Size&quot;) = 1000<br/>objCommand.Properties(&quot;Searchscope&quot;) = ADS_SCOPE_SUBTREE</p> <p>objCommand.CommandText = &quot;SELECT ADsPath FROM 'LDAP://OU=Test_Computers -Clients,DC=X,DC=X,DC=com' WHERE &quot; &amp; &quot;objectCategory='computer'&quot;  <br/>Set objRecordSet = objCommand.Execute</p> <p>objRecordSet.MoveFirst<br/>Do Until objRecordSet.EOF<br/>    strPath = objRecordSet.Fields(&quot;ADsPath&quot;).Value<br/>    Set objComputer = GetObject(strPath)</p> <p>     objnewFile.Write objComputer.samaccountname <br/> objNewFile.Write &quot;,&quot;<br/> objnewFile.Write objComputer.operatingsystem<br/> objNewFile.Write &quot;,&quot;<br/> objnewFile.Write objComputer.operatingsystemServicePack<br/> objNewFile.Write &quot;,&quot;<br/>     objnewFile.Write objComputer.AccountDisabled<br/> objNewFile.Write &quot;,&quot;<br/> objnewFile.Write objComputer.whencreated<br/> objNewFile.Write &quot;,&quot;<br/> objnewFile.Write objComputer.LastLogon<br/> objNewFile.Write &quot;,&quot;<br/> objnewFile.Write objComputer.PasswordLastChanged <br/> objNewFile.Write &quot;,&quot;<br/> objNewFile.Write DateDiff(&quot;d&quot;, objComputer.passwordlastchanged, Date)<br/> objNewFile.Write &quot;,&quot;<br/> objNewFile.Write objComputer.DistinguishedName<br/> objNewFile.WriteLine</p> <p>    objRecordSet.MoveNext<br/>Loop</p> <p>'wscript.echo &quot;Parasing completed ... !!&quot;</p> <p>'http://technet.microsoft.com/en-us/magazine/cc161038.aspx</p>Wed, 25 Nov 2009 16:20:36 Z2009-11-25T22:01:29Zhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/cb396200-db47-419e-8460-4cdd235c9cdbhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/cb396200-db47-419e-8460-4cdd235c9cdbmadhuadavihttp://social.technet.microsoft.com/Profile/en-US/?user=madhuadaviHelp me in modifying this Script Please. Urgent.Hello there,<br/> <br/> <br/> heare is my script. it will check the services are running or not and if its stopped it will start it. if there is an error while starting it will say as error while stopping.<br/> <br/> But am unable to get exact o/p as am looking, some looping is missing..<br/> <br/> in this code i used an strStopped string.<br/> <br/> when i calling the sendmail function, i need the value in strStopped as follows.<br/> <br/> suppose say service 1  and service 2 are stopped, then while starting service 1 started successfully but service 2 is error.<br/> <br/> service1     started successfully<br/> service2     Error while starting<br/> <br/> But when i ran this script its overlapping . meanse it is like o/p is not coming properly.. some time it will come as <br/> <br/> service 1    started successfully<br/> <br/> service2  started successfully<br/> <br/> even though the service 1 is error while starting..<br/> <br/> Please help me.. <pre>Option Explicit Dim strComputer, objWMIService, colServices, objService, strService Dim objFSO, strFile, objFile,strStopped,strStopped1,strTmp Const ForReading = 1 ' Specify text file with service names. strFile = &quot;C:\Services.txt&quot; ' Open the text file for reading. Set objFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;) Set objFile = objFSO.OpenTextFile(strFile, ForReading) ' Specify the computer. strComputer = &quot;.&quot; ' Connect to the computer with WMI. Set objWMIService = GetObject(&quot;winmgmts:&quot; _ &amp; &quot;{impersonationLevel=impersonate,authenticationLevel=Pkt}!\\&quot; _ &amp; strComputer &amp; &quot;\root\cimv2&quot;) strStopped = &quot;&quot; Do Until objFile.AtEndOfStream strService = Trim(objFile.ReadLine) ' Skip blank lines. If (strService &lt;&gt; &quot;&quot;) Then ' Retrieve information on the service. Set colServices = objWMIService.ExecQuery _ (&quot;SELECT * FROM Win32_Service WHERE Name = '&quot; &amp; strService &amp; &quot;'&quot;) For Each objService In colServices If (objService.State = &quot;Stopped&quot;) Then ' If you want to attempt to start the service, uncomment the next line. dim tmp tmp = 0 tmp = objService.StartService() ' Flag service as stopped. If (strStopped = &quot;&quot;) Then if (tmp &gt; 0) then 'strStopped = strService &amp; &quot; &quot; &amp; &quot;Error while starting the Service&quot; strTmp = &quot;Error while Starting the Service&quot; else strTmp = &quot;Started Successfully&quot; end if strStopped = strService &amp; &quot; &quot; &amp; strTmp Else strStopped = strStopped &amp; vbCrLf &amp; strService &amp;&quot; &quot; &amp; strTmp End If End If Next End If Loop ' Clean up. objFile.Close If (strStopped &lt;&gt; &quot;&quot;) Then 'Call SendEmailMessage(strComputer, strStopped) Wscript.Echo strStopped 'Call SendEmailMessage(strComputer, strStopped) End If Sub SendEmailMessage(ByVal strComputer, ByVal strStopped) ' Send email message. ' Sender and To email addresses are hard coded. Dim objMessage Set objMessage = CreateObject(&quot;CDO.Message&quot;) objMessage.Subject = &quot;TMEA Services stopped on the Server &quot; &amp; strComputer objMessage.Sender = &quot;suresh.babu.ps@hds.com&quot; objMessage.To = &quot;suresh.babu.ps@hds.com&quot; objMessage.Configuration.Fields.Item(&quot;http://schemas.microsoft.com/cdo/configuration/sendusing&quot;) = 2 'Name or IP of Remote SMTP Server objMessage.Configuration.Fields.Item(&quot;http://schemas.microsoft.com/cdo/configuration/smtpserver&quot;) = &quot;mail.hds.com&quot; 'Server port (typically 25) objMessage.Configuration.Fields.Item(&quot;http://schemas.microsoft.com/cdo/configuration/smtpserverport&quot;) = 25 objMessage.Fields.Item(&quot;urn:schemas:mailheader:importance&quot;).Value = &quot;High&quot; objMessage.Fields.Update() objMessage.Configuration.Fields.Update objMessage.TextBody = &quot;Hello Team,&quot; &amp; vbCrLf &amp;&quot;The Following services &quot; &amp; strStopped &amp; vbCrLf &amp; &quot; are stopped on computer &quot; &amp; vbCrLf &amp; strComputer &amp; vbCrLf objMessage.Send End Sub</pre> <br/> <br/> like this.. <br/> <input type=hidden> <input type=hidden><hr class="sig">Madhu AdaviWed, 25 Nov 2009 15:35:21 Z2009-11-25T17:47:33Zhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/c30f2138-203d-4fe4-9bc6-0578c0745572http://social.technet.microsoft.com/Forums/en/ITCG/thread/c30f2138-203d-4fe4-9bc6-0578c0745572KennethThompsonhttp://social.technet.microsoft.com/Profile/en-US/?user=KennethThompsonVBS problem with spaces using fso.OpenTextFile(str).ReadAll <p>I have an hta written in VBS that uses .OpenTextFile(strDirectory).ReadAll as an &quot;include&quot; statement to make functions in a vbs file locally accessible to the hta code.  <br/>There are 3 points to my problem that seem significant:<br/>1. On 'my system' (the LAN I work in and developed the code on) has no problems and runs fine under all circumstances</p> <p>2. On 'the other' system in my company (I don't really understand what differences there are between the systems, but I have to sign into a security portal to gain access to the other drives and/or virtual terminals that run on the other system) the .OpenTextFile(strDirectory).ReadAll statements fail with &quot;path not found&quot; if there are spaces in the path. It fails with 'bad file name or number' when I try to put quotes around it.</p> <p>3. I'm &quot;almost&quot; sure it's a 'spaces' issue because I can run it on the old system if I take the space out of the parent folder name and run as an hta.  However I want to make it an .exe which makes it run from a local temp file which will have spaces in it.</p> <p>Here's the relevant code:</p> <p>intpos=InStrRev(document.location.pathname,&quot;\&quot;)<br/>strCurrentDirectory=&quot;&quot;<br/>   If intpos&gt;0 Then<br/>     strcurrentDirectory = Left(document.location.pathname,intpos)<br/>     strCurrentDirectory = strCurrentDirectory <br/>   End If</p> <p><br/>strDirectory = strCurrentDirectory &amp; &quot;GetProjectFolders.vbs&quot;<br/>strDirectory = Chr(34)&amp; strDirectory &amp; Chr(34)</p> <p>ExecuteGlobal CreateObject(&quot;Scripting.FileSystemObject&quot;).OpenTextFile(strDirectory).ReadAll</p> <p><br/>I've tried this with double quotes (Chr(34)) as well and it also gives me 'bad file name or number'. </p> <p>I've searched hi and low on the web to find the proper way to quote out the spaces and just can't find a solution.  How are these paths supposed to be quoted for spaces?</p>Wed, 25 Nov 2009 15:11:46 Z2009-11-25T16:17:12Zhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/a4ac3c3d-d0e2-4781-9f6a-8db2209ce77bhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/a4ac3c3d-d0e2-4781-9f6a-8db2209ce77bMatt Teehttp://social.technet.microsoft.com/Profile/en-US/?user=Matt%20TeeEnableBitlocker.vbs, issue since Vista SP2<p class=MsoNormal style="margin:0cm 0cm 0pt"><span style="font-family:'Verdana','sans-serif';color:black;font-size:8pt">Hi there,<br/><br/>I'm looking for a little guidance with Starr Andersens script to enable BitLocker:<br/><a href="http://gallery.technet.microsoft.com/ScriptCenter/ja-jp/780d167f-2d57-4eb7-bd18-84c5293d93e3">http://gallery.technet.microsoft.com/ScriptCenter/ja-jp/780d167f-2d57-4eb7-bd18-84c5293d93e3</a><br/><br/>We tested with the script successfully using Vista SP1 clients, but now we are trying to enable this in our live environment which has been patched to Vista SP2 (and soon to be Win7). We now seem to have hit the problem detailed in this KB article: <a href="http://support.microsoft.com/kb/2002136">http://support.microsoft.com/kb/2002136</a><br/><br/>Much of this script is way beyond my basic understanding of VBScript so implementing the recommended solution is proving tricky.<br/><br/>Many thanks,<br/>Matt Tee</span></p>Wed, 25 Nov 2009 14:15:49 Z2009-11-25T14:15:49Zhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/44fd3f1b-677b-42eb-affb-2b7f69c1ad14http://social.technet.microsoft.com/Forums/en/ITCG/thread/44fd3f1b-677b-42eb-affb-2b7f69c1ad14helllmonkeyhttp://social.technet.microsoft.com/Profile/en-US/?user=helllmonkeyReading text from webpage/source code into access database, preferably with VBANot sure if this is the right place or not, so if it is in the wrong place let me know.<br/><br/>At work, we have a webpage that is hosted offisite. Its a simple site that allows residents to submit service requests for things like down trees, road kill, stuff like that. After submission, there is a tracking page that is always in the same format. The problem here is that data is stored offsite and off of our network, so we have no real way to access it other than through the limited webpage. <br/><br/>Each request is givin a request number, and that number is placed in the url, so the page is <a href="http://biglongurlforrequest=requestNumber">http://biglongurlforrequest=requestNumber</a>. I have a hyperlink field on our in house work order system, they just have to put the request number in the field, then double click to access the page. There is no security or loggin in. The problem is I have no idea how to write a webpage to a file or array, and then pull that information from the page.  My biggest hurdle is I dont know how to get the info from the file into a field in access. <br/><br/> Example from the source code:<br/>&lt;td align=&quot;left&quot;  valign=&quot;top&quot;&gt;&lt;font face=&quot;Arial&quot; size=&quot;2&quot; color=&quot;#000000&quot;&gt;&lt;tr&gt;&lt;td align=&quot;right&quot; valign=&quot;top&quot;&gt;&lt;font face=&quot;Arial&quot; size=&quot;2&quot; color=&quot;#000000&quot;&gt;&lt;b&gt;Comments:&lt;/b&gt;&lt;/font&gt;&lt;/td&gt;<br/> &lt;td align=&quot;left&quot;  valign=&quot;top&quot;&gt;&lt;font face=&quot;Arial&quot; size=&quot;2&quot; color=&quot;#000000&quot;&gt;<strong>Description of problem</strong>.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;<br/><br/>How would I get the bolded part into a field in a table?  If there is a better way to go about this please let me know of other options.  <br/> <br/>Or can you tell me where to look/research for this stuff.  My limit of VBA is mostly looping, if/then, and form operations.<br/><br/><br/>Thank youTue, 24 Nov 2009 21:06:56 Z2009-11-25T14:07:14Zhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/20bdbe4a-6160-4696-aab2-e365307cbfe3http://social.technet.microsoft.com/Forums/en/ITCG/thread/20bdbe4a-6160-4696-aab2-e365307cbfe3Rolf Szimnauhttp://social.technet.microsoft.com/Profile/en-US/?user=Rolf%20SzimnauPowershell script to export mailboxes to a csv, and script to import as contacts.Hi,<br/> We recently expanded our business, and open a new company, - they run completely separate from us, and have their own exchange 2007sp2, and what I would like is that we once or twice a year export mailboxes to a csv file, and then import the resulting csv into our exchange 2007 sp2 as contacts.<br/> get-mailbox | select-object name, alias, PrimarySmtpAddress | Export-Csv C:\mailboxes.csv -NoTypeInformation <br/> <br/> Unfortunate the above lacks information as Tiltle, company, department and lastly manager. <br/> <br/> Also what command do i need to run to import the final script. <br/> Can someone help me ?<br/> <br/> ThanksWed, 25 Nov 2009 10:48:56 Z2009-11-25T13:45:28Zhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/2d483469-21cc-48a5-a257-93b9f5013737http://social.technet.microsoft.com/Forums/en/ITCG/thread/2d483469-21cc-48a5-a257-93b9f5013737Aussie Techhttp://social.technet.microsoft.com/Profile/en-US/?user=Aussie%20TechNetwork User Agreement on logon using script and a flagHi everyone,<br/>I'm working on a Network User Agreement for the company I work for.<br/><br/>A long time ago, I created a little web page that launched from a batch file and it created a cookie when the user clicked &quot;Agree.&quot; It didn't prompt them after that until I ran a script to delete all the cookies for it, forcing the users to agree on next logon. If they did not agree, they would be logged off.<br/><br/>I am sure that there is some kind of function I can use with vbscript or batch script to present a neat little user agreement box with Agree or Disagree.<br/><br/>The desired functionality would be:<br/>Agree - Continue the login script and launch the shell.<br/>Disagree - Logoff user immediately and if possible lock out their account until they call IT for support and to discuss. Alternatively we could generate a simple email to the IT Manager advising that User:John.Doe does not accept the user agreement. We can do without this functionality but it would be great.<br/><br/>The users cannot be given the option to close the script or get around it.<br/><br/>Thanks in advance :)<br/><br/>Ian<hr class="sig">Aussie TechWed, 25 Nov 2009 12:31:30 Z2009-11-25T12:31:31Zhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/51de27c9-c6d4-44e1-9cb4-ac32b9816b66http://social.technet.microsoft.com/Forums/en/ITCG/thread/51de27c9-c6d4-44e1-9cb4-ac32b9816b66KroneMarvzhttp://social.technet.microsoft.com/Profile/en-US/?user=KroneMarvzUptime using SystemInfo | Find "Uptime" method for multiple computersHey Scripting Guy,<br/> <br/> Good day to you, my name is Krone and I got a question with regards to uptime script using the Windows SystemInfo method. Here's my simple script below.<br/> <br/> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br/> <br/> for /f %%i in (machinelist_selected.txt) do SystemInfo | Find &quot;Up Time&quot; %%i&gt;&gt;Out1.txt<br/> <br/> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br/> <br/> where: machinelist_selected.txt are the list of the machines to be queried<br/>            out1.txt should be the output where the computers being queried should be recorded.<br/> <br/> My problem is that  the script run successfully and generate an Out1.txt file on the path where the script is being saved however Out1.txt doesn't seem to provide any data recorded based on the query, in short Out1.txt is empty :(.<br/> <br/> Is there any other pipe method that could display the output properly.<br/> <br/> Also, I've no problem running the script using uptime.exe method, all works well. I'll just need to further validate and compare the results of the two methods.<br/> <br/> Hoping for your favorable response.<br/> <br/> P.S. ---&gt; this thread is migrated from <a href="http://social.technet.microsoft.com/Forums/en-US/itproxpsp/thread/d74aade1-78b7-420a-a1b8-ea5bd7c0f694">http://social.technet.microsoft.com/Forums/en-US/itproxpsp/thread/d74aade1-78b7-420a-a1b8-ea5bd7c0f694 </a> and I had just migrated it. Old thread is now okay to be deleted.<br/> <br/> -Krone-Wed, 25 Nov 2009 02:11:24 Z2009-11-25T10:17:56Zhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/b5526a74-1773-457d-8493-6cc64ea3a92ahttp://social.technet.microsoft.com/Forums/en/ITCG/thread/b5526a74-1773-457d-8493-6cc64ea3a92aRob.Fordhttp://social.technet.microsoft.com/Profile/en-US/?user=Rob.FordProblem with user level environment variables set from VBS logon script not being available until logoff/logonHi,<br/><br/>I'm a little stuck with this problem on Windows 7. Our VBS logon script sets certain user level environment variables. On Windows XP and 2003 this works perfectly. On Windows 7, it does not. <br/><br/>Details of the problem are posted in the Windows 7 forum <a href="http://social.technet.microsoft.com/Forums/en/w7itproui/thread/b2db8f15-cf77-4f48-9f6a-5b5575684d03">here</a>. I have had no luck getting a solution there so thought I'd try in here instead :)<br/><br/>A quick overview of the problem is that when a user logs onto Windows 7 for the first time, the environment variables set by the logon script are not available until the user logs off and then on again.<br/><br/>They are set using WScript.Shell.Environment like this:<br/><br/>Set Shell = CreateObject(&quot;WScript.Shell&quot;)<br/>Set TEnv = Shell.Environment(TLevel)<br/>TEnv(TName) = TValue<br/><br/>I have even tried putting this into an in-house VB.NET DLL that sets them like this:<br/><br/><span style="font-size:x-small"> <p>Environment.SetEnvironmentVariable(VarName, VarValue, EnvironmentVariableTarget.User)</p> </span>However they are set, they appear in the Registry and Computer -&gt; Properties -&gt; Advanced -&gt; Environment Variables.<br/><br/>They just won't work!<br/><br/>Restarting explorer.exe and dwm.exe have no affect so at this stage I am guessing that this is a bug in winlogon.exe or some other parent process.<br/><br/>So, I have 2 questions:<br/><br/>1. Does anyone know how to force a refresh of user environment variables? <br/>2. Is this a bug - can someone from Microsoft comment please?<br/><br/>Remember that this problem is only seen during a first logon (or the 1st time a new variable is set I think), when the variables are set during the logon.<br/><br/>One last thing, if, after logon, I manually set a new variable, the others are then picked up, which suggests that there is a way to refresh environment variables for new processes...<br/><br/>Thanks!<br/><br/>Rob<br/><br/><br/><br/><br/><br/><br/>Tue, 24 Nov 2009 22:48:54 Z2009-11-25T03:14:49Zhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/2da50f7d-1227-41e3-a26a-bb934df47369http://social.technet.microsoft.com/Forums/en/ITCG/thread/2da50f7d-1227-41e3-a26a-bb934df47369gsterlehttp://social.technet.microsoft.com/Profile/en-US/?user=gsterleNew to VBScripting - Reading a log file extracting the error line and the next line and writing an output file and also extract the last 15 lines at the end on the fileI am new to vbscripting and have the following task at hand.  I am reading a unicode log file and am trying to extract the errors from the file.  Each error line contains the word * Error * so I have figured out how to extract that line, however I would also like to exctract the next line that contains additional information about the error.  I would like to write these lines to an output file.  Also the last 15 lines of the file contain valuable summary information that I would also like to be written to the output file.  That is a constant it is always the last 15 lines.  Any hlep and our examples would be apprceciated.   Other nices to have would be the generation of a unique output file name based on the input file name and the date.Tue, 24 Nov 2009 16:54:16 Z2009-11-25T00:02:55Zhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/1b8944c7-e05e-4d45-9d53-91c4bd21e7bfhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/1b8944c7-e05e-4d45-9d53-91c4bd21e7bfJohn.Jinhttp://social.technet.microsoft.com/Profile/en-US/?user=John.JinIE8 HTA Print lost focusHi guys, we have a HTA software running some CRM functions like Invocing / Ordering. Under IE6 everything is OK. Recently we planned to switch over to IE8 but one of the problems is printing issue.<br/>We are using the following code to start print, the print dialog will appear and click the &quot;print&quot; button on the dialog will send the page to the printer. But immediately it jumps away to an other opened application (like Excel). <br/><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> <p>&quot;&lt;<span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small">A</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> </span></span><span style="color:#ff0000;font-size:x-small"><span style="color:#ff0000;font-size:x-small">HREF</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">=</span></span><span style="font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">javascript: void(0);</span></span><span style="font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> </span></span><span style="color:#ff0000;font-size:x-small"><span style="color:#ff0000;font-size:x-small">ID</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">=</span></span><span style="font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">print</span></span><span style="font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> </span></span><span style="color:#ff0000;font-size:x-small"><span style="color:#ff0000;font-size:x-small">ONCLICK</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">=</span></span><span style="font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">window.print();</span></span><span style="font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">&gt;</span></span><span style="font-size:x-small">Print</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">&lt;/</span></span><span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small">A</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">&gt; &quot;</span></span></p> I also tried an other way as the following code, it still jumps away for a little while but then jumps back again.<br/><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> <p>&quot;&lt;</p> </span></span></span></span><span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small">A</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> </span></span><span style="color:#ff0000;font-size:x-small"><span style="color:#ff0000;font-size:x-small">HREF</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">=</span></span><span style="font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">javascript: this.focus();</span></span><span style="font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> </span></span><span style="color:#ff0000;font-size:x-small"><span style="color:#ff0000;font-size:x-small">ID</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">=</span></span><span style="font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">print</span></span><span style="font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> </span></span><span style="color:#ff0000;font-size:x-small"><span style="color:#ff0000;font-size:x-small">ONCLICK</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">=</span></span><span style="font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">window.print();</span></span><span style="font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">&gt;</span></span><span style="font-size:x-small">Print</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">&lt;/</span></span><span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small">A</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">&gt;&quot;<br/><br/>Is it a bug for IE8?</span></span></span></span></span></span>Tue, 24 Nov 2009 23:46:19 Z2009-11-24T23:46:20Zhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/ea4eb933-11e3-42ea-bc6d-cb4c77e8a55dhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/ea4eb933-11e3-42ea-bc6d-cb4c77e8a55dFrank F Clark Jrhttp://social.technet.microsoft.com/Profile/en-US/?user=Frank%20F%20Clark%20JrReading a group from one domain and copying users to another group in a different domain using VBS and W2K8 SP2Hey all, <br/> <br/> I'm trying to read a group from a child domain and extract the users so that I can put them in a group with the same name in the parent domain. <br/> Here is my code so far. It reads the child domain group but I can't seem to get the users into the parent domain group. currently the names of the groups are different but will change once testing is complete.<br/> <br/> On Error Resume Next<br/> Dim strMember <br/> Set objGroup = GetObject(&quot;LDAP://cn=fo power users group,ou=fo,dc=fo,dc=CA,dc=org&quot;)<br/> objGroup.GetInfo<br/> arrMemberOf = objGroup.GetEx(&quot;member&quot;)<br/>  <br/> WScript.Echo &quot;Members:&quot;<br/> For Each strMember in arrMemberOf<br/>     WScript.echo strMember<br/> Next<br/> <br/> '' Add users to a group<br/> Const ADS_PROPERTY_APPEND = 3 <br/> <br/> Set objRootDSE = GetObject(&quot;LDAP://rootDSE&quot;)<br/> Set objContainer = GetObject(&quot;LDAP://cn=Users,&quot; &amp; _<br/>     objRootDSE.Get(&quot;defaultNamingContext&quot;))<br/> <br/> For Each strMember in arrMemberOf<br/>     Set objGroup = GetObject(&quot;LDAP://cn=fo power users group,ou=fo users,ou=fo,ou=field office,dc=CA,dc=org&quot;)<br/>     objGroup.Putex ADS_PROPERTY_APPEND, strMember,&quot;FO Power Users Group&quot;<br/>     objGroup.SetInfo <br/>     WScript.echo strMember<br/> Next<br/> WScript.Echo &quot;Done&quot;<br/> <br/> Any help would be appreciated. And yes, I have looked at the scripting forum but the copying between groups script fails. Might be 2008 issue.<br/> <br/> Thanks,<br/> <br/> FrankTue, 24 Nov 2009 20:49:49 Z2009-11-24T23:22:14Zhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/b1d37394-5028-45c2-b60a-f6612ed5a60chttp://social.technet.microsoft.com/Forums/en/ITCG/thread/b1d37394-5028-45c2-b60a-f6612ed5a60cNick Colyerhttp://social.technet.microsoft.com/Profile/en-US/?user=Nick%20ColyerDNS Script - PowershellI'm busy working on a script to DNS check over 300 servers.<br/> <br/> My script does the following:<br/> <br/> 1. Checks if there is a DNS record from a text file of hosts<br/> 2. Returns to an excel file, the hostname, the Hostname in DNS, the ip address and eventually i want to add aliases.<br/> <br/> My script is as follows:<br/> <br/> $erroractionpreference = &quot;SilentlyContinue&quot;<br/> $a = New-Object -comobject Excel.Application<br/> $a.visible = $True <br/> <br/> $b = $a.Workbooks.Add()<br/> $c = $b.Worksheets.Item(1)<br/> <br/> $c.Cells.Item(1,1) = &quot;Machine Name&quot;<br/> $c.Cells.Item(1,2) = &quot;DNS Entry&quot;<br/> $c.Cells.Item(1,3) = &quot;IP Address listed&quot;<br/> <br/> $d = $c.UsedRange<br/> $d.Interior.ColorIndex = 19<br/> $d.Font.ColorIndex = 11<br/> $d.Font.Bold = $True<br/> $d.EntireColumn.AutoFit($True)<br/> <br/> $intRow = 2<br/> <br/> $colComputers = get-content C:\ScriptData\activehosts.txt<br/> foreach ($strComputer in $colComputers)<br/> {<br/> $c.Cells.Item($intRow, 1) = $strComputer.ToUpper()<br/> <br/> #Resolve the host name<br/> <br/> $dnsresult = [System.Net.DNS]::GetHostEntry($strComputer)<br/> <br/> #Display information about host<br/> <br/> #Give hostname Entry in Cell2<br/> <br/> $c.Cells.Item($intRow, 2) = $dnsresult.HostName<br/> <br/> #IP listed in Cell 3<br/> <br/> $c.Cells.Item($intRow, 3) = $dnsresult.AddressList[0].IpAddressToString<br/> <br/> <br/> <br/> $intRow = $intRow + 1<br/> <br/> }<br/> $d.EntireColumn.AutoFit()<br/> <br/> It is almost working perfectly, except that if there isn't a DNS record, it seems to just populate that field with the previous dns record it had from the previous server it looked up. I'm unsure what command to use to give a false value or just to output &quot;No DNS record&quot; in the hostname column and leave the ip column blank.<br/> <br/> Any advice is appreciatedTue, 24 Nov 2009 17:23:26 Z2009-11-24T22:57:21Zhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/07a82e5e-aa3b-40cf-8202-0433dc467564http://social.technet.microsoft.com/Forums/en/ITCG/thread/07a82e5e-aa3b-40cf-8202-0433dc467564Hari Kodungallurhttp://social.technet.microsoft.com/Profile/en-US/?user=Hari%20KodungallurRobocopy - Include directories (as opposed to Include files) option?Hello,<br/> <br/> I would like to copy only a given set of directories using robocopy. How can this be achieved? Is there an option that I am missing?<br/> <br/> Details of my requirement:<br/> - I already use robocopy to sync a large number of binary files. I use robocopy obviously because I want to copy only the files that are changed since the last copy. (something like rsync)<br/> - Almost always I can run the robocopy on the top level directory. But once in a while (very infrequently), I need to copy a few files (~100 files) from 3-4 directories. I do not want to copy anything else. Again, not all files within these 3-4 directories have changed. But I know that the files that have changed are within these directories. So again using robocopy will be ideal because it will detect and copy only the changed files.<br/> <br/> From what I see so far, there is no way to provide just these directory names to robocopy and copy the appropriate files. I will have to loop through these directories and then robocopy individual files. Is that correct? Or is there an option in robocopy that can achieve this?<br/> <br/> <br/> Many thanks,<br/> -HariTue, 14 Jul 2009 00:51:48 Z2009-11-24T22:55:06Zhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/ecebf962-e68b-459d-8314-a279de901dcdhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/ecebf962-e68b-459d-8314-a279de901dcdwein3967http://social.technet.microsoft.com/Profile/en-US/?user=wein3967Windows 7 Backup and Shutdown with PowershellI am would like to writing a Powershell script which will fire the &quot;built in&quot; backup utility in Windows 7 and shut the computer down when finished.  I am new to Powershell, and I was unable to find any sample scripts in the downloads section for this type of backup.  Since I am interested in learning Powershell, I would like to avoid using VBscript and the like.  Thank you for your help.Tue, 24 Nov 2009 22:06:22 Z2009-11-24T22:06:23Zhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/2487ee51-0023-4b4d-9e70-4895f9c9b99dhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/2487ee51-0023-4b4d-9e70-4895f9c9b99dlizaoreohttp://social.technet.microsoft.com/Profile/en-US/?user=lizaoreoExecuting script on a remote machine - VBScriptI'm trying to remotely run a script that will get a listing of all printers (network and local) for a specific user along with whether they are default or not.  I have a script that I can use to do this locally.  I've been able to remote computers printers, but only local printer and not default status.<br/> <br/> I tried WSH, but I ran into issues with it that may have to do with how our company's domain security is set up, something I can't change.  I tried disabling firewalls, putting myself in the admin group, and all that good stuff, but was never able to get WSHRemote to work right.Tue, 24 Nov 2009 17:27:23 Z2009-11-24T21:23:48Zhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/9506f12b-4000-4b33-bc73-f582b9aab26ahttp://social.technet.microsoft.com/Forums/en/ITCG/thread/9506f12b-4000-4b33-bc73-f582b9aab26aJames Troyhttp://social.technet.microsoft.com/Profile/en-US/?user=James%20TroyHow to identify a junction in VBscript?<span style="font-size:x-small;font-family:Courier"><span style="font-size:x-small;font-family:Courier"> <p>As you know, Win 2008 and Vista make much use of junctions (aka reparse points). For example, &quot;Documents and Settings&quot; is a junction. When using a VBscript to enumerate all folders and files, the presence of the junction causes the subfolders and files to be listed twice. <br/><br/>Is there a way in VBscript to determine that a folder or file is really a junction? <br/><br/>I realize that I could start a subordinate CMD process to use the &quot;dir /al&quot; command, but was hoping for something more efficient, that avoids starting another process.<br/><br/>Thank you.<br/><br/>James Troy</p> </span></span>Tue, 24 Nov 2009 16:07:38 Z2009-11-24T21:01:51Zhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/148cc128-5440-427c-baee-9d8de9129494http://social.technet.microsoft.com/Forums/en/ITCG/thread/148cc128-5440-427c-baee-9d8de9129494Mark1906http://social.technet.microsoft.com/Profile/en-US/?user=Mark1906Copying file numerous times and rename each file from Excel spread sheet (followed your answer to DF and didn't work)<p>Hi Scripting Guy,<br/><br/>I have a file that needs to be duplicated numerous times and named from a list in Excel spread sheet. I coded the following script from your response to DF:<br/><br/><br/>strComputer = &quot;.&quot;</p> <p>Set objWMIService = GetObject (&quot;winmgmts:\\&quot; &amp; strComputer &amp; &quot;\root\cimv2&quot;)</p> <p>Set colFiles = objWMIService.ExecQuery (&quot;Select * From CIM_DataFile Where Name ='C:\\Scripts\\Test.txt'&quot;)</p> <p>Set objExcel = CreateObject (&quot;Excel.Application&quot;)<br/>objExcel.Visible = True</p> <p>Set objWorkbook = objExcel.Workbooks.Open(&quot;C:\Documents and Settings\wilsonm1\My Documents\Projects\ENSRProjects\ENSRFileNames1.xls&quot;)</p> <p>intRow = 1</p> <p>Do Until objExcel.Cells (intRow, 1).Value = &quot;&quot;</p> <p> strNewName = objExcel.Cells (intRow, 1).Value</p> <p> For Each objFile in ColFiles<br/>  strCopy = &quot;C:\Scripts\&quot; &amp; strNewName<br/>  objFile.Copy(strCopy)<br/> Next</p> <p> intRow = intRow + 1<br/>Loop</p> <p>objExcel.Quit</p> <p>The script ran and I can't find the files. I thought they should be in C:\Scripts\new file?????</p>Mon, 23 Nov 2009 17:51:30 Z2009-11-25T10:34:43Zhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/dff6f402-79cd-48a7-a478-0394f429b4a9http://social.technet.microsoft.com/Forums/en/ITCG/thread/dff6f402-79cd-48a7-a478-0394f429b4a9Thiago.Pereirahttp://social.technet.microsoft.com/Profile/en-US/?user=Thiago.PereiraGenerate a List of Last Modified files in a Folder and SubfoldersHello,<br/><br/>I'm trying to find an easy way to display files that have been modified since a relative date (12/31/2006) . I was recently looking at the FORFILES command which appears to allow this, but the help description is puzzling and I can't get it to work.<br/><br/>I need to generate a list of the files that were not modified in last 3 years, so last modified in December, 31, 2006 in a specific folder and subfolders, generate a log file with the all patch and file name and after that another line to push this log and delete all files.<br/><br/>Was thinking about (VBscript).<br/>Found this post: <a href="http://blogs.technet.com/heyscriptingguy/archive/2008/03/13/how-can-i-find-the-number-and-size-of-all-the-files-recently-modified-or-added-to-a-computer.aspx">http://blogs.technet.com/heyscriptingguy/archive/2008/03/13/how-can-i-find-the-number-and-size-of-all-the-files-recently-modified-or-added-to-a-computer.aspx</a> that could edit and help me, but I dont know how.<br/><br/>I was reading this Thread: <a href="http://social.technet.microsoft.com/Forums/en-US/ITCG/thread/121ff244-b60b-4256-aadc-86286d274302">http://social.technet.microsoft.com/Forums/en-US/ITCG/thread/121ff244-b60b-4256-aadc-86286d274302</a>, but question is pretty similar.<br/><br/>Hope you Guys can help.<br/><br/>Thanks in Advance.<br/> <hr class=sig> Thiago Pereira | http://thiagoinfrat.spaces.live.com | http://www.winsec.orgTue, 17 Nov 2009 00:12:49 Z2009-11-24T16:22:35Zhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/30e47c03-bc7c-47d1-bb6a-dea0f8a40612http://social.technet.microsoft.com/Forums/en/ITCG/thread/30e47c03-bc7c-47d1-bb6a-dea0f8a40612Johnny Joehttp://social.technet.microsoft.com/Profile/en-US/?user=Johnny%20JoeVB script for lastlogon dnsserver.<p>I have a script for polling all the dns server in a domain to find the lastlogon, but the script I have doesn't store the name of the dns server that had the most current last logon.  Is that data stored in the user class somewhere.  Or do I need to take the most current time I found and verify it against evey dns server with a If most current time = last logon time on this dns server  echo the name?  I am not real sure how to go about verifying it either.  I got alot of this script from Richard Mueller's site <a href="http://www.rlmueller.net">http://www.rlmueller.net</a>  This script is great for auditing user accounts, so feel free to use it if you need it.  Thanks for your help in advance.<br/><br/>Johnny<br/><br/>Option Explicit <br/>Dim objRootDSE, strConfig, objConnection, objCommand, strQuery <br/>Dim objRecordSet, objDC <br/>Dim strDNSDomain, objShell, lngBiasKey, lngBias, k, arrstrDCs() <br/>Dim strDN, dtmDate, objDate, lngDate, objList, strUser<br/>Dim strBase, strFilter, strAttributes, lngHigh, lngLow</p> <p> </p> <p><br/>' Create dictionary to keep track of <br/>' users and login times <br/>Set objList = CreateObject(&quot;Scripting.Dictionary&quot;) <br/>objList.CompareMode = vbTextCompare <br/>' rmueller's script <br/>' Obtain local Time Zone bias from machine registry. <br/>Set objShell = CreateObject(&quot;Wscript.Shell&quot;) <br/>lngBiasKey = objShell.RegRead(&quot;HKLM\System\CurrentControlSet\Control\&quot; _ <br/>&amp; &quot;TimeZoneInformation\ActiveTimeBias&quot;) <br/>If UCase(TypeName(lngBiasKey)) = &quot;LONG&quot; Then <br/>lngBias = lngBiasKey <br/>ElseIf UCase(TypeName(lngBiasKey)) = &quot;VARIANT()&quot; Then <br/>lngBias = 0 <br/>For k = 0 To UBound(lngBiasKey) <br/>   lngBias = lngBias + (lngBiasKey(k) * 256^k) <br/>Next <br/>End If <br/>' Determine configuration context and DNS domain from RootDSE object. <br/>Set objRootDSE = GetObject(&quot;<a>LDAP://RootDSE</a>&quot;) <br/>strConfig = objRootDSE.Get(&quot;configurationNamingContext&quot;) <br/>strDNSDomain = objRootDSE.Get(&quot;defaultNamingContext&quot;) <br/>' Use ADO to search Active Directory for ObjectClass nTDSDSA. <br/>' This will identify all Domain Controllers. <br/>Set objCommand = CreateObject(&quot;ADODB.Command&quot;) <br/>Set objConnection = CreateObject(&quot;ADODB.Connection&quot;) <br/>objConnection.Provider = &quot;ADsDSOObject&quot; <br/>objConnection.Open &quot;Active Directory Provider&quot; <br/>objCommand.ActiveConnection = objConnection <br/>strBase = &quot;&lt;LDAP://&quot; &amp; strConfig &amp; &quot;&gt;&quot; <br/>strFilter = &quot;(objectClass=nTDSDSA)&quot; <br/>strAttributes = &quot;AdsPath&quot; <br/>strQuery = strBase &amp; &quot;;&quot; &amp; strFilter &amp; &quot;;&quot; &amp; strAttributes &amp; &quot;;subtree&quot; <br/>objCommand.CommandText = strQuery <br/>objCommand.Properties(&quot;Page Size&quot;) = 100 <br/>objCommand.Properties(&quot;Timeout&quot;) = 60 <br/>objCommand.Properties(&quot;Cache Results&quot;) = False <br/>Set objRecordSet = objCommand.Execute <br/>' Enumerate parent objects of class nTDSDSA. Save Domain Controller <br/>' AdsPaths in dynamic array arrstrDCs. <br/>k = 0 <br/>Do Until objRecordSet.EOF <br/>Set objDC = _ <br/>   GetObject(GetObject(objRecordSet.Fields(&quot;AdsPath&quot;)).Parent) <br/>ReDim Preserve arrstrDCs(k) <br/>arrstrDCs(k) = objDC.DNSHostName <br/>k = k + 1 <br/>objRecordSet.MoveNext <br/>Loop <br/>' Retrieve lastLogon attribute for each user on each Domain Controller. <br/>For k = 0 To Ubound(arrstrDCs) <br/>strBase = &quot;&lt;LDAP://&quot; &amp; arrstrDCs(k) &amp; &quot;/&quot; &amp; strDNSDomain &amp; &quot;&gt;&quot; <br/>strFilter = &quot;(&amp;(objectCategory=person)(objectClass=user))&quot; <br/> <br/>strAttributes = &quot;distinguishedName,lastLogon&quot; <br/>strQuery = strBase &amp; &quot;;&quot; &amp; strFilter &amp; &quot;;&quot; &amp; strAttributes _ <br/>   &amp; &quot;;subtree&quot; <br/>objCommand.CommandText = strQuery <br/>On Error Resume Next <br/>Set objRecordSet = objCommand.Execute <br/>If Err.Number &lt;&gt; 0 Then <br/>   On Error GoTo 0 <br/>   Wscript.Echo &quot;Domain Controller not available: &quot; &amp; arrstrDCs(k) <br/>Else <br/>   On Error GoTo 0 <br/>   Do Until objRecordSet.EOF <br/>      strDN = objRecordSet.Fields(&quot;distinguishedName&quot;) <br/>      lngDate = objRecordSet.Fields(&quot;lastLogon&quot;) <br/>     <br/>     On Error Resume Next <br/>     Set objDate = lngDate <br/>     If Err.Number &lt;&gt; 0 Then <br/>       On Error GoTo 0 <br/>       dtmDate = #1/1/1601# <br/>     Else <br/>       On Error GoTo 0 <br/>       'stored as a 64 bit integer that VBScript cannot handle, must <br/>       'seperate it to work with it. <br/>       lngHigh = objDate.HighPart <br/>       lngLow = objDate.LowPart <br/>       If lngLow &lt; 0 Then <br/>         lngHigh = lngHigh + 1 <br/>       End If <br/>       If (lngHigh = 0) And (lngLow = 0 ) Then <br/>         dtmDate = #1/1/1601# <br/>       Else <br/>         dtmDate = #1/1/1601# + (((lngHigh * (2 ^ 32)) _ <br/>           + lngLow)/600000000 - lngBias)/1440 <br/>       End If <br/>     End If <br/>     If objList.Exists(strDN) Then <br/>       If dtmDate &gt; objList(strDN) Then <br/>         objList(strDN) = dtmDate <br/>       End If <br/>     Else <br/>       objList.Add strDN, dtmDate <br/>     End If <br/>     objRecordSet.MoveNext <br/>   Loop <br/>End If <br/>Next <br/>Dim objNetwork,objExcel <br/>dim intRow <br/>intRow = 2 <br/>Set objNetwork = Wscript.CreateObject(&quot;Wscript.Network&quot;) <br/>Set objExcel = CreateObject(&quot;Excel.Application&quot;) <br/>objExcel.Visible = True <br/>objExcel.Workbooks.Add</p> <p>objExcel.Cells(1,1).value = &quot;First Name&quot;<br/>objExcel.Cells(1,2).value = &quot;Last Name&quot;<br/>objExcel.Cells(1,3).value = &quot;User ID&quot; <br/>objExcel.Cells(1,4).value = &quot;Last Logon Date&quot; <br/>objExcel.Cells(1,5).value = &quot;Last Logon Time&quot;<br/>objExcel.Cells(1,6).value = &quot;Last Logon Server&quot;<br/>objExcel.Cells(1,7).value = &quot;Account Status&quot;</p> <p>' Output latest lastLogon date for each user. <br/>Dim easydate1 <br/>Dim easydate2<br/>Dim objUser</p> <p>For Each strUser In objList <br/>'easydate1 is the date stamp<br/>'easydate2 is the time stamp<br/>easydate1 = objList(strUser) <br/>easydate1 = FormatDateTime(easydate1,2)<br/>easydate2 = objList(strUser) <br/>easydate2 = FormatDateTime(easydate2,3)<br/>'output username and last login date and last login time<br/>' change 1/1/1601 to Never for Never logged in <br/>If easydate1 = &quot;1/1/1601&quot; Then <br/> easydate1 = &quot;Never&quot; <br/>End If  <br/>' change 12:00:00 AM to Never for Never logged in<br/>If easydate2 = &quot;12:00:00 AM&quot; Then<br/> easydate2 = &quot;Never&quot;<br/>End If</p> <p>Set objUser = GetObject _<br/>    (&quot;LDAP://&quot; &amp; struser &amp; &quot;&quot;)</p> <p>objExcel.Cells(intRow,1).value = objuser.givenname<br/>objExcel.Cells(intRow,2).value = objuser.sn<br/>objExcel.Cells(intRow,3).value = objuser.sAMAccountName <br/>objExcel.Cells(intRow,4).value = easydate1 <br/>objExcel.Cells(intRow,5).value = easydate2</p> <p><br/>'*Problem area Start*<br/>'objExcel.Cells(intRow,6).value = lastlogon dns server name<br/>'populated disabled column <br/>'*Problem area End*</p> <p><br/>if objuser.AccountDisabled = True Then <br/> objExcel.Cells(intRow,7).value = &quot;DISABLED&quot;<br/>Else<br/> objExcel.Cells(intRow,7).value = &quot;ACTIVE&quot;<br/>End if <br/>intRow = intRow + 1</p> <p>Next</p> <p>'sort by login Date <br/>Dim obrange, obrange2 <br/>Set obrange = objExcel.Range(&quot;A:K&quot;) <br/>Set obrange2 = objExcel.Range(&quot;A2&quot;) <br/>obrange.Sort obrange2,1,,,,,,1</p> <p><br/>' Clean up. <br/>objConnection.Close <br/>Set objRootDSE = Nothing <br/>Set objConnection = Nothing <br/>Set objCommand = Nothing <br/>Set objRecordSet = Nothing <br/>Set objDC = Nothing <br/>Set objDate = Nothing <br/>Set objList = Nothing <br/>Set objShell = Nothing <br/>Set obrange = Nothing <br/>Set obrange2 = Nothing <br/>Set objExcel = Nothing <br/>WScript.Quit</p><hr class="sig">JohnnyTue, 30 Jun 2009 18:51:28 Z2009-11-24T16:04:14Zhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/4de309bc-d97f-4c96-86c7-2cc85f093c8ehttp://social.technet.microsoft.com/Forums/en/ITCG/thread/4de309bc-d97f-4c96-86c7-2cc85f093c8ecesaremsdnhttp://social.technet.microsoft.com/Profile/en-US/?user=cesaremsdnreset local admin password on windows server 2008Hello,<br/><br/>there is a script that i can use with gpo on windows server 2008 that actually reset /remove the local admin built in password for all clients/users? <br/><br/>ThanksTue, 24 Nov 2009 15:21:10 Z2009-11-24T15:57:49Zhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/514740df-2770-4885-b30b-f7ea977a639ahttp://social.technet.microsoft.com/Forums/en/ITCG/thread/514740df-2770-4885-b30b-f7ea977a639agroovyfhttp://social.technet.microsoft.com/Profile/en-US/?user=groovyfPermission denied copying file to Progam Files folderWe use SAP in our business which is installed in the Program Files (or Program Files (x86) if using 64bit OS) folder, and have a .ini file in the SAPGui folder located within Program Files which lists all connections available when the user starts the program.<br/> This is updated from time-to-time, and is copied across from a central network location as part of the login script. We've had no issues with Windows XP at all, however, now we're testing Windows 7, I'm finding I'm getting a Permission Denied error when it's trying to copy the file locally (thanks to UAC, I guess)<br/> I *thought* there was some &quot;virtual&quot; folder that was referenced for just such occassions - where a seperate folder was created outside of Program Files but with the same structure... is this not the case?<br/> Is there any workaround for me?<br/> <br/> Thanks<br/> CraigMon, 23 Nov 2009 15:05:31 Z2009-11-24T14:31:59Zhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/a3fedbc9-4046-4db9-a24c-99372e5a0805http://social.technet.microsoft.com/Forums/en/ITCG/thread/a3fedbc9-4046-4db9-a24c-99372e5a0805sonihmhttp://social.technet.microsoft.com/Profile/en-US/?user=sonihmWMI Asynchronously in ASP.NET<p>Hi,<br/><br/>I am developing ASp.net app  using WMI.  I have one button and textbox in web form.<br/>When user click  button, I want to execute below program code under button click<br/><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">protected</span></span><span style="font-size:x-small"> </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">void</span></span><span style="font-size:x-small"> Button1_Click(</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">object</span></span><span style="font-size:x-small"> sender, </span><span style="color:#2b91af;font-size:x-small"><span style="color:#2b91af;font-size:x-small">EventArgs</span></span><span style="font-size:x-small"> e) <p>{ }</p> <font size=2> <p> </p> </font></span></p> <p><br/><br/>I WANT TO EXECUTE BELOW CODE WHEN BUTTON CLICK OCCUR, How can I do it?<br/><br/>using System;<br/>using System.Management;<br/>using System.Windows.Forms;</p> <p>namespace WMISample<br/>{<br/>    public class WMIReceiveEvent<br/>    {<br/>        public WMIReceiveEvent()<br/>        {<br/>            try<br/>            {<br/>                WqlEventQuery query = new WqlEventQuery(<br/>                    &quot;SELECT * FROM Win32_ProcessStartTrace WHERE ProcessName = 'notepad.exe'&quot;);</p> <p>                ManagementEventWatcher watcher = new ManagementEventWatcher(query);<br/>                Console.WriteLine(&quot;Waiting for an event...&quot;);</p> <p>                watcher.EventArrived += <br/>                    new EventArrivedEventHandler(<br/>                    HandleEvent);</p> <p>                // Start listening for events<br/>                watcher.Start();</p> <p>                // Do something while waiting for events<br/>                System.Threading.Thread.Sleep(10000);</p> <p>                // Stop listening for events<br/>                watcher.Stop();<br/>                return;<br/>            }<br/>            catch(ManagementException err)<br/>            {<br/>                MessageBox.Show(&quot;An error occurred while trying to receive an event: &quot; + err.Message);<br/>            }<br/>        }<br/>        <br/>        private void HandleEvent(object sender,<br/>            EventArrivedEventArgs e)<br/>        {<br/>            Console.WriteLine(&quot;Win32_ProcessStartTrace event occurred.&quot;);<br/>        }</p> <p>        public static void Main()<br/>        {<br/>            WMIReceiveEvent receiveEvent = new WMIReceiveEvent();<br/>            return;<br/>        }</p> <p>    }<br/>}</p>Wed, 18 Nov 2009 04:07:31 Z2009-11-24T13:18:13Zhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/5ee26769-4f14-4dba-b652-c75885586b59http://social.technet.microsoft.com/Forums/en/ITCG/thread/5ee26769-4f14-4dba-b652-c75885586b59K R Nhttp://social.technet.microsoft.com/Profile/en-US/?user=K%20R%20NAutomate in task scheduler to runa c# script , whena new file is created in the folder ?I do have a C# script which i need to run automatically whenever a file is created in the folder.<br/>I searched in task scheduler for the above , i did not find any visible solution . Can anyone help me with this ???? Any help is appreciated.<br/><br/>Is there any other way , can anybody guide with this ?<br/><br/>ThanksThu, 12 Nov 2009 06:58:25 Z2009-11-24T13:15:58Zhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/8079383c-d01b-44a3-8e97-72ee36776fe3http://social.technet.microsoft.com/Forums/en/ITCG/thread/8079383c-d01b-44a3-8e97-72ee36776fe3arectechhttp://social.technet.microsoft.com/Profile/en-US/?user=arectechPowershell directory splitterHi,<br/> Our call center makes recordings which are converted to mp3 files and put into a directory with a name of month like this... 2009-01-30. When I get time, I archive them to dvd/dvd-dl .<br/> This time of year, the folders can get quite large and it's a pain to divide them up to fit on dvds.<br/> I made a little diddy to split the folders but I'm looking to see if someone has a better way of doing this or improving the code.<br/> <br/> <br/> # Copy files into DVD or DVD-DL size folders<br/> # With flex room for larger files<br/> <br/> Function CopyFiles{<br/> <br/> # Get source path for the copy operation.<br/> param ($SourceFolder = $(Read-Host &quot;Please Enter The Source Path&quot;))<br/> <br/> $intFiles = 53000<br/> # intFiles = 29000<br/> <br/> If (!(Test-Path -path &quot;$SourceFolder&quot;)) {<br/>    Exit<br/> }<br/> <br/> $Num = 1<br/> $Counter = 0<br/> $TargetFolder = $SourceFolder + &quot;-&quot; + $Num<br/>     New-Item &quot;$TargetFolder&quot; -Type Directory<br/> <br/>   Foreach ($File in (gci $SourceFolder -Recurse)){<br/>     If ($Counter -eq $intFiles){<br/>       $Num = $Num + 1<br/>       $Counter = 0<br/>       $TargetFolder = $SourceFolder + &quot;-&quot; + $Num<br/>       New-Item &quot;$TargetFolder&quot; -Type Directory<br/>     }<br/>     Copy-Item $SourceFolder\$File $TargetFolder<br/>     $Counter = $Counter + 1<br/> <br/>   } <br/> }<br/> CopyFiles<br/> <br/> <br/> thanks,<br/> rcTue, 24 Nov 2009 12:48:10 Z2009-11-24T12:48:14Zhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/7718eecc-c272-436e-b1fb-6e50c9329b11http://social.technet.microsoft.com/Forums/en/ITCG/thread/7718eecc-c272-436e-b1fb-6e50c9329b11B. Voroshttp://social.technet.microsoft.com/Profile/en-US/?user=B.%20VorosHow to export a DictionaryBase Propertycollection object to csv using PowerShell.Hi,<br/> <br/> I am trying to export an Active Directory user's details into a csv file.<br/> Got as far as having the user's details in a System.Collections.DictionaryBase ResultPropertyCollection object.<br/> <br/> I would like to export this to a csv so thet the Keys are the header and the Values are the values.<br/> <br/> More generally, I want to export a collection/hashtable so that the keys/index are the header and the values are the values.<br/> <br/> Struggling to achieve this.<br/> <br/>Sat, 21 Nov 2009 14:08:47 Z2009-11-24T08:52:49Zhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/c5758e58-b94d-4939-93af-e61ce1a443a6http://social.technet.microsoft.com/Forums/en/ITCG/thread/c5758e58-b94d-4939-93af-e61ce1a443a6Bojinovhttp://social.technet.microsoft.com/Profile/en-US/?user=BojinovPowerShell v1 will crash on raising event<span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> <p>Hi guys and gals,</p> <span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> <p>I ve encountered a problem with Powershell v1 and am interested if any of you can induce it.</p> <p>[code]</p> <span style="font-family:Courier New;color:#0000ff;font-size:x-small"><span style="font-family:Courier New;color:#0000ff;font-size:x-small"><span style="font-family:Courier New;color:#0000ff;font-size:x-small"><span style="font-family:Courier New;color:#0000ff;font-size:x-small"><span style="font-family:Courier New;color:#0000ff;font-size:x-small"><span style="font-family:Courier New;color:#0000ff;font-size:x-small"> <p>function</p> </span></span></span></span></span></span> <p><span style="font-family:Courier New;color:#5f9ea0;font-size:x-small"><span style="font-family:Courier New;color:#5f9ea0;font-size:x-small"><span style="font-family:Courier New;color:#5f9ea0;font-size:x-small">watch</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> { </span></span></p> <p><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small">$dir</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#ff0000;font-size:x-small"><span style="font-family:Courier New;color:#ff0000;font-size:x-small"><span style="font-family:Courier New;color:#ff0000;font-size:x-small">=</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small">$args</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small">[0] </span></span></p> <p><span style="font-family:Courier New;color:#0000ff;font-size:x-small"><span style="font-family:Courier New;color:#0000ff;font-size:x-small"><span style="font-family:Courier New;color:#0000ff;font-size:x-small">if</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> (</span></span><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small">$dir</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#ff0000;font-size:x-small"><span style="font-family:Courier New;color:#ff0000;font-size:x-small"><span style="font-family:Courier New;color:#ff0000;font-size:x-small">-eq</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small">$null</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small">){</span></span><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small">$dir</span></span></span><span style="font-family:Courier New;color:#ff0000;font-size:x-small"><span style="font-family:Courier New;color:#ff0000;font-size:x-small"><span style="font-family:Courier New;color:#ff0000;font-size:x-small">=</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small">$((</span></span><strong><span style="font-family:Courier New;color:#5f9ea0;font-size:x-small"><span style="font-family:Courier New;color:#5f9ea0;font-size:x-small"><span style="font-family:Courier New;color:#5f9ea0;font-size:x-small">gi</span></span></span></strong><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> .).Fullname)} </span></span></p> <p><span style="font-family:Courier New;color:#0000ff;font-size:x-small"><span style="font-family:Courier New;color:#0000ff;font-size:x-small"><span style="font-family:Courier New;color:#0000ff;font-size:x-small">if</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> (</span></span><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small">$dir</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#ff0000;font-size:x-small"><span style="font-family:Courier New;color:#ff0000;font-size:x-small"><span style="font-family:Courier New;color:#ff0000;font-size:x-small">-eq</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">&quot;.&quot;</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small">){</span></span><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small">$dir</span></span></span><span style="font-family:Courier New;color:#ff0000;font-size:x-small"><span style="font-family:Courier New;color:#ff0000;font-size:x-small"><span style="font-family:Courier New;color:#ff0000;font-size:x-small">=</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small">$((</span></span><strong><span style="font-family:Courier New;color:#5f9ea0;font-size:x-small"><span style="font-family:Courier New;color:#5f9ea0;font-size:x-small"><span style="font-family:Courier New;color:#5f9ea0;font-size:x-small">gi</span></span></span></strong><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> .).Fullname)} </span></span></p> <p><span style="font-family:Courier New;color:#0000ff;font-size:x-small"><span style="font-family:Courier New;color:#0000ff;font-size:x-small"><span style="font-family:Courier New;color:#0000ff;font-size:x-small">if</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> ([</span></span><span style="font-family:Courier New;color:#008080;font-size:x-small"><span style="font-family:Courier New;color:#008080;font-size:x-small"><span style="font-family:Courier New;color:#008080;font-size:x-small">system.io.directory</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small">]::</span></span><span style="font-family:Courier New;color:#8b4513;font-size:x-small"><span style="font-family:Courier New;color:#8b4513;font-size:x-small"><span style="font-family:Courier New;color:#8b4513;font-size:x-small">exists</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small">(</span></span><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small">$dir</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small">)) {  <span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span></span></span></p> <p><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small">$fsw</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#ff0000;font-size:x-small"><span style="font-family:Courier New;color:#ff0000;font-size:x-small"><span style="font-family:Courier New;color:#ff0000;font-size:x-small">=</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><strong><span style="font-family:Courier New;color:#5f9ea0;font-size:x-small"><span style="font-family:Courier New;color:#5f9ea0;font-size:x-small"><span style="font-family:Courier New;color:#5f9ea0;font-size:x-small">new-object</span></span></span></strong><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">System.IO.FileSystemWatcher</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small">$dir</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span></p> <p><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small">$fsw</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small">.IncludeSubDirectories </span></span><span style="font-family:Courier New;color:#ff0000;font-size:x-small"><span style="font-family:Courier New;color:#ff0000;font-size:x-small"><span style="font-family:Courier New;color:#ff0000;font-size:x-small">=</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small">$false</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span></p> <p><span style="font-family:Courier New;color:#008000;font-size:x-small"><span style="font-family:Courier New;color:#008000;font-size:x-small"><span style="font-family:Courier New;color:#008000;font-size:x-small">#$fsw.SynchronizingObject = </span></span></span></p> <p><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small">$fsw</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small">.add_Changed({</span></span><strong><span style="font-family:Courier New;color:#5f9ea0;font-size:x-small"><span style="font-family:Courier New;color:#5f9ea0;font-size:x-small"><span style="font-family:Courier New;color:#5f9ea0;font-size:x-small">Write-Host</span></span></span></strong><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><em><span style="font-family:Courier New;color:#5f9ea0;font-size:x-small"><span style="font-family:Courier New;color:#5f9ea0;font-size:x-small"><span style="font-family:Courier New;color:#5f9ea0;font-size:x-small">-f</span></span></span></em><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">Red</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">&quot;$((get-date).ToShortTimeString()) : $($_.FullPath)$($_.ChangeType)&quot;</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small">}) </span></span></p> <p><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small">$fsw</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small">.EnableRaisingEvents </span></span><span style="font-family:Courier New;color:#ff0000;font-size:x-small"><span style="font-family:Courier New;color:#ff0000;font-size:x-small"><span style="font-family:Courier New;color:#ff0000;font-size:x-small">=</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small">$true</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small">;<span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span></span></span></p> <p><span style="font-family:Courier New;color:#0000ff;font-size:x-small"><span style="font-family:Courier New;color:#0000ff;font-size:x-small"><span style="font-family:Courier New;color:#0000ff;font-size:x-small">while</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small">(</span></span><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small">$true</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small">){<span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span></span></span></p> <p><span style="font-family:Courier New;color:#0000ff;font-size:x-small"><span style="font-family:Courier New;color:#0000ff;font-size:x-small"><span style="font-family:Courier New;color:#0000ff;font-size:x-small">if</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> (</span></span><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small">$host</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small">.</span></span><span style="font-family:Courier New;color:#8b4513;font-size:x-small"><span style="font-family:Courier New;color:#8b4513;font-size:x-small"><span style="font-family:Courier New;color:#8b4513;font-size:x-small">ui</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small">.</span></span><span style="font-family:Courier New;color:#8b4513;font-size:x-small"><span style="font-family:Courier New;color:#8b4513;font-size:x-small"><span style="font-family:Courier New;color:#8b4513;font-size:x-small">rawui</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small">.</span></span><span style="font-family:Courier New;color:#8b4513;font-size:x-small"><span style="font-family:Courier New;color:#8b4513;font-size:x-small"><span style="font-family:Courier New;color:#8b4513;font-size:x-small">KeyAvailable</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small">){<span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span></span></span></p> <p><span style="font-family:Courier New;color:#0000ff;font-size:x-small"><span style="font-family:Courier New;color:#0000ff;font-size:x-small"><span style="font-family:Courier New;color:#0000ff;font-size:x-small">If</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> ((</span></span><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small">$host</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small">.</span></span><span style="font-family:Courier New;color:#8b4513;font-size:x-small"><span style="font-family:Courier New;color:#8b4513;font-size:x-small"><span style="font-family:Courier New;color:#8b4513;font-size:x-small">ui</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small">.</span></span><span style="font-family:Courier New;color:#8b4513;font-size:x-small"><span style="font-family:Courier New;color:#8b4513;font-size:x-small"><span style="font-family:Courier New;color:#8b4513;font-size:x-small">rawui</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small">.</span></span><span style="font-family:Courier New;color:#8b4513;font-size:x-small"><span style="font-family:Courier New;color:#8b4513;font-size:x-small"><span style="font-family:Courier New;color:#8b4513;font-size:x-small">ReadKey</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small">()).VirtualKeyCode </span></span><span style="font-family:Courier New;color:#ff0000;font-size:x-small"><span style="font-family:Courier New;color:#ff0000;font-size:x-small"><span style="font-family:Courier New;color:#ff0000;font-size:x-small">-eq</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">&quot;88&quot;</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small">) { # ctrl + x<span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span></span></span></p> <p><strong><span style="font-family:Courier New;color:#5f9ea0;font-size:x-small"><span style="font-family:Courier New;color:#5f9ea0;font-size:x-small"><span style="font-family:Courier New;color:#5f9ea0;font-size:x-small">write-host</span></span></span></strong><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">&quot;Stopping watcher...&quot;</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small">; </span></span></p> <p><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small">$fsw</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small">.EnableRaisingEvents </span></span><span style="font-family:Courier New;color:#ff0000;font-size:x-small"><span style="font-family:Courier New;color:#ff0000;font-size:x-small"><span style="font-family:Courier New;color:#ff0000;font-size:x-small">=</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small">$False</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small">; </span></span></p> <p><span style="font-family:Courier New;color:#0000ff;font-size:x-small"><span style="font-family:Courier New;color:#0000ff;font-size:x-small"><span style="font-family:Courier New;color:#0000ff;font-size:x-small">break</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small">; </span></span></p> <p>}}}}</p> <p><span style="font-family:Courier New;color:#0000ff;font-size:x-small"><span style="font-family:Courier New;color:#0000ff;font-size:x-small"><span style="font-family:Courier New;color:#0000ff;font-size:x-small">else</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> {</span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">&quot;Directory $dir does not exist&quot;</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small">} } </span></span></p> <p>[/code]</p> <span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> <p>This snippet is supposed to monitor changes is a selected folder. I ve found it some place (</p> <p><span style="font-family:Courier New;color:#0000ff;font-size:x-small"><span style="font-family:Courier New;color:#0000ff;font-size:x-small"><span style="font-family:Courier New;color:#0000ff;font-size:x-small">do</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> not remember </span></span><strong><span style="font-family:Courier New;color:#5f9ea0;font-size:x-small"><span style="font-family:Courier New;color:#5f9ea0;font-size:x-small"><span style="font-family:Courier New;color:#5f9ea0;font-size:x-small">where</span></span></span></strong><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">but</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">thanks</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">to</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">the</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">one</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">who</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">made</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">it</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small">)<span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> Problem is that the </span></span></span></span><strong><span style="font-family:Courier New;color:#5f9ea0;font-size:x-small"><span style="font-family:Courier New;color:#5f9ea0;font-size:x-small"><span style="font-family:Courier New;color:#5f9ea0;font-size:x-small">PS</span></span></span></strong><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">will</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">crash</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">on</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">raising</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">an</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> event. </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">I</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">can</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">easily</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">induce</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">it</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">on</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">XP</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">and</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> Vista. </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">Just</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">start</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">the</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> script, </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">say</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">that</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">you</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">will</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#5f9ea0;font-size:x-small"><span style="font-family:Courier New;color:#5f9ea0;font-size:x-small"><span style="font-family:Courier New;color:#5f9ea0;font-size:x-small">watch</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">the</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">c:\something</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">folder</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">and</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">create</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">a</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">text</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">file</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#0000ff;font-size:x-small"><span style="font-family:Courier New;color:#0000ff;font-size:x-small"><span style="font-family:Courier New;color:#0000ff;font-size:x-small">in</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> it, </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">containing</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">few</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> symbols. </span></span></p> <p>What I ve tried:<br/><br/>uninstalled the community ext pack PSCX-1.2</p> <span style="font-family:Courier New;color:#ff0000;font-size:x-small"><span style="font-family:Courier New;color:#ff0000;font-size:x-small"><span style="font-family:Courier New;color:#ff0000;font-size:x-small"><span style="font-family:Courier New;color:#ff0000;font-size:x-small"><span style="font-family:Courier New;color:#ff0000;font-size:x-small"><span style="font-family:Courier New;color:#ff0000;font-size:x-small"> <p><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small">install the PSeventing from codeplex (PSEventing 1.1) and use it<span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small">uninstall the community pack (PSCX-1.2)</span></span> <span style="font-family:Courier New;color:#ff0000;font-size:x-small"><span style="font-family:Courier New;color:#ff0000;font-size:x-small"><span style="font-family:Courier New;color:#ff0000;font-size:x-small"><span style="font-family:Courier New;color:#ff0000;font-size:x-small"></span></span></span></span></p> <p>Does not matter what I <span style="font-family:Courier New;color:#0000ff;font-size:x-small"><span style="font-family:Courier New;color:#0000ff;font-size:x-small"><span style="font-family:Courier New;color:#0000ff;font-size:x-small">try</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> every time I call </span></span><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small">$fsw</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small">.add_Changed or </span></span><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small"><span style="font-family:Courier New;color:#800080;font-size:x-small">$fsw</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small">.add_Created, the </span></span><strong><span style="font-family:Courier New;color:#5f9ea0;font-size:x-small"><span style="font-family:Courier New;color:#5f9ea0;font-size:x-small"><span style="font-family:Courier New;color:#5f9ea0;font-size:x-small">PS</span></span></span></strong><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small"><span style="font-family:Courier New;color:#800000;font-size:x-small">will</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> crash.<span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> </span></span></span></span> </p> <p>Could you please <span style="font-family:Courier New;color:#0000ff;font-size:x-small"><span style="font-family:Courier New;color:#0000ff;font-size:x-small"><span style="font-family:Courier New;color:#0000ff;font-size:x-small">try</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> it and let me know it </span></span><span style="font-family:Courier New;color:#0000ff;font-size:x-small"><span style="font-family:Courier New;color:#0000ff;font-size:x-small"><span style="font-family:Courier New;color:#0000ff;font-size:x-small">if</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> works </span></span><span style="font-family:Courier New;color:#0000ff;font-size:x-small"><span style="font-family:Courier New;color:#0000ff;font-size:x-small"><span style="font-family:Courier New;color:#0000ff;font-size:x-small">for</span></span></span><span style="font-family:Courier New;font-size:x-small"><span style="font-family:Courier New;font-size:x-small"> you ? </span></span></p> <p>Thanks</p> <p>Momchil Bojinov</p> </span></span></span></span></span></span></span></span></span></span></span></span>Tue, 24 Nov 2009 08:38:36 Z2009-11-24T08:44:05Zhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/3ed90e05-eff9-440b-9abb-e321b0ab19bbhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/3ed90e05-eff9-440b-9abb-e321b0ab19bbAmjad Shaikhttp://social.technet.microsoft.com/Profile/en-US/?user=Amjad%20ShaikHow to Find local Admin Users for Entire Domain ...( Windows 2003 R2 )Hello Friends,<br/> <br/> We have found some of the domain users are having local admin rights on their PCs.<br/> <br/> We need to find out the users those who are member of Administrator Account &amp; remove them from Domain.<br/> <br/> Is there any tool / Script to find out...???<br/> <br/> Our Domain is Windows 2003 Enterprize R2.<br/> <br/> Kindly help me ..Thanks in Advanced.<hr class="sig">Regards, AmjadMon, 23 Nov 2009 08:54:48 Z2009-11-24T07:51:19Zhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/103a0f65-fb96-4c5d-81e8-cd42406e4b39http://social.technet.microsoft.com/Forums/en/ITCG/thread/103a0f65-fb96-4c5d-81e8-cd42406e4b39cehottlehttp://social.technet.microsoft.com/Profile/en-US/?user=cehottleWMI Query Returns Incorrect TimeGenerated ValueIn March, I wrote &quot;<span style="font-size:11pt;font-family:'Calibri','sans-serif'">The TimeGenerated value returned by a VBScript using the query, SELECT * FROM Win32_NTLogEvent, with a date filter began returning the wrong date after the DST change this past weekend.<span style="">  </span>It is now one hour behind.<span style="">  </span>The script queries the event logs on our production SQL Servers from a central monitoring server.<span style="">  </span>As a result, I had to employ a work-around to have my script work correctly.<span style="">  </span>Has anyone in your group encountered this issue and, if so, how do you fix it?<span style=""> &quot;<br/><br/>Ed Wilson wrote back that it was a bug and there would be a fix released.  In October, Ed pointed me to <span style="font-size:11pt;font-family:'Calibri','sans-serif'">KB 970413 as the fix.  <br/><br/> <p class=MsoPlainText style="margin:0in 0in 0pt"><span style="font-size:x-small;font-family:Arial">We applied the hotfix to all of the database servers that I monitor using a centralized WMI query utility.<span style="">  </span>Unfortunately, the patch does not seem to have resolved the issue.<span style="">  </span>We are seeing the same behavior that we saw in the spring.<span style="">  </span>For example, there is an error entry in the Event Log on one server this morning from 5:43 AM.<span style="">  </span>The WMI query that was run on our monitoring server returned 6:43 AM.<span style="">  </span>Since our utility uses the last poll date/time in the filter for the query, the result of this is that the entry is returned every time the utility is run until an hour has passed (from 5:43 to 6:44).<span style="">  </span>Do you know if there have been other reports of this patch not resolving the issue?<span style="">  </span>Thanks.<br/><br/> <p class=MsoPlainText style="margin:0in 0in 0pt">Chuck Hottle</p> <p class=MsoPlainText style="margin:0in 0in 0pt">Tillamook County Creamery Association</p> <p class=MsoPlainText style="margin:0in 0in 0pt">6855 SW Baylor Street</p> <p class=MsoPlainText style="margin:0in 0in 0pt">Tigard, OR 97223</p> <p class=MsoPlainText style="margin:0in 0in 0pt">503-619-4242 phone</p> <font face=Arial size=2> <p class=MsoPlainText style="margin:0in 0in 0pt"> </p> </font></span></p> <p class=MsoPlainText style="margin:0in 0in 0pt"> </p> </span></span></span>Thu, 19 Nov 2009 21:35:53 Z2009-11-23T22:31:41Zhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/d89913a1-c1bf-49b0-b76f-703740fb5abahttp://social.technet.microsoft.com/Forums/en/ITCG/thread/d89913a1-c1bf-49b0-b76f-703740fb5abaJoe Moylehttp://social.technet.microsoft.com/Profile/en-US/?user=Joe%20MoyleAdd or Move Excel sheet with PowerShellI've had good success with working with Excel and PowerShell except I fail to find how to add or move a sheet to the last position.  It appears to me that the Add and Move methods accept similar arguments so I'm just going to focus on attempting to get it to work with the optional After argument.  Here is what I have.<br/><br/>#get my sheets<br/> $Sheets = $WorkBook.WorkSheets<br/>#find the index of the last one<br/> $SheetCount = $Sheets.Count<br/>#create an object reference to the last sheet<br/> $LastSheet = $WorkBook.Sheets | WHERE {$_.Index -eq $SheetCount}<br/>#attempt to create the new sheet after the last one<br/> $NewSheet = $Sheets.Add($LastSheet After)<br/><br/>It does not work.  Do any of you know how to create a sheet in the last position with PowerShell?<hr class="sig">Joe MoyleMon, 23 Nov 2009 03:54:34 Z2009-11-23T21:36:01Zhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/d11d5592-7b19-4e46-8ad7-972c3cb49f06http://social.technet.microsoft.com/Forums/en/ITCG/thread/d11d5592-7b19-4e46-8ad7-972c3cb49f06.Tim Harrisonhttp://social.technet.microsoft.com/Profile/en-US/?user=.Tim%20HarrisonWireless Configuration ScriptI have been tasked with creating a report that lists the computers in our SCCM 2007 system that currently have wireless SSID's configured and what security they are configured to use (none, WEP, WPA, etc.).  I don't see that as a default report in SCCM, so I was thinking of creating some kind of script that I would deploy to the machines that would write this information to a text file that I could then gather in some way.<br/> <br/> Is there any kind of WMI (or other) script that will list all configured SSIDs and what type of security they're configured to use?<br/> <br/> I was looking at this tool: http://www.symantec.com/connect/articles/how-capture-and-deploy-wlan-profiles<br/> <br/> ... which in 3 seperate commands will find the GUID of the WLAN card, find the SSIDs and find the type of encrypton, keys, etc., but each successive command uses output from the one before it, so I'm not sure how to script it.<br/> <br/> ThanksWed, 18 Nov 2009 21:03:37 Z2009-11-23T20:16:16Zhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/78c70570-6195-4dde-bcf9-91ef9a107905http://social.technet.microsoft.com/Forums/en/ITCG/thread/78c70570-6195-4dde-bcf9-91ef9a107905Leo Clouserhttp://social.technet.microsoft.com/Profile/en-US/?user=Leo%20ClouserVBScript routine to move / hide an IE window on the desktopI have a pop up box that I do not want a user to fill in. I would like to move this window off the desktop, then I will proxy in credentials using VBScript. If I could hide this window - but still be able to access it using VBScript - that would be perfect. Any help would be appreciated.<br/> <br/> Thanks!<br/> <br/> LeoThu, 23 Jul 2009 13:46:12 Z2009-11-23T18:51:19Zhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/7d3f00ec-8270-49e4-aeff-42d07e1d6919http://social.technet.microsoft.com/Forums/en/ITCG/thread/7d3f00ec-8270-49e4-aeff-42d07e1d6919Richard Davies FDChttp://social.technet.microsoft.com/Profile/en-US/?user=Richard%20Davies%20FDCUsing CSVDE export/import a global security groupingHi, new to AD first time using CSVDE,<br/> 2008 domain<br/> <br/> In the domain, created a global security group of 128 users to be applied to some app based policys.<br/> need to export the group to a csv file, to transfer to a test domain which mirrors live, which i think i can export with<br/> CSVDE -d &quot;cn=g-sec-appgrouping,OU=dept,OU=london,DC=blah,dc=com&quot; -f appgroup.csv<br/> Test system is a direct mirror of live.<br/> I now need to import it in to live <br/> Question would the global security be a CN class or an OU class<br/> and would the Import string look like this<br/> CSVDE -i &quot;cn=g-sec-appgrouping,OU=dept,OU=london,DC=blah,dc=com&quot; -f appgroup.csv<br/> Trying to do this in theory at home, to get my head round it,before i get to work to try it out tomorrow.<br/> any advice gratefully welcomed<br/> <br/> <br/>Thu, 19 Nov 2009 21:04:52 Z2009-11-23T18:05:21Zhttp://social.technet.microsoft.com/Forums/en/ITCG/thread/c35e7c1e-d5c1-421c-999a-7affeacd1668http://social.technet.microsoft.com/Forums/en/ITCG/thread/c35e7c1e-d5c1-421c-999a-7affeacd1668sdduhttp://social.technet.microsoft.com/Profile/en-US/?user=sdduPassword expiration e-mail Hello,<br/> <br/> i would like my users to be notified bij e-mail (exchange 2007) when there password is about to expire. Does someone have a script i can use for that ?<br/> <br/> thanks DaveTue, 21 Apr 2009 08:34:47 Z2009-11-23T17:42:25Z