Tag Archives: Get-TMVerbSynonym

I am TechNet Gallery Years Old

I did not know it when I started, but it turns out, this is Part I.

Up until just recently, I had a section on my website called “TechNet Gallery.” It was right up there between “Contents” and “About.” I have an image of what it contained below. There was some pretty great stuff in there, but it was time for that section to be removed. With that, it is now time for the links to be updated, so people can find these scripts and modules again. The TechNet Gallery links no longer work. It has been a while since I have looked these over, but the links will likely be a combination of GitHub and the PowerShell Gallery. Check the content below the image for information about the first four entries. The others will be highlighted in additional, related posts.

1. “Get Synonyms for Approved and Unapproved Verbs”

I have always loved this script. I even used it yesterday, prior to knowing I would start piecing this post together. If there is a verb you want to use for your cmdlet or function, but it is not approved, this function will look for verb synonyms and tell you if they are approved or not. Here’s a quick image (because it is just beautiful).

While the 1.3 version is available in a GitHub Gist, the newest version — 1.4 — was written and uploaded to the PowerShell Gallery. You can either use that link or use PowerShellGet to download it using the PowerShell below. I have written about this script before, so you can read more here: https://tommymaynard.com/get-tmverbsynonym-1-4-2017/.

Install-Script -Name Get-TMVerbSynonym

2. “Active Directory User Lookup Form”

This was “my first, hand-coded PowerShell form using Windows Forms.” While it was available on the TechNet Gallery for download, that link no longer works.  Here is the 2015 post, and here is an updated link to the GitHub Gist. I always love doing a forms project and am grateful it made its way into .NET (core).

3. “Find DNS Servers Being Used by DHCP Scopes”

This script was written as a solution to a post on the TechNet Forums. I did not read that whole thread, but I can offer you the link to the Gist if this is helpful or interesting. Oh, one other thing, I apparently wrote about the script here on my own site, as well. All the way back in 2015!

4. “Measure Command with Multiple Commands, Repetitions, Calculated Averages”

There is no way I did not write about this one. I loved this script and to this very day, I still think it should be implemented in PowerShell by the PowerShell Team. Perhaps I will add it as a discussion in GitHub in the future. I do not think that was a thing back in 2017. Here is my post about it now!

Measure-Command can only measure one command and only one time per command invocation. This changed that. It allowed a user to measure multiple commands multiple times. It could even calculate the average time for a command to complete. I think its Command parameter accepted a string, so that should probably be changed to a ScriptBlock.

Here is an old image that accompanies the above link to the article on my site — click it to enlarge it. And here, is a link to the code in a Gist.

There is more to cover, but we will put that on hold for a moment. I will be back with a continuation of these soon. And once I am, the below text will link to Part II of this series!

Part II

PowerShell Approved Verb Synonyms

One of the best design decisions, when PowerShell was initially being created, was using approved verbs in naming a command. When people use those, we can guarantee some consistency between command names. As commands — both cmdlets and functions — we expect to see an approved verb followed by a dash and then a singular noun or nouns. Sometimes there’s a prefix after the dash, but before the noun(s). Here are a few examples of some random commands: Import-Module, Get-VMGroup, Add-AzVhd, Export-AzDataLakeStoreItem, Set-WsusProduct, and Stop-SSMCommand. While these commands display a few of the approved verbs, it’s not all of them. Use the Get-Verb command to view the full list of the approved verbs, from which you should choose when writing a new function or cmdlet.

There may not have always been this many, but in 7.2.0-preview4, there are 100 approved verbs.

[PS7.2.0-preview.4][C:\] Get-Verb | Measure-Object

Count             : 100
Average           :
Sum               :
Maximum           :
Minimum           :
StandardDeviation :
Property          :

Even though there’s a good number of options from which to choose, there may not always feel like there’s one for your newest command. While I’ve brought this up to the community at least a couple of times before, it’s time to do it again. It’s the Get-TMVerbSynonym function. I authored it in June 2016, I updated it in 2017, and I used it earlier today, in 2021. It can be found in the Powershell Gallery and installed using the below command:

[PS7.2.0-preview.4][C:\] Install-Script -Name Get-TMVerbSynonym

The file it downloads is a function inside of a script file — a .ps1 file. In order to add a function inside a script file to the current PowerShell session, you need to dot source the file. That’s what the mystery dot is doing between my prompt and the path to the .ps1 file below.

[PS7.2.0-preview.4][C:\] . C:\Users\tommymaynard\Documents\PowerShell\Scripts\Get-TMVerbSynonym.ps1

Once it’s dot sourced, you can use the function. In closing, here are few examples of the function in action. Each of these commands uses the Format-Table -AutoSize command and parameter in order that the results are easier to read.

[PS7.1.3][C:\] Get-TMVerbSynonym -Verb change | Format-Table -AutoSize

Verb   Synonym     Group  Approved Notes
----   -------     -----  -------- -----
Change Alter                 False
Change Commute               False
Change Convert     Data       True
Change Deepen                False
Change Dress                 False Generic Term
Change Exchange              False
Change Get Dressed           False Generic Term
Change Go                    False Generic Term
Change Interchange           False
Change Locomote              False Generic Term
Change Modify                False
Change Move        Common     True Generic Term
Change Replace               False Generic Term
Change Shift                 False
Change Stay                  False Antonym
Change Switch      Common     True
Change Transfer              False
Change Transfer              False Generic Term
Change Travel                False Generic Term
Change Vary                  False

[PS7.1.3][C:\] Get-TMVerbSynonym -Verb change -Approved | Format-Table -AutoSize

Verb   Synonym Group  Approved Notes
----   ------- -----  -------- -----
Change Convert Data       True
Change Move    Common     True Generic Term
Change Switch  Common     True

[PS7.1.3][C:\] 

If there’s ever a verb you want to use, but it’s not approved, then try this function. You’ll likely be able to choose something that’s close enough, and is approved.

Get-TMVerbSynonym 1.4

Notes: Download link at the bottom of this post.

One of my favorite PowerShell community members, June Blender, posted a question on Twitter. While it wasn’t directed at me, I couldn’t resist. She wanted the approved verb options for the verbs “populate”, “fill in”, or “load”. I couldn’t help myself, because I wrote a function for this very task!

The Get-TMVerbSynonym function’s purpose is to find synonyms for verbs and return whether they’re approved, or not. Well, her Tweet was all it took to finally make some overdue changes, including getting it posted on the PowerShell Gallery. As I called it in one of my follow-up tweets, when June asked where it was then published, I said it was a “TechNet leftover.”

Well, not anymore.

It’s since been updated to version 1.4 and placed on the PowerShell Gallery. The above image was what I posted when it was in version 1.3. This means that it doesn’t reflect two of the newest, view-able changes. The Verb property now indicates the verb it’s checking, and the old Verb property has been renamed to Synonym. This was included to support some other potential updates for an even newer version. Anyway, this means it’s up to five properties, so pipe to Format-Table -AutoSize in order that the results can be easily read.

Additionally, it now includes something I always wanted it to have: an Approved, switch parameter. This means there’s no piping to Where-Object to filter the function to only show the approved synonyms. Here’s an example of the function in action, both with and without the Approved, switch parameter.

Download it now manually, or use Install-Script -Name Get-TMVerbSynonym.

Script Sharing – Get Synonyms for Approved and Unapproved Verbs

Download link at bottom of post. Note: This post contains information that is necessary to know to use this function. Please read it if you think you’ll try using this function.

Update: The previous version of the function (1.0) required the user to register and obtain an API key, and place it inside the function’s code. I’ve only had some 40 downloads, so I’ve opted to include my API key to see if this function can get more usage. This really can be a great tool, and so it seems the best idea for now. If anyone ever hits an error using the API key, please let me know: <my1stname>@<thisdomain>.com. (6/10/2016)

I consider myself a best practice kind of guy; especially when it comes to Windows PowerShell. There’s been a time or two where I’m quite sure that I, politely, called someone out for using an unapproved verb. If you’re familiar with PowerShell, then you know that cmdlet and function names should use the verb-noun naming convention. Now, no one cares about the nouns you choose, but verbs need to be approved.

If you haven’t before, try running the Get-Verb cmdlet. This cmdlet, when used without any parameters, will return all the approved verbs. Even for me, there’s been a time or two when the verb I wanted to use wasn’t approved. In that case, I recommend still finding and using an approved verb, but also creating an alias that you can use to call your properly named, cmdlet or function. Here’s a modified example from one of my previous posts:

Set-Alias -Name Launch-InternetExplorer -Value Open-InternetExplorer
 
Function Open-InternetExplorer {
    # Do Stuff.
}

In this example, that was originally posted here: http://tommymaynard.com/quick-learn-create-a-function-to-open-internet-explorer-like-in-run-2015, I can use Launch as my verb, since I’ve made it part of an alias. The function name with the approved verb is Open-InternetExplorer and my alias, that will run this same function, is Launch-InternetExplorer.

So, where am I going with this: I’ve always wanted a function that would allow me to pull back synonyms for a verb, and today, I have just that. I considered walking though what I did to write this, but instead, because it ended up being somewhat lengthy, I posted it on TechNet for download.

Before I provide a download link, I should mentioned that you’re going to need to do a couple things to make this function work for you.

  1. Go to http://thesaurus.altervista.org/mykey and register for an API key.
  2. Download my function from the link at the bottom of the page.
  3. Open the function in the ISE, or your editor of preference, and replace [string]$Key with [string]$Key ='<Your API Key>’, replacing <Your API Key> with key you received from step 1.

Now when you use the function, it’ll use your API key. In addition, we won’t have to make the -Key parameter mandatory, forcing it to prompt us for the key, even when the $Key variable is being assigned a value inside the function. Thanks!

get-synonyms-for-approved-and-unapproved-verbs01

Update: The newest version is now available for download on the PowerShell Gallery.

Download the Get-TMVerbSynonym advanced function here: https://gallery.technet.microsoft.com/Get-Synonyms-for-Approved-f6625752