Learning and Sharing
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
No Result
View All Result

#22 PowerShell Learning: The Philosophy Verb-Noun

August 20, 2023
in Blog, PowerShell Learning
0
ADVERTISEMENT

Table of Contents

The Philosophy: Verb-Noun

In this section, we’ll focus on the PowerShell cmdlets. In concrete terms, the philosophy of these commands. Each PowerShell command called cmdlets contains a verb and a noun, separated by a hyphen. 

For example, command Stop-Computer. Stop is the verb and Computer is the noun. Here are some examples of this philosophy or naming convention:

PS C:\> Get-Date
Sunday, August 20, 2023 9:53:24 AM

PS C:\> Get-Process | Select -First 5

Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName
-------  ------    -----      -----     ------     --  -- -----------
    185      14     3104       6512       2.17   5644   1 AdobeIPCBroker
    415      24    42756      32136       0.28  10996   1 AdobeNotificationClient
    164      11     2168       5408       4.55   5348   0 AdobeUpdateService
    152      10     3808       7228       2.34   6908   0 AggregatorHost
    401      24    14544      17264       4.33  10932   1 ApplicationFrameHost

PS C:\> Start-Process 'https://bonguides.com'

The last command opens my website. Start-Process starts a process. And if you specify a website the command opens a web browser and gets you to my site.

An important PowerShell cmdlet: Get-Command

Which takes me to to the command Get-Command. Get-Command enables you to show all available PowerShell Commands at once. Let’s explore all PowerShell commands.

PS C:\> Get-Command | select -First 5

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Alias           Add-AppPackage                                     2.0.1.0    Appx
Alias           Add-AppPackageVolume                               2.0.1.0    Appx
Alias           Add-AppProvisionedPackage                          3.0        Dism
Alias           Add-ProvisionedAppPackage                          3.0        Dism
Alias           Add-ProvisionedAppxPackage                         3.0        Dism

PS C:\> (Get-Command).Count
26741

There’s a lot of them. In order to make the whole thing clearer, we can use a special method. For this we need a pipe and the command more. A pipe connects commands. In concrete terms, the pipe takes everything on the left of the pipe and forwards it to the command to the right of the pipe.

For example, we only get the first five commands in the Get-Command cmdlet results.

How to get a command by verb or noun?

I always recommend playing with Get commands first. Why? You cannot destroy your system. Get Commands only get something, they don’t modify. So, the task for this part is to find all the Get commands. Remember: Get is the verb. Let’s search all of the gets using a simple parameter.

PS C:\> Get-Command -Verb 'Get' | select -First 5

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Alias           Get-AppPackage                                     2.0.1.0    Appx
Alias           Get-AppPackageDefaultVolume                        2.0.1.0    Appx
Alias           Get-AppPackageLastError                            2.0.1.0    Appx
Alias           Get-AppPackageLog                                  2.0.1.0    Appx
Alias           Get-AppPackageManifest                             2.0.1.0    Appx

PS C:\> (Get-Command -Verb 'Get').Count
424

Nice. Found some interesting? I do. Get-Host. Get-Host shows you information about your system, especially of PowerShell. For example, you can see your PowerShell version. Mine is 5.1. That was just a quick glance at a particular Get command. Let’s move on with nouns.

PS C:\> Get-Host

Name             : ConsoleHost
Version          : 5.1.19041.3031
InstanceId       : 19125d42-de3f-4c8b-976d-6c5870854ae0
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : en-US
CurrentUICulture : en-US
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

To find a command with a specific noun, for example the noun date, run:

PS P:\> Get-Command -Noun 'Date'

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Cmdlet          Get-Date                                           3.1.0.0    Microsoft.Pow...
Cmdlet          Set-Date                                           3.1.0.0    Microsoft.Pow...

It is no coincidence that I use this noun. Date contains only 2 commands. That doesn’t make it too extensive. For instance, we’ve listed more commands for the nouns service and process.

