Tuesday, August 28, 2007

Computer Bios Script (bios.vbs)

Here is a quick little script that will display both the manufacturer and serial of your computer. You can easily add in a variable to create a list of ALL of the machines in your environment. Say... from AD.... :P

On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_BIOS",,48)
For Each objItem in colItems
Wscript.Echo "Manufacturer: " & objItem.Manufacturer
Wscript.Echo "SerialNumber: " & objItem.SerialNumber

Next

Auto Accept Agent for Exchange

Here is a neat thing that you can implement for your resource mailboxes. This service will create an Auto Accept Agent on your Exchange Server. This service can send an email to your end user as a confirmation of the acceptance or denial of the booking of the resource.

Once you setup the Auto Except Service on your Exchange Server, here is the script that you will need to use in order to register your resource.

cscript RegisterMailbox.vbs {/m:mailbox@domain.com | /f:file.txt} [/t:domain\AgentAccountName] [/u] [/DEBUG]

Where:
/m
The primary SMTP address of the mailbox that you want to register. Use this switch when registering or unregistering a single mailbox.
/f
The name of the text file that contains the primary SMTP addresses of the mailboxes that you want to register. Use this switch when registering or unregistering multiple mailboxes. You must create the text file before using this script. This switch cannot be used with the /m switch.

Note
If the text file is not located in the same folder as the RegisterMailbox.vbs script, you must provide the full path to the location of your text file.

/t
Specifies the account that will be granted full mailbox access. This is typically the domain account that the Auto Accept Agent is running as on the local server. The account must be provided as domain\accountname. If Auto Accept Agent is running as Local System, you do not need to specify this switch unless you want to grant permissions to a domain account that you can use to monitor the resource mailboxes, which is necessary for the MailboxStatus.vbs script described later in this chapter.
/u
Attempts to remove the mailbox binding. Additionally, this switch also attempts to remove full mailbox access for the Auto Accept Agent account specified in the /t switch.
/DEBUG
Outputs verbose debug information you can use to diagnose issues.

For example, if you were using a file named Mailboxes.txt to register multiple mailboxes, where the Agent's security context is example\AgentAccount, you might type the following at the command prompt:
C:\>cscript RegisterMailbox.vbs /f:Mailboxes.txt /t:example\AgentAccount

For more information see: http://technet.microsoft.com/en-us/library/bb124104.aspx

Wednesday, August 08, 2007

Cisco IOS Commands

Recently I have been working on some Cisco equipment. Here are some commands that I found to be really useful.


Find the MAC from an IP address
Show ip arp (ip address)

Find the port number associated with the MAC address:
Show mac-address-table address (MAC Address)

Adding a Virtual LAN (VLAN) or Changing the VLAN on a port:
Once you are in configuration mode and set your interface or range of interfaces – All you have to do is..
Switchport access vlan (number)

But, My most used command is:
Show interface status – This will give you a summary of all the ports, descriptions (if present), connected/notconnected, and speed…



I think that I will need to start studying for that CCNA…

Tuesday, August 07, 2007

Files that are older than 45 days old.

Here is a script for all those file server administrators. This script will find all files that are "created" more than 45 days ago and then delete them. I generally export the results to a text file for review, but that is totally up to you.

'This script is to find and then delete any files that are older than 45 days old
'Version 1.0

Set fso = CreateObject ("Scripting.FileSystemObject")

If WScript.Arguments.Count = 0 then
RecurseDirectory "."
Else
RecurseDirectory WScript.Arguments.Item(0)
End If

Sub Recursedirectory(strDir)
Set refFolder = fso.GetFolder(strDir)


'Process files in directory
For Each refFile in refFolder.Files
if cDate(refFile.DateCreated) <= now()-45 then
refFile.Delete


end if
Next

Then Recurse down directory tree
For Each refSubFolder in refFolder.SubFolders
RecurseDirectory refSubFolder.Path
if refSubFolder.Files.Count = 0 then
refSubFolder.Delete
End If
Next
end sub


'cscript //nologo 45days.vbs >> 45day.csv