Skip to content

Instantly share code, notes, and snippets.

View tommymaynard's full-sized avatar

tommymaynard tommymaynard

View GitHub Profile
# Option 1: Y and N ONLY.
Do {
$Response = Read-Host -Prompt 'Enter Y for Yes or N for No'
} Until ($Response -eq 'Y' -or $Response -eq 'N')
If ($Response -eq 'Y') {
'Doing yes stuff...'
} ElseIf ($Response -eq 'N') {
'Doing no stuff...'
}
@tommymaynard
tommymaynard / technet-map_drive_to_drive_letter.ps1
Created May 21, 2020 19:41
Map Drive to Drive Letter Using the Win32_DiskDrive Interface Type Property
<#
TechNet Contribution: Map Drive to Drive Letter Using the Win32_DiskDrive Interface Type Property
Previous link: https://gallery.technet.microsoft.com/Map-Drive-to-Drive-Letter-1fff91ad
Downloaded: 2,904 times (as of 05/21/2020)
This project began on the TechNet forums. Someone requested help determining the drive letter of a USB drive.
It was first recommended to use the Win32_LogicalDisk class, but I was concerned that this might return false
results since an SD card would report the same Description and DriveType as a USB using Win32_LogicalDisk.
I recommended using the Win32_DiskDrive class and the InterfaceType property so the user could ensure the drive
@tommymaynard
tommymaynard / technet-find_dns_servers.ps1
Last active March 6, 2023 21:11
Find DNS Servers Being Used by DHCP Scopes
<#
TechNet Contribution: Find DNS Servers Being Used by DHCP Scopes
Previous link: https://gallery.technet.microsoft.com/Find-DNS-Servers-Being-640978d1
Downloaded: 1,174 times (as of 05/21/2020)
This advanced function determines the DNS Servers being used by a DHCP Scope whether the DNS Servers are assigned
at the Scope Options, or Server Options. It was inspired by the Microsoft TechNet Forums
(https://social.technet.microsoft.com/Forums/en-US/58723d31-7586-40c3-acd2-183f20b49daf/how-to-dump-the-dns-options-for-each-dhcp-scope?forum=ITCG).
Please read more here: http://tommymaynard.com/script-sharing-find-dns-servers-being-used-by-dhcp-scopes-2015/.
@tommymaynard
tommymaynard / technet-active_directory_user_lookup_form.ps1
Last active March 18, 2023 06:08
Active Directory User Lookup Form
<#
TechNet Contribution: Active Directory User Lookup Form
Previous link: https://gallery.technet.microsoft.com/Active-Directory-User-d8ee6a0c
Downloaded: 1,034 times (as of 05/21/2020)
This PowerShell script creates a PowerShell form to search for users in Active Directory by Username (SamAccountName).
The form returns a user's Name, Distinguished Name, Email, Title, and Office Phone. You can read more about the form's
development at http://tommymaynard.com/script-sharing-active-directory-user-lookup-form-2015.
Update to 2.1: 2015-07-23 (see code for changes).
@tommymaynard
tommymaynard / technet-measure-command_with_multiple_commands.ps1
Created May 21, 2020 20:07
Measure-Command with Multiple Commands, Repetitions, Calculated Averages
<#
TechNet Contribution: Measure-Command with Multiple Commands, Repetitions, Calculated Averages
Previous link: https://gallery.technet.microsoft.com/Measure-Command-with-52158178
Downloaded: 529 times (as of 05/21/2020)
In Windows PowerShell, there are often several ways to complete the same task. With that in mind, it makes sense that
we might want to determine how long commands and scripts take to complete. Until now, Measure-Command has been the
cmdlet we’ve used. While Measure-Command has been helpful, I’ve often thought it should include some additional
functionality. Therefore, I’ve written an advanced function, Measure-TMCommand, that adds all the benefits listed below:
@tommymaynard
tommymaynard / technet-check_email_address_domain_against.ps1
Created May 21, 2020 20:12
Check Email Address Domain Against the Top-Level Domain List from IANA
<#
TechNet Contribution: Check Email Address Domain Against the Top-Level Domain List from IANA
Previous link: https://gallery.technet.microsoft.com/Check-Email-Address-Domain-41cb7838
Downloaded: 496 times (as of 05/21/2020)
At times it seems that there has been some frustration when trying to validate an email address. In my experience,
this often been because an email address without a domain (.com, .net, .org) is often validated as True. While the
purpose of this advanced function is not to validate an entire email address, it does validate the domain according
to the Internet Assigned Numbers Authority (IANA).
@tommymaynard
tommymaynard / technet-get_synonyms_approved_verbs.ps1
Created May 21, 2020 20:16
Get Synonyms for Approved and Unapproved Verbs
<#
TechNet Contribution: Get Synonyms for Approved and Unapproved Verbs
Previous link: https://gallery.technet.microsoft.com/Get-Synonyms-for-Approved-f6625752
Downloaded: 452 times (as of 05/21/2020)
The newest version can be found here: http://tommymaynard.com/get-tmverbsynonym-1-4-2017/
As many PowerShell users are aware, cmdlets and functions should use a verb-noun naming convention with approved
verbs. There are times when the verb a person may desire to use for the cmdlet or function isn't approved -- that's
where this function can assist. This function will return synonyms for verbs and indicate if the synonyms are approved
@tommymaynard
tommymaynard / technet-specify_and_create_multiple_credential_objects.ps1
Created May 21, 2020 20:19
Specify and Create Multiple Credential Objects
<#
TechNet Contribution: Specify and Create Multiple Credential Objects
Previous link: https://gallery.technet.microsoft.com/Specify-and-Create-d80ad39e
Downloaded: 461 times (as of 05/21/2020)
This advanced function will allow a user to specify and then create multiple credential objects. Creating additional
credential objects allows a user the ability to use different credentials for various purposes while working in the Windows
PowerShell console, or ISE. More information, including a walkthrough of the function's development, can be found here: http://tommymaynard.com/ql-creating-multiple-credential-objects-2015.
Although this advanced function has only been tested on Windows 8.1, I suspect it should work on most other Windows
@tommymaynard
tommymaynard / technet-convert_alphanumeric_string_to_the_NATO.ps1
Last active March 1, 2023 14:33
Convert Alphanumeric String to the NATO Phonetic Alphabet Equivalent
<#
TechNet Contribution: Convert Alphanumeric String to the NATO Phonetic Alphabet Equivalent
Previous link: https://gallery.technet.microsoft.com/Convert-Alphanumeric-8c1d6a79
Downloaded: 858 times (as of 05/21/2020)
There was a post in the TechNet Forum about needing a solution to convert a string into the NATO phonetic alphabet
equivalent (link). I really liked the project and quickly wrote out an advanced function in Windows PowerShell to
accompany the VBS solution that was also posted. Please let me know if there are any problems that need correcting.
The 1.3 version will speak the results, if the -Speak switch parameter is included when the function is run.
<#
TechNet Contribution: The 1 to 100 Game
Previous link: https://gallery.technet.microsoft.com/The-1-to-100-Game-5288e279
Downloaded: 749 times (as of 05/21/2020)
Update: The newest version of this function (3.0), has been posted on the PowerShell Gallery at
https://www.powershellgallery.com/packages/Start-1to100Game3.0/3.0/DisplayScript. Read the newest write up here:
http://tommymaynard.com/the-1-to-100-game-updated-2016.
While this advanced function isn't as useful as many in the TechNet Gallery, it does show a great example of nested