Scripts By Boe Prox

  • New-TemporaryFile by Boe Prox 22 Apr 2011 02:37 AM UTC
    by 2 users

    Advanced Event 10

    In at the last minute...kind of like last year. This command takes the original requirements of creating a temp file on the user's temp folder that accepts data from the pipeline if used and supports whatif,verbose and debug. After creation of the file, the file path and name is displayed. An option to open the file can be performed using the -DisplayFile switch. In its default state, you can run the command and it will automatically generate a file and save it to your temp folder. Because I felt that was sort of a limited feature, I added the ability to state your own destination path and file if needed. An additional feature is that if the folder path does not exist at the time, the folders will automatically be created for you. Also added is the option to determine what type of encoding you wish to use using the -Encoding parameter and supplying the proper encoding name. When added to a profile, this function will be visible for use.

  • Set-Pictures by Boe Prox 18 Apr 2011 02:56 PM UTC
    by 2 users

    Advanced Event 8

    My entry for Advanced Event 8 contains a few features not required for the games, but I felt that if I was going to do something like this, I might as well have some fun with it. There are 2 ways to determine both the source and destination folders, either by typing in the path in the text box (and clicking Load Pictures for source) or by clicking on Browse Folder and opening a dialog to select the folder. For the source folder, once you select the source containing the pictures, all of the pictures will be populated on the left column. Clicking on a picture will display its metadata in the far right column and display the picture in the middle box. You can then right-click on the picture in the right hand column and select to just prepare that one or you can click the prepare pictures button to process all of the pictures. Optionally, you can go to the Photo Menu and select a couple options to change the size and type for the saved pictures. A progress bar is also used along with a status bar to show where the processing is at. And lastly, all settings to include Source folder, Destination folder, photo size and type are saved to a pictureutility.ini file so the same settings can be loaded again upon start up. Keep in mind that the settings are stored in the same path of where you called the script from. This event was a lot of fun and I hope you enjoy my creation.

  • New-LogFile by Boe Prox 15 Apr 2011 06:41 PM UTC
    by 2 users

    Advanced Event 9

    This is my entry for Advanced Event 9. Since this is the Advanced Event, I went ahead and created an advanced function and then called the function to create the logfile and folder as required. The folder and file are created in the currently logged on user's My Documents folder. The logfile follows the yyyymmdd_username.log format and is only created on the first time each day that a user would be logged onto their workstation. The user will have no indication of this as there is nothing written to the console by default. With the advanced function, I allowed for this code to be more portable so it can be used for other things if needed and added a parameter to add data into the logfile if needed.

  • Get-TwitterIDNames by Boe Prox 12 Apr 2011 07:44 PM UTC
    by 2 users

    Advanced Event 7

    This submission allows you to query a specified site and grab both the Twitter ID and its associated Real Name. This returns an object that can easily be exported to a CSV file per the event requirement by piping the data to Export-CSV. This submission meets ALL of the design criteria mentioned in the event to include: reusable code, help comments and sample usage. Function also has error handling, verbose and debug information included as well.

  • Get-TwitterIDs by Boe Prox 12 Apr 2011 12:25 AM UTC
    by 2 users

    Advanced Event 6

    Instead of just saving the usernames to a text file, I went with the "create an object" approach which in my opinion allows for greater flexibility to let the user decide what they would like to display and if they want to save that data to a file. With that in mind, this submission does satisfy ALL of the requirements set forth. This advanced function is reusable, allows for choosing different URLs to query for twitter names, allows for the output of just usernames if filtered via the Select-Object -ExpandProperty UserNames and provides help comments and enough examples to cover various aspects of usage. I also take into consideration that the twitter url may not always be the same which proves useful if being used against other sites for querying. For the sake of of the event which includes saving just the twitter username to a file, the usage for this command is: Get-TwitterIDs -URL | Select-Object -ExpandProperty UserName | Out-File "twitternames.txt"

  • Test-WindowsSevenCompatibility by Boe Prox 11 Apr 2011 05:09 AM UTC
    by 2 users

    Advanced Event 5

    For my submission on Advanced Event 5, it is a rather larger script, but I had to allow for both PowerShell remoting to work if applicable and if that failed and the computer was active on the network, to use WMI to pull the data. I also used Invoke-WMIMethod to allow for running a remote process on a remote system so I could still query for WDDM and DirectX data. Finding the WDDM information was a lesson in patience and research, but I found that running the dxdiag command line with a /x switch would create a nice xml file for me to work with. I chose to display all of the data that I used in the comparison to include the RAM, Hard drive space, processor speed, WDDM and DirectX. I added the IsUpgradable property so it could easily be sorted by True (can be upgraded) and False (cannot be upgraded). If ran without any parameters, it will query the local computer. Also does a check to verify if running as an Administrator. Example: Test-WindowsSevenCompatibility -Computername Workstation1

  • Get-ProcessInformation by Boe Prox 08 Apr 2011 04:22 AM UTC
    by 3 users

    Advanced Event 4

    This is my entry for the 4th event of the games. It gave me a few items to think harder about and come up with a solution. I used WMI as my main basis to gather both the process information and service information. Since both Win32_Process and Win32_Service share the ProcessId property, I used that to link them up and find all of the information needed. As with my other scripts, this does meet all of the design criteria, including a few extras such as the option to provide a process name and also to select a computername to perform the query against. I also set up a check to see if the processname was given with the extension and if not, the extension would be added on automatically. I went with using a hash table to display the output as it allows for cleaner code. For the purpose of this event, you would want to run the following command after dot-sourcing the script: Get-ProcessInformation -Processname svchost.exe

  • Get-EventLogs by Boe Prox 07 Apr 2011 02:20 AM UTC
    by 2 users

    Advanced Event 3

    This is my entry for the Advanced Event 3. This script satisfies all of the requirements of this event. This script accepts input from the user via the command line and has options to specify an EventId, Severity and the maximum amount of events to return for each log that is available. Since I use the -filterhashtable switch, I included a check to make sure that the script can be run from a supported operating system. Also included is a check to make sure the user is a local administrator, and if not, a prompt is presented to input alternate credentials. By default, if only the command is typed, the local machine will be queried with a maximum events returned per log is 1 event. I've added a switch to choose to either a remote system or systems, or to query Active Directory for only Servers to query. I opted to not allow the logname to display by default because I felt that it would degrade the function by limiting all of the possible properties that can be displayed. To display the logname and also the recommend machine name when running against more than one machine, you can use the following command as an example: Get-EventLogs | Select MachineName,TimeCreated,LogName,ProviderName,Id,Message

  • Get-DependantServices by Boe Prox 05 Apr 2011 11:49 PM UTC
    by 2 users

    Advanced Event 2

    This is the seconds entry for the Advanced category of the scripting games. I used a lot of Write-Verbose to track the progress of the advanced function when using the -verbose switch. When run using Get-DependantServices by itself, it will query the current machine that the script is being run on. If not an Administrator on the local system, you will be prompted for alternate credentials. A -Credential switch is also available to provide alternate credentials. There is also a switch to pull a collection of only servers from Active Directory. You can also specify a specific server using the -Computername parameter as well. I used a hash table and format-table with the -hideheader switch to make the result look better which can be outputted to a text file is needed. I also included the server name at the top of each report of services to easily identify which server belongs to what report.

  • Get-ProcessModuleVersion by Boe Prox 04 Apr 2011 06:06 PM UTC
    by 5 users

    Advanced Event 1

    This advanced function allows for local and remote queries for the process module. Remoting is required for this as using the Get-Process with the -Computername does not allow you to query for the process module. A switch is also available to gather computers from Active Directory as well. If no computername is given, then the local machine is used. I used a tab-delimitted output so data can be written to a CSV file.