Powershell 4 : Help System - 2020
"If you aren't willing to read PowerShell's help files, you won't be effective with PowerShell. You won't learn how to use it, you won't learn how to administer products like Windows and Exchange with it, and you might as well stick with the GUI."
PowerShell contains many different types of executable commands which includes cmdlets, functions, workflows. They're all commands, and the help system works with all of them. A cmdlets is something unique to PowerShell, and many of the commands we run will be cmdlets.
Let's look into how we can update PowerShell's help. These files are stored in the System32 directory, which means our shell must be running under elevated privileges. If it doesn't say Administrator in the PowerShell title bar, we'll likely get an error message like this:
C:\Users\KHong> update-help ate-help : Failed to update Help for the module(s) 'Microsoft.PowerShell.Management, Microsoft.PowerShell.Utility, rosoft.PowerShell.Diagnostics, Microsoft.PowerShell.Host, Microsoft.PowerShell.Security, rosoft.WSMan.Management, Microsoft.PowerShell.Core' : The command could not update Help topics for the Windows erShell core modules, or for any modules in the $pshome\Modules directory. To update these Help topics, start dows PowerShell by using the "Run as Administrator" command, and try running Update-Help again. line:1 char:1 pdate-help ~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [Update-Help], Exception + FullyQualifiedErrorId : UpdatableHelpSystemRequiresElevation,Microsoft.PowerShell.Commands.UpdateHelpCommand ate-help : Failed to update Help for the module(s) 'CimCmdlets, ISE, PSDesiredStateConfiguration, PSScheduledJob, orkflow, PSWorkflowUtility' with UI culture(s) {en-US} : Access to the path \Windows\system32\WindowsPowerShell\v1.0\Modules\CimCmdlets\en-US' is denied. line:1 char:1 pdate-help ~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [Update-Help], Exception + FullyQualifiedErrorId : UnknownErrorId,Microsoft.PowerShell.Commands.UpdateHelpCommand
If we run PowerShell as admin, the help will be updated successfully:
Windows PowerShell provides a cmdlet, Get-Help, that accesses the help system.
We can use wild character (*) with get-help or help:
PS C:\Windows\system32> help *event* Name Category Module Synopsis ---- -------- ------ -------- Clear-EventLog Cmdlet Microsoft.PowerShell.M... Deletes all entries from specified event logs ... Get-EventLog Cmdlet Microsoft.PowerShell.M... Gets the events in an event log, or a list of ... Limit-EventLog Cmdlet Microsoft.PowerShell.M... Sets the event log properties that limit the s... New-EventLog Cmdlet Microsoft.PowerShell.M... Creates a new event log and a new event source... Register-WmiEvent Cmdlet Microsoft.PowerShell.M... Subscribes to a Windows Management Instrumenta... Remove-EventLog Cmdlet Microsoft.PowerShell.M... Deletes an event log or unregisters an event s... Show-EventLog Cmdlet Microsoft.PowerShell.M... Displays the event logs of the local or a remo... Write-EventLog Cmdlet Microsoft.PowerShell.M... Writes an event to an event log. Register-CimIndicationEvent Cmdlet CimCmdlets Register-CimIndicationEvent... Get-WinEvent Cmdlet Microsoft.PowerShell.D... Gets events from event logs and event tracing ... New-WinEvent Cmdlet Microsoft.PowerShell.D... Creates a new Windows event for the specified ... Get-Event Cmdlet Microsoft.PowerShell.U... Gets the events in the event queue. Get-EventSubscriber Cmdlet Microsoft.PowerShell.U... Gets the event subscribers in the current sess... New-Event Cmdlet Microsoft.PowerShell.U... Creates a new event. Register-EngineEvent Cmdlet Microsoft.PowerShell.U... Subscribes to events that are generated by the... Register-ObjectEvent Cmdlet Microsoft.PowerShell.U... Subscribes to the events that are generated by... Remove-Event Cmdlet Microsoft.PowerShell.U... Deletes events from the event queue. Unregister-Event Cmdlet Microsoft.PowerShell.U... Cancels an event subscription. Wait-Event Cmdlet Microsoft.PowerShell.U... Waits until a particular event is raised befor... about_Eventlogs HelpFile Windows PowerShell creates a Windows event log... PS C:\Windows\system32> PS C:\Windows\system32> get-help *event* Name Category Module Synopsis ---- -------- ------ -------- Clear-EventLog Cmdlet Microsoft.PowerShell.M... Deletes all entries from specified event logs ... Get-EventLog Cmdlet Microsoft.PowerShell.M... Gets the events in an event log, or a list of ... Limit-EventLog Cmdlet Microsoft.PowerShell.M... Sets the event log properties that limit the s... New-EventLog Cmdlet Microsoft.PowerShell.M... Creates a new event log and a new event source... Register-WmiEvent Cmdlet Microsoft.PowerShell.M... Subscribes to a Windows Management Instrumenta... Remove-EventLog Cmdlet Microsoft.PowerShell.M... Deletes an event log or unregisters an event s... Show-EventLog Cmdlet Microsoft.PowerShell.M... Displays the event logs of the local or a remo... Write-EventLog Cmdlet Microsoft.PowerShell.M... Writes an event to an event log. Get-Event Cmdlet Microsoft.PowerShell.U... Gets the events in the event queue. Get-EventSubscriber Cmdlet Microsoft.PowerShell.U... Gets the event subscribers in the current sess... New-Event Cmdlet Microsoft.PowerShell.U... Creates a new event. Register-EngineEvent Cmdlet Microsoft.PowerShell.U... Subscribes to events that are generated by the... Register-ObjectEvent Cmdlet Microsoft.PowerShell.U... Subscribes to the events that are generated by... Remove-Event Cmdlet Microsoft.PowerShell.U... Deletes events from the event queue. Unregister-Event Cmdlet Microsoft.PowerShell.U... Cancels an event subscription. Wait-Event Cmdlet Microsoft.PowerShell.U... Waits until a particular event is raised befor... Register-CimIndicationEvent Cmdlet CimCmdlets Register-CimIndicationEvent... Get-WinEvent Cmdlet Microsoft.PowerShell.D... Gets events from event logs and event tracing ... New-WinEvent Cmdlet Microsoft.PowerShell.D... Creates a new Windows event for the specified ... about_Eventlogs HelpFile Windows PowerShell creates a Windows event log...
Let's try Help Get-EventLog -example:
PS C:\Windows\system32> help get-eventlog -example NAME Get-EventLog SYNOPSIS Gets the events in an event log, or a list of the event logs, on the local or remote computers. -------------------------- EXAMPLE 1 -------------------------- PS C:\>get-eventlog -list This command gets the event logs on the computer. -------------------------- EXAMPLE 2 -------------------------- PS C:\>get-eventlog -newest 5 -logname application This command gets the five most recent entries from the Application event log. -------------------------- EXAMPLE 3 -------------------------- PS C:\>$events = get-eventlog -logname system -newest 1000 PS C:\>$events | group-object -property source -noelement | sort-object -property count -descending Count Name ----- ---- 75 Service Control Manager 12 Print 6 UmrdpService 2 DnsApi 2 DCOM 1 Dhcp 1 TermDD 1 volsnap This example shows how to find all of the sources that are represented in the 1000 most recent entries in the System event log. The first command gets the 1,000 most recent entries from the System event log and stores them in the $events variable. The second command uses a pipeline operator (|) to send the events in $events to the Group-Object cmdlet, which groups the entries by the value of the Source property. The command uses a second pipeline operator to send the grouped events to the Sort-Object cmdlet, which sorts them in descending order, so the most frequently appearing source is listed first. Source is just one property of event log entries. To see all of the properties of an event log entry, pipe the event log entries to the Get-Member cmdlet. -------------------------- EXAMPLE 4 -------------------------- PS C:\>get-eventlog -logname System -EntryType Error ...
Powershell 4 Tutorial
- Powersehll : Introduction
- Powersehll : Help System
- Powersehll : Running commands
- Powersehll : Providers
- Powersehll : Pipeline
- Powersehll : Objects
- Powershell : Remote Control
- Windows Management Instrumentation (WMI)
- How to Enable Multiple RDP Sessions in Windows 2012 Server
- How to install and configure FTP server on IIS 8 in Windows 2012 Server
- How to Run Exe as a Service on Windows 2012 Server
- SQL Inner, Left, Right, and Outer Joins
Ph.D. / Golden Gate Ave, San Francisco / Seoul National Univ / Carnegie Mellon / UC Berkeley / DevOps / Deep Learning / Visualization