Show-RandomCommand.ps1


Description

Purpose

Displays the help for a random PowerShell command.

Detailed Description

The Show-RandomCommand function gets a random command from the Microsoft, Cim, and PS* modules and displays its help. If the -showWindow switch is specified, the help is displayed in a separate window.

Back to Top

Usage

Example 1

Show-RandomCommand

Displays the help for a random command in the console.

Example 2

Show-RandomCommand -showWindow

Displays the help for a random command in a separate window.

Back to Top

Notes

Author: [Author Name] Date: [Date]

Back to Top


Script

function Show-RandomCommand {

    <#
    .SYNOPSIS
    Displays the help for a random PowerShell command.
    
    .DESCRIPTION
    The Show-RandomCommand function gets a random command from the Microsoft*, Cim*, and PS* modules and displays its help. 
    If the -showWindow switch is specified, the help is displayed in a separate window.
    
    .PARAMETER showWindow
    Displays the help in a separate window.
    
    .EXAMPLE
    Show-RandomCommand
    Displays the help for a random command in the console.
    
    .EXAMPLE
    Show-RandomCommand -showWindow
    Displays the help for a random command in a separate window.
    
    .NOTES
    Author: [Author Name]
    Date: [Date]
    #>

    param (
        [Parameter(ValueFromPipeline = $True)]
        [switch]$showWindow
    )
    if ($showWindow) {
        Get-Command -Module Microsoft*, Cim*, PS* | Get-Random | Get-Help -ShowWindow
    }
    else {
        Get-Command -Module Microsoft*, Cim*, PS* | Get-Random | Get-Help
    }
}

Back to Top

Download

Please feel free to copy parts of the script or if you would like to download the entire script, simply click the download button. You can download the complete repository in a zip file by clicking the Download link in the menu bar on the left hand side of the page.


Report Issues

You can report an issue or contribute to this site on GitHub. Simply click the button below and add any relevant notes. I will attempt to respond to all issues as soon as possible.

Issue


Back to Top