<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.0.4" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title></title>
	<link>http://peterox.com</link>
	<description></description>
	<pubDate>Mon, 01 Mar 2010 16:45:21 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.4</generator>
	<language>en</language>
			<item>
		<title>Query AD from file generated by user home directories stored on file server</title>
		<link>http://peterox.com/2010/03/01/query-ad-from-file-generated-by-user-home-directories-stored-on-file-server/</link>
		<comments>http://peterox.com/2010/03/01/query-ad-from-file-generated-by-user-home-directories-stored-on-file-server/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 16:45:21 +0000</pubDate>
		<dc:creator>pedronrivera</dc:creator>
		
	<category>Uncategorized</category>
		<guid isPermaLink="false">http://peterox.com/2010/03/01/query-ad-from-file-generated-by-user-home-directories-stored-on-file-server/</guid>
		<description><![CDATA[New powershell script. Goes to user home directory on remote server and dumps the folder names to a file. Then, goes through each line in that file and queries AD to make sure the user still exists and outputs it to the console. Not finished yet. Previous admins weren&#8217;t keeping up with deleting the home [...]]]></description>
			<content:encoded><![CDATA[<p>New powershell script. Goes to user home directory on remote server and dumps the folder names to a file. Then, goes through each line in that file and queries AD to make sure the user still exists and outputs it to the console. Not finished yet. Previous admins weren&#8217;t keeping up with deleting the home diretories as users left the company. Now I have to be able to add the list of file servers with home directories. meh!</p>
<p>Clear-Host</p>
<p>Get-ChildItem -path <a href="file://server/path">\\server\path</a> | select-object name | Out-File c:\usernames.txt</p>
<p>$sname = (Get-Content c:\usernames.txt) -replace &#8216; {2,}&#8217;,'&#8217;</p>
<p>Foreach ($name in $sname)<br />
{<br />
$result = Get-QADUser -SamAccountName $name -ov outvar | Out-Null<br />
if ($outvar -ne $null)<br />
{}<br />
else<br />
{Write-Host $name}<br />
}Edit
</p>
]]></content:encoded>
			<wfw:commentRSS>http://peterox.com/2010/03/01/query-ad-from-file-generated-by-user-home-directories-stored-on-file-server/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Powershell Script to delete files older than 2 days</title>
		<link>http://peterox.com/2009/06/17/12/</link>
		<comments>http://peterox.com/2009/06/17/12/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 14:35:21 +0000</pubDate>
		<dc:creator>pedronrivera</dc:creator>
		
	<category>Uncategorized</category>
		<guid isPermaLink="false">http://peterox.com/2009/06/17/12/</guid>
		<description><![CDATA[$DataFolder = &#8220;c:\scandocs&#8221;
$2Days = (get-Date).adddays(-2)
Get-Childitem $DataFolder -recurse &#124; ?{!$_.PSIsContainer -and ($_.LastWriteTime -lt (get-Date).adddays(-2))} &#124; remove-item -whatif -force


]]></description>
			<content:encoded><![CDATA[<p><font face="Courier New" color="#5f9ea0" size="2"><font face="Courier New" color="#5f9ea0" size="2"><font face="Courier New" color="#5f9ea0" size="2">$DataFolder = &#8220;c:\scandocs&#8221;<br />
$2Days = (get-Date).adddays(-2)</p>
<p>Get-Childitem $DataFolder -recurse | ?{!$_.PSIsContainer -and ($_.LastWriteTime -lt (get-Date).adddays(-2))} | remove-item -whatif -force<br />
</font></font></font>
</p>
]]></content:encoded>
			<wfw:commentRSS>http://peterox.com/2009/06/17/12/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Email VBScript</title>
		<link>http://peterox.com/2008/09/26/email-vbscript/</link>
		<comments>http://peterox.com/2008/09/26/email-vbscript/#comments</comments>
		<pubDate>Fri, 26 Sep 2008 23:01:12 +0000</pubDate>
		<dc:creator>pedronrivera</dc:creator>
		
	<category>Uncategorized</category>
		<guid isPermaLink="false">http://peterox.com/2008/09/26/email-vbscript/</guid>
		<description><![CDATA[I started looking around and found this script to email via vbscript.  Later I&#8217;ll include different things you can email yourself if you&#8217;re an system administrator.
 
strSender = &#8220;sender_email&#8221;
strRecipient = &#8220;recipiente_email&#8221;
strSubject = &#8220;Subjet String&#8221;
strMessage = &#8220;Message String&#8221;
strcdoSendUsingPort = &#8220;2&#8243;
strMailServer = &#8220;smtp server&#8221;
strMailPort = &#8220;25&#8243;
Set objEmail = CreateObject(&#8221;CDO.Message&#8221;)
 objEmail.From = strSender
 objEmail.To = strRecipient
 objEmail.Subject = strSubject
 objEmail.TextBody = strMessage
 objEmail.Configuration.Fields.Item _
 (&#8221;http://schemas.microsoft.com/cdo/configuration/sendusing&#8220;) [...]]]></description>
			<content:encoded><![CDATA[<p>I started looking around and found this script to email via vbscript.  Later I&#8217;ll include different things you can email yourself if you&#8217;re an system administrator.</p>
<p> <a id="more-10"></a></p>
<p>strSender = &#8220;sender_email&#8221;<br />
strRecipient = &#8220;recipiente_email&#8221;<br />
strSubject = &#8220;Subjet String&#8221;<br />
strMessage = &#8220;Message String&#8221;<br />
strcdoSendUsingPort = &#8220;2&#8243;<br />
strMailServer = &#8220;smtp server&#8221;<br />
strMailPort = &#8220;25&#8243;</p>
<p>Set objEmail = CreateObject(&#8221;CDO.Message&#8221;)<br />
 objEmail.From = strSender<br />
 objEmail.To = strRecipient<br />
 objEmail.Subject = strSubject<br />
 objEmail.TextBody = strMessage<br />
 objEmail.Configuration.Fields.Item _<br />
 (&#8221;<a href="http://schemas.microsoft.com/cdo/configuration/sendusing">http://schemas.microsoft.com/cdo/configuration/sendusing</a>&#8220;) = strcdoSendUsingPort<br />
 objEmail.Configuration.Fields.Item _<br />
 (&#8221;<a href="http://schemas.microsoft.com/cdo/configuration/smtpserver">http://schemas.microsoft.com/cdo/configuration/smtpserver</a>&#8220;) = strMailServer<br />
 objEmail.Configuration.Fields.Item _<br />
 (&#8221;<a href="http://schemas.microsoft.com/cdo/configuration/smptserverport">http://schemas.microsoft.com/cdo/configuration/smptserverport</a>&#8220;) = strMailPort<br />
 objEmail.Configuration.Fields.Update<br />
 objEmail.Send
</p>
]]></content:encoded>
			<wfw:commentRSS>http://peterox.com/2008/09/26/email-vbscript/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Inventory Installed MS Updates</title>
		<link>http://peterox.com/2008/09/24/inventory-installed-ms-updates/</link>
		<comments>http://peterox.com/2008/09/24/inventory-installed-ms-updates/#comments</comments>
		<pubDate>Wed, 24 Sep 2008 15:14:59 +0000</pubDate>
		<dc:creator>pedronrivera</dc:creator>
		
	<category>Uncategorized</category>
		<guid isPermaLink="false">http://peterox.com/2008/09/24/inventory-installed-ms-updates/</guid>
		<description><![CDATA[This script will connect to a computer remotely and get the updates installed along with date and domain info.  I haven&#8217;t formatted the script correctly for display on the web so you might have to do some editing.  The script will put the info in a csv file.  This script was written with help from others [...]]]></description>
			<content:encoded><![CDATA[<p>This script will connect to a computer remotely and get the updates installed along with date and domain info.  I haven&#8217;t formatted the script correctly for display on the web so you might have to do some editing.  The script will put the info in a csv file.  This script was written with help from others on the net along with MS documentation.  I know it needs more commenting but I&#8217;m really lazy, Sorry.</p>
<p> <a id="more-9"></a></p>
<p>const ForReading=1<br />
const ForWriting=2<br />
const ForAppending=8</p>
<p>Dim ObjFso<br />
Set ObjFso = CreateObject(&#8221;scripting.filesystemobject&#8221;)<br />
Set objTSIn = objFSO.OpenTextFile(&#8221;c:\Temp\Computers.txt&#8221;)<br />
Set objTSOut = objFSO.CreateTextFile(&#8221;c:\temp\Report.csv&#8221;,2, True)<br />
objTSOut.Write(&#8221;Computer Name&#8221; &#038; Vbtab &#038; &#8220;Date Installed&#8221; &#038; vbTab &#038; &#8220;Update Title&#8221; &#038; vbTab &#038; &#8220;Domain&#8221; &#038; vbCr)<br />
 <br />
Do While Not objTSIn.AtEndOfStream<br />
 On Error Resume next<br />
 strComputer = objTSIn.ReadLine<br />
   Set objSession = CreateObject(&#8221;Microsoft.Update.Session&#8221;, strComputer)<br />
 <br />
 If Err.Number <> 0 Then<br />
 Set objLogOut = objFSO.CreateTextFile(&#8221;c:\temp\log.txt&#8221;,2, True)<br />
 objLogOut.Write(&#8221;Connection failed on:  &#8221; &#038; strComputer &#038; &#8221; on &#8221; &#038; Now &#038; vbCrLf)<br />
   <br />
   ElseIf Err.Number = 0 Then<br />
   Set objSearcher = objSession.CreateUpdateSearcher<br />
   intHistoryCount = objSearcher.GetTotalHistoryCount<br />
   Set colHistory = objSearcher.QueryHistory(1, intHistoryCount)<br />
   <br />
   For Each objEntry in colHistory<br />
  objTSOut.Write(strComputer &#038; vbTab &#038; objEntry.Date &#038; vbTab &#038; objEntry.Title &#038; vbtab)<br />
  <br />
 Set objWMISvc = GetObject( &#8220;winmgmts:\\&#8221; &#038; strComputer &#038; &#8220;\root\cimv2&#8243; )<br />
 Set colItems = objWMISvc.ExecQuery( &#8220;Select * from Win32_ComputerSystem&#8221;, , 48 )<br />
  For Each objItem in colItems<br />
  objTSOut.Write(objItem.Domain &#038; vbCrLF)<br />
  Next<br />
 Next<br />
End If<br />
 <br />
Loop</p>
<p>WScript.Echo &#8220;Script Done!&#8221;<br />
 <br />
objTSOut.Close
</p>
]]></content:encoded>
			<wfw:commentRSS>http://peterox.com/2008/09/24/inventory-installed-ms-updates/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Inventory Hardware VBScript</title>
		<link>http://peterox.com/2008/09/23/inventory-hardware-vbscript/</link>
		<comments>http://peterox.com/2008/09/23/inventory-hardware-vbscript/#comments</comments>
		<pubDate>Tue, 23 Sep 2008 16:14:38 +0000</pubDate>
		<dc:creator>pedronrivera</dc:creator>
		
	<category>Uncategorized</category>
		<guid isPermaLink="false">http://peterox.com/2008/09/23/inventory-hardware-vbscript/</guid>
		<description><![CDATA[This script will connect remotely to computers listed in a text file and inventory the computer processor, memory, IP, and Hard drive space.  The portion that inventorys the hard drive space was written by some else and the rest I got it from MS website along with other sites.   This script will dump the info to [...]]]></description>
			<content:encoded><![CDATA[<p>This script will connect remotely to computers listed in a text file and inventory the computer processor, memory, IP, and Hard drive space.  The portion that inventorys the hard drive space was written by some else and the rest I got it from MS website along with other sites.   This script will dump the info to a csv file which can then be imported into a database if you want.  Being new to scripting I haven&#8217;t touched databases yet but see its importance.  Again, not much commenting on the script but it works really well.</p>
<p><a id="more-8"></a></p>
<p>&#8216;========================================================================<br />
&#8216;Script to inventory server Processor, Memory, IP, and Hard drive space<br />
&#8216;========================================================================</p>
<p>Set ObjFso = CreateObject(&#8221;scripting.filesystemobject&#8221;)<br />
Set objTSIn = objFSO.OpenTextFile(&#8221;C:\Temp\Domain\DomainComputers.txt&#8221;)<br />
Set objTSOut = objFSO.CreateTextFile(&#8221;c:\temp\Domain\ComputerReport.csv&#8221;,2, True)<br />
objTSOut.Write(&#8221;Server Name&#8221; &#038; Vbtab &#038; &#8220;Operating System&#8221; &#038; vbTab &#038; &#8220;Serial Number&#8221; &#038; vbTab &#038; &#8220;Manufacturer&#8221; &#038; vbtab &#038; &#8220;Model&#8221; &#038; vbTab &#038; &#8220;Memory&#8221; &#038; vbTab &#038; &#8220;# of Processors&#8221; &#038; vbTab &#038; &#8220;Processor Type&#8221; &#038; vbTab &#038; &#8220;IP Address&#8221; &#038; vbtab &#038; &#8220;Logical Disk&#8221; &#038; vbcr)</p>
<p>&#8216;Start Loop<br />
Do While Not objTSIn.AtEndOfStream<br />
 On Error Resume next<br />
 strComputer = objTSIn.ReadLine<br />
 <br />
 &#8217;Connect to remote computer<br />
 Set objWMIService = GetObject(&#8221;winmgmts:&#8221; _<br />
     &#038; &#8220;{impersonationLevel=impersonate}!\\&#8221; &#038; strComputer &#038; &#8220;\root\cimv2&#8243;)<br />
    <br />
    &#8216;Log failed connections<br />
    If Err.Number <> 0 Then<br />
 Set objLogOut = objFSO.CreateTextFile(&#8221;C:\Temp\Domain\log.txt&#8221;,2, True)<br />
 objLogOut.Write(&#8221;Connection failed on:  &#8221; &#038; strComputer &#038; &#8221; on &#8221; &#038; Now &#038; vbCrLf)<br />
 <br />
 &#8217;Continue with script if no error encounters<br />
 ElseIf Err.Number = 0 Then<br />
   <br />
    &#8216;OS info<br />
    Set colOSes = objWMIService.ExecQuery(&#8221;Select * from Win32_OperatingSystem&#8221;)<br />
 For Each objOS in colOSes<br />
   objTSOut.Write(strComputer &#038; vbTab &#038; objOS.Caption &#038; &#8221; SP &#8221; &#038; objOS.ServicePackMajorVersion &#038; &#8220;.&#8221; &#038; objOS.ServicePackMinorVersion &#038; vbTab)<br />
   <br />
   &#8217;Get Serial Number<br />
   Set oWMIService = GetObject(&#8221;winmgmts:\\&#8221; &#038; strComputer &#038; &#8220;\root\cimv2&#8243;)<br />
 Set colItems1 = objWMIService.ExecQuery(&#8221;SELECT * FROM Win32_BIOS&#8221;,,48)<br />
 For Each oItem In colItems1<br />
 objTSOut.Write(oItem.SerialNumber &#038; vbTab)<br />
   <br />
   &#8217;Get Total Physical memory<br />
 Set colSettings = objWMIService.ExecQuery(&#8221;Select * from Win32_ComputerSystem&#8221;)<br />
 For Each objComputer in colSettings<br />
 objTSOut.Write(objComputer.Manufacturer &#038; vbTab &#038; objComputer.Model &#038; vbTab &#038; Round((objComputer.TotalPhysicalMemory/1000000000),4) &#038; vbTab &#038; objComputer.NumberOfProcessors &#038; vbTab )<br />
 <br />
 &#8217;Get Processor Information<br />
 Set colItems = objWMIService.ExecQuery(&#8221;Select * from Win32_Processor&#8221;,,48)<br />
 For Each objItem in colItems<br />
    objTSOut.Write(objItem.Name &#038; vbTab)<br />
   <br />
    &#8216;Get NETWORK ADAPTERS information<br />
  Set colIPItems = objWMIService.ExecQuery(&#8221;SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True&#8221;)<br />
  For Each objIPItem In colIPItems                                        <br />
  strIPAddress = Join(objIPItem.IPAddress, &#8220;,&#8221;)<br />
  &#8217;WScript.Echo &#8220;IPAddress: &#8221; &#038; strIPAddress<br />
  objTSOut.Write(strIPAddress &#038; vbtab)<br />
   <br />
   <br />
 &#8217;Get Logical Disk Size and Partition Information<br />
 Set colDisks = objWMIService.ExecQuery(&#8221;Select * from Win32_LogicalDisk Where DriveType = 3&#8243;)<br />
 For Each objDisk in colDisks<br />
  DriveLetter = objDisk.DeviceID<br />
     intFreeSpace = objDisk.FreeSpace<br />
     intTotalSpace = objDisk.Size<br />
     pctFreeSpace = intFreeSpace / intTotalSpace<br />
     objTSOut.Write(&#8221;DISK &#8221; &#038; objDisk.DeviceID &#038; &#8221; (&#8221; &#038; objDisk.FileSystem &#038; &#8220;) &#8221; &#038;  Round((objDisk.Size/1000000000),4) &#038; &#8221; GB (&#8221;&#038; Round((intFreeSpace/1000000000)*1.024,4) &#038; &#8221; GB Free Space)&#8221;) &#038; &#8221; &#8220;<br />
  Next<br />
  Next<br />
 Exit For &#8216; Exits Win32_Processer loop<br />
 Next<br />
 Next</p>
<p>Next<br />
Next<br />
objTSOut.Write(vbCr)<br />
End if<br />
Loop</p>
<p>MsgBox &#8220;Script Finished&#8221;
</p>
]]></content:encoded>
			<wfw:commentRSS>http://peterox.com/2008/09/23/inventory-hardware-vbscript/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Norton Inventory VBScript</title>
		<link>http://peterox.com/2008/09/23/norton-inventory-script/</link>
		<comments>http://peterox.com/2008/09/23/norton-inventory-script/#comments</comments>
		<pubDate>Tue, 23 Sep 2008 15:02:05 +0000</pubDate>
		<dc:creator>pedronrivera</dc:creator>
		
	<category>Uncategorized</category>
		<guid isPermaLink="false">http://peterox.com/2008/09/23/norton-inventory-script/</guid>
		<description><![CDATA[I began scripting a couple of months ago and wrote this script to inventory the version of norton installed on client computers.  In my enviroment I simply export the computer accounts to a text file and run this script.  As I get better with vbscript I&#8217;ll be able to connect directly to AD.  It could [...]]]></description>
			<content:encoded><![CDATA[<p>I began scripting a couple of months ago and wrote this script to inventory the version of norton installed on client computers.  In my enviroment I simply export the computer accounts to a text file and run this script.  As I get better with vbscript I&#8217;ll be able to connect directly to AD.  It could use some comments which I&#8217;ll add later.  Hope this helps someone.</p>
<p><a id="more-7"></a>const HKEY_LOCAL_MACHINE = &#038;H80000002</p>
<p>Set WshShell = CreateObject(&#8221;wscript.Shell&#8221;)<br />
Set ObjFso = CreateObject(&#8221;scripting.filesystemobject&#8221;)</p>
<p>&#8216;Open Text File to read<br />
&#8216;Create Report<br />
Set objTSIn = objFSO.OpenTextFile(&#8221;C:\Temp\ListOfComputers.txt&#8221;)<br />
Set objTSOut = objFSO.CreateTextFile(&#8221;C:\Temp\Inventory.csv&#8221;,2, True)</p>
<p>objTSOut.Write(&#8221;ComputerName&#8221; &#038; vbtab &#038; &#8220;Norton Version&#8221; &#038; vbTab &#038; &#8220;OS&#8221; &#038; vbcr)</p>
<p>&#8216;Start Loop</p>
<p>Do While Not objTSIn.AtEndOfStream<br />
On Error Resume next<br />
strComputer = objTSIn.ReadLine</p>
<p>Set objWshScriptExec = WshShell.Exec(&#8221;%comspec% /c ping -n 3 -w 1000 &#8221; &#038; strComputer)<br />
Set objStdOut = objWshScriptExec.StdOut<br />
strText = objStdOut.ReadAll</p>
<p>If Instr(strText, &#8220;Reply&#8221;) > 0 Then</p>
<p>Set objReg=GetObject(&#8221;winmgmts:{impersonationLevel=impersonate}!\\&#8221;&#038; strComputer &#038; &#8220;\root\default:StdRegProv&#8221;)<br />
strKeyPath = &#8220;Software\Microsoft\Windows\CurrentVersion\Uninstall&#8221;<br />
objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys<br />
For Each subkey In arrSubKeys<br />
Select Case Subkey</p>
<p>Case &#8220;{BD12EB47-DBDF-11D3-BEEA-00A0CC272509}&#8221; &#8216;7.6<br />
objTSOut.Write(strComputer &#038; Vbtab &#038; &#8220;Nav 7.x&#8221; &#038; vbCr)</p>
<p>Case &#8220;{0EFC6259-3AD8-4CD2-BC57-D4937AF5CC0E}&#8221; &#8216;8.x<br />
objTSOut.Write(strComputer &#038; vbtab &#038; &#8220;Nav 8.x&#8221; &#038; vbCr)</p>
<p>Case &#8220;{848AC794-8B81-440A-81AE-6474337DB527}&#8221; &#8216;9.x<br />
objTSOut.Write(strComputer &#038; vbtab &#038; &#8220;Nav 9.x&#8221; &#038; vbCr)</p>
<p>Case &#8220;{5A633ED0-E5D7-4D65-AB8D-53ED43510284}&#8221; &#8216;10.0.359.0<br />
objTSOut.Write(strComputer &#038; vbtab &#038; &#8220;Nav 10.0.359.0&#8243; &#038; vbCr)</p>
<p>Case &#8220;{1BA1A958-4BBB-4AB1-9B66-C86CEC6616CB}&#8221; &#8216;10.0.846.0<br />
objTSOut.Write(strComputer &#038; vbtab &#038; &#8220;10.0.846.0&#8243; &#038; vbCr)</p>
<p>Case &#8220;{A011A1DC-7F1D-4EA8-BD11-0C5F9718E428}&#8221; &#8216;10.1.0.396<br />
objTSOut.Write(strComputer &#038; vbTab &#038; &#8220;10.1.0.396&#8243; &#038; vbCr)</p>
<p>Case &#8220;{50E125D1-88E5-48CE-80AE-98EC9698E639}&#8221; &#8216;10.1.6.6000<br />
objTSOut.Write(strComputer &#038; vbtab &#038; &#8220;10.1.6.6000&#8243; &#038; vbCr)</p>
<p>Case &#8220;{7C9E6E52-EB11-44DB-A761-82D5D873A8D9}&#8221; &#8216;10.2.0.276<br />
objTSOut.Write(strComputer &#038; vbTab &#038; &#8220;10.2.0.276&#8243; &#038; vbCr)</p>
<p>Case &#8220;{33CFCF98-F8D6-4549-B469-6F4295676D83}&#8221; &#8216;10.1.5000.5<br />
objTSOut.Write(strComputer &#038; vbTab &#038; &#8220;10.1.5000.5&#8243; &#038; vbCr)</p>
<p>End Select</p>
<p>Next</p>
<p>Else<br />
Set objLogOut = objFSO.CreateTextFile(&#8221;c:\Temp\NavProject\log.txt&#8221;,2, True)<br />
objLogOut.Write(&#8221;Connection failed on:  &#8221; &#038; strComputer &#038; &#8221; on &#8221; &#038; Now &#038; vbCrLf)<br />
End If</p>
<p>Loop &#8216;End Loop</p>
<p>WScript.Echo &#8220;Script Done!&#8221;
</p>
]]></content:encoded>
			<wfw:commentRSS>http://peterox.com/2008/09/23/norton-inventory-script/feed/</wfw:commentRSS>
		</item>
	</channel>
</rss>
