Scripts By David Temple
Beginner_10_2011.ps1 by David Temple 21 Apr 2011 11:56 PM UTCby 2 users
Beginner Event 102 Comments
SYNOPSIS Finds the Average Milliseconds for a CMDLET or Oneliner. DESCRIPTION The Script will process a provided CMDLET or Onliner and determine the Average Millisecond Time it took for PowerShell to run it. IT IS IMPORTANT TO SURROUND THE VALUE OF CMDLET WITH SINGLE QUOTES. PLEASE SEE THE EXAMPLES. After the process finishes it will report the following for example: "Average time of 5 runs of 5 seconds is 4998.5468 milliseconds." PARAMETERS -Iterations Iterations indicates how many times this process will loop through the provided CMDLET or Oneliner (Note: The default value is "5") -CMDLET Name of the CMDLET (with or without Parameters) and or a Oneliner. IT IS IMPORTANT TO SURROUND THE VALUE OF CMDLET WITH SINGLE QUOTES. (Note: You must enter a CMDLET Parameter. It is Mandatory and will prompt you if you forget. Again if you use a CMDLET with Parameters or you are using a Oneliner, surround the CMDLET Value with Single Quotes. See Examples) EXAMPLE .\Beginner_10_2011.ps1 -Iterations 5 -CMDLET 'Start-Sleep -Seconds 5' Average time of 5 runs of 5 seconds is 5004.4389 milliseconds. NOTE: The Single Quotes. EXAMPLE .\Beginner_10_2011.ps1 -CMDLET 'Get-ChildItem -Path C:\Windows\System32 -Filter "*.dll"' Average time of 5 runs of 5 seconds is 150.44608 milliseconds. NOTE: The Single Quotes. EXAMPLE .\Beginner_10_2011.ps1 -Iterations 2 -CMDLET 'Get-ChildItem C:\Windows -Filter "*.txt" -Recurse' Average time of 2 runs of 5 seconds is 821.15165 milliseconds. NOTE: The Single Quotes.
Beginner_09_2011.ps1 by David Temple 21 Apr 2011 05:48 AM UTCby 3 users
Beginner Event 93 Comments
The Script will create a Log File using the Year, Month and Day (i.e. 20110421.log) This Script will verify the directories configured in this script exist. If they do exist not they will be created. To modify look for the section labeled "#Directory Configuration Array" and modify accordingly. Once the Directories are verified (or created) It beings to collect the information for the local system to determine the Log File name and if it already exists. If it does it will assign a Name to the Long File using the following Year, Month, Day, Hour, Minute and Second to avoid duplication of Log File Name. It is important to note that while the script is running it will append to the created Log File. Once the Script completes and if it is run again it will create a new log file leaving the original intact. The last process to run is a LogCleanUp Function. It is currently configured to clean up Files in the Logs Directory that are older than 15 days. If this Function is not needed a Simple Comment "#" in front of the LogCleanUp Function or deletion of that line will disable it from running. To Adjust the number of days Find the LogCleanUp Function and change the $Daysback Variable accordingly.
Beginner_08_2011.ps1 by David Temple 20 Apr 2011 05:22 AM UTCby 2 users
Beginner Event 85 Comments
Finds all files in the Directory provided. The Script will write the following information to a CSV File: Name of the File Found - Name Size of the File Found - File Size in (bytes) When the File was last written to = LastWriteTime After the process finishes it will open the CSV File, provided Excel is installed.
Beginner_07_2011.ps1 by David Temple 16 Apr 2011 06:33 AM UTCby 2 users
Beginner Event 71 Comments
The Script will echo the following information to the host: "There are XXX days until the end of the fiscal year." Note: A quick Edit of the Switch Parameters "-Year, -Month or -Day" will allow this basic script to be reused next year (and the year after that and so on).
Beginner_06_2011.ps1 by David Temple 16 Apr 2011 05:05 AM UTCby 2 users
Beginner Event 61 Comments
The Script will check for the existence of the word "failed" located in the WindowsUpdate.Log file and echoes the information to the host. Below is the shortest I could get the one liner. GC is the alias for "Get-Content" which I pipe over to "Select-String" which does not have an alias. "-Patt" is the shortest switch parameter I could use without confusing folks with the "-Path" Switch Parameter. I did test without the "-Pattern" Switch Parameter which the "Select-String" was intelligent enough to figure out from the information I was passing to it that it was not a path statement but a pattern, however I thought it would be best practice to include the Switch Parameter.
Beginner_05_2011.ps1 by David Temple 15 Apr 2011 04:37 AM UTCby 2 users
Beginner Event 5
Connects to a List of Computers (if a ListOfComputers.txt file exists) or connects to the Local Computer to collect the user name, computer name, domain name, and the operating system information and logs it to a text file named Basic_Computer_Information.txt
Beginner_03_2011.ps1 by David Temple 14 Apr 2011 06:37 AM UTCby 2 users
Beginner Event 42 Comments
Generates a List of Services and is sorted by by the Service Account Name
Get-PauseableService by David Temple 12 Apr 2011 05:51 AM UTCby 2 users
Beginner Event 2
Get-PauseableService displays Running Services that can be Paused. In addition you can name a remote machine or supply a path to a text file to work with a list of remote machines. If you do not supply a Status of 'Running', 'Stopped' or 'Paused' it will run against all of the Services regardless of status to determine if a Service can be paused.
Beginner_01_2011.ps1 by David Temple 11 Apr 2011 04:25 AM UTCby 2 users
Beginner Event 12 Comments
Unfortunately, this does not solve the issue presented in 2001 Scripting Games Event 1. My limited Scripting abilities got me stuck at this point. I am hoping for some direction so that I can finish this challenge on my own. I am not even sure if I was headed in the right direction. Thanks in Advance, David
- Advanced Event 1 (83)
- Advanced Event 10 (34)
- Advanced Event 2 (63)
- Advanced Event 3 (50)
- Advanced Event 4 (51)
- Advanced Event 5 (38)
- Advanced Event 6 (51)
- Advanced Event 7 (39)
- Advanced Event 8 (27)
- Advanced Event 9 (46)
- Beginner Event 1 (149)
- Beginner Event 10 (85)
- Beginner Event 2 (139)
- Beginner Event 3 (100)
- Beginner Event 4 (108)
- Beginner Event 5 (93)
- Beginner Event 6 (102)
- Beginner Event 7 (108)
- Beginner Event 8 (90)
- Beginner Event 9 (92)