Last active
June 8, 2016 06:03
-
-
Save PrateekKumarSingh/22bcbceaa76b53b8661ceea6d0293871 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Get-CmdletOfTheDay | |
{ | |
Function Get-HelpDescription ($d) | |
{ | |
$help.description|Out-File C:\Temp\DecriptionTemp.txt | |
$Description=@(); ((gc C:\Temp\DecriptionTemp.txt)|?{$_ -ne ''})| %{$Description+="$($_.trim())`n"} | |
return $Description | |
} | |
Function Get-HelpExample ($e) | |
{ | |
$e | Out-File c:\temp\exampletemp.txt | |
$examples=@() | |
$Content = (gc c:\temp\exampletemp.txt)|?{$_ -ne ''} | |
For($i = 1; $i -le $Content.count; $i++) | |
{ | |
if($Content[$i] -like '*EXAMPLE 1*' -or $Content[$i] -like '*Example 1*') | |
{$examples+=""} | |
elseif($Content[$i] -like '*EXAMPLE 2*' -or $Content[$i] -like '*Example 2*') | |
{return $examples} | |
elseif($i -eq $Content.count) | |
{return $examples} | |
else | |
{$examples+="$($content[$i])`n"} | |
} | |
} | |
#Cls | |
# Title in the PowerShell Console | |
Write-Host "`nHere is your #PSCmdlet of the Day`n`n" -ForegroundColor Yellow | |
# Choosing a Random Powershell Cmdlet | |
$RandomCmdlet = gcm * -CommandType Cmdlet | Get-Random | |
$help = Get-Help $RandomCmdlet.Name -Full | |
# To Generate the Display | |
Write-Host "NAME" -ForegroundColor Yellow | |
Write-host " $($help.Name)" | |
Write-Host "SYNOPSIS" -ForegroundColor Yellow | |
Write-host " $($help.Synopsis)" | |
Write-host "DESCRIPTION" -ForegroundColor Yellow | |
Write-host " $(Get-HelpDescription $help.description)" | |
Write-host "EXAMPLE" -ForegroundColor Yellow | |
Write-host " $(Get-HelpExample $help.examples)" | |
Remove-Item C:\Temp\DecriptionTemp.txt, C:\Temp\ExampleTemp.txt | |
Remove-Variable Help, RandomCmdlet | |
} | |
Get-CmdletOfTheDay |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment