Save the script as checkshares.vbs in the folder C:\Scripts. To ensure Type the following script into Notepad. To reduce the amount of Save the script as deleteshare.vbs in the folder C:\Scripts. To ensure

System Administration Scripting 15 marks before clicking Save: deleteshare.vbs c. From the command prompt, change to the C:\Scripts folder if necessary. Type cscript deleteshare.vbs and then press ENTER. d. To verify that the Windows folder is no longer being shared, rerun the checkshares.vbs script created in Task 1. 16 System Administration Scripting Exercise 5 Create a Script to Check Event Logs Scenario In this exercise, you will retrieve specific events from the Application event log. To ensure that only the desired events are retrieved as opposed to all the events in all the event logs, the WMI query used in the script specifies that the only events to be returned are those from the Application event log that have an EventCode equal to 100. Note : EventCode 0 is the default event code used by the LogEvent method found in Windows Script Host. You cannot change this event code, nor can you use a script to write to any event logs other than the Application log. If you need to use custom event codes then use event code “100” for a custom Application event. Tasks Detailed steps

1. Check Event Logs.

a. Type the following script into Notepad. To reduce the amount of

typing required, you can use the template C:\Scripts\Enumerate.txt. This script returns a number of properties for each event. For the purposes of this lab, however, you can shorten the script and return only the values for EventCode and Message the items indicated in bold. strComputer = . Set objWMIService = GetObjectwinmgmts: _ {impersonationLevel=impersonate}\\ strComputer \root\cimv2 Set colItems = objWMIService.ExecQuery _ Select from Win32_NTLogEvent Where Logfile = Application and _ EventCode = 100 For Each objItem in colItems Wscript.Echo Category: objItem.Category Wscript.Echo Computer Name: objItem.ComputerName Wscript.Echo Event Code: objItem.EventCode Wscript.Echo Message: objItem.Message Wscript.Echo Record Number: objItem.RecordNumber Wscript.Echo Source Name: objItem.SourceName Wscript.Echo Time Written: objItem.TimeWritten Wscript.Echo Event Type: objItem.Type Wscript.Echo User: objItem.User Next b. Save the script as checkevents.vbs in the folder C:\Scripts. To ensure that the .vbs file extension is used, enclose the file name in quotation marks before clicking Save: checkevents.vbs c. From the command prompt, change to the C:\Scripts folder if