PS P:\> Get-Command -Noun 'service' 

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Cmdlet          Get-Service                                        3.1.0.0    Microsoft.Pow... 
Cmdlet          New-Service                                        3.1.0.0    Microsoft.Pow... 
Cmdlet          Restart-Service                                    3.1.0.0    Microsoft.Pow... 
Cmdlet          Resume-Service                                     3.1.0.0    Microsoft.Pow... 
Cmdlet          Set-Service                                        3.1.0.0    Microsoft.Pow... 
Cmdlet          Start-Service                                      3.1.0.0    Microsoft.Pow...
Cmdlet          Stop-Service                                       3.1.0.0    Microsoft.Pow... 
Cmdlet          Suspend-Service                                    3.1.0.0    Microsoft.Pow... 


PS P:\> Get-Command -Noun 'process'

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Cmdlet          Debug-Process                                      3.1.0.0    Microsoft.Pow... 
Cmdlet          Get-Process                                        3.1.0.0    Microsoft.Pow... 
Cmdlet          Start-Process                                      3.1.0.0    Microsoft.Pow... 
Cmdlet          Stop-Process                                       3.1.0.0    Microsoft.Pow...
Cmdlet          Wait-Process                                       3.1.0.0    Microsoft.Pow... 

Using TAB

A nice feature is the use of TAB. If you have no clue about the noun, type Get-Command -Noun and press TAB. Unfortunately, this only works with nouns.

lQF46T89pyW4U4HWHWzOAzKChrQoipXjMdXdHp7oDx71zTcuovXtsVRoc6IL

How to list commands using wildcards

Wildcards are placeholders for any value. The wildcard character is usually *. If you are not happy with searching by verb or noun you can simply use the wildcard character. 

For example, I don’t know the command to restart the computer. Let’s search for command that includes the word restart.

PS C:\> Get-Command *restart*

CommandType Name               Version Source
----------- ----               ------- ------
Function    Restart-NetAdapter 2.0.0.0 NetAdapter
Function    Restart-PcsvDevice 1.0.0.0 PcsvDevice
Function    Restart-PrintJob   1.1     PrintManagement
Cmdlet      Restart-Computer   3.1.0.0 Microsoft.PowerShell.Management
Cmdlet      Restart-Service    3.1.0.0 Microsoft.PowerShell.Management

Combining two commands

Restart computer in an hour?  Type Start-Sleep and specify a time span in seconds.

Start-Sleep -Seconds 10

PowerShell goes to sleep. For 10 seconds. Let’s think ahead. We can now combine two commands. The first one will be Start-Sleep. The second one is Restart-Computer. The goal is that in about one hour the computer should be shut down. For this we need a separator, to separate the two commands from each other. It’s a dotted comma. 

Start-Sleep -Seconds 3600; Restart-Computer -Force

PowerShell goes to sleep for 3600 seconds. After this period the computer will do a restart. Trust me, it will happen! Provided that you don’t close PowerShell. Planning this in a scheduled task is by all means the better solution. But that’s a topic for the more advanced blog posts.

5/5 - (1 vote)
Previous Post

#21 PowerShell Learning: Understanding Parentheses, Braces and Square Brackets

Next Post

#23 PowerShell Learning: PowerShell Parameters

Related Posts

Running Hyper-V and VMware Workstation on The Same Machine

August 15, 2024

How to Uninstall All Autodesk Products At Once Silently

July 29, 2024
Ftr5

How to Uninstall the Autodesk Genuine Service on Windows

July 29, 2024
Ftr19

How to Fix Windows Cannot Read the ProductKey From the Unattend Answer File in VirtualBox

July 26, 2024
Ftr25

How to Update Windows Terminal in Windows 10/11

July 26, 2024

How to Disable The Beep Sound in WSL Terminal on Windows

July 26, 2024

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • How To Turn On uBlock Origin Extension in Chrome (2025)
  • Images Hidden Due To Mature Content Settings In CivitAI
  • Azure OpenAI vs Azure AI Hub, How to Choose the Right One for Your Needs

Categories

Stay in Touch

Discord Server

Join the Discord server with the site members for all questions and discussions.

Telegram Community

Jump in Telegram server. Ask questions and discuss everything with the site members.

Youtube Channel

Watch more videos, learning and sharing with Leo ❤❤❤. Sharing to be better.

Newsletter

Join the movement and receive our weekly Tech related newsletter. It’s Free.

General

Microsoft Windows

Microsoft Office

VMware

VirtualBox

Technology

PowerShell

Microsoft 365

Microsoft Teams

Email Servers

Copyright 2025 © All rights Reserved. Design by Leo with ❤

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory