From e44fd29d4c215e650696f282331092925b12a4b2 Mon Sep 17 00:00:00 2001 From: Reinhart Previano Koentjoro Date: Thu, 30 Nov 2023 14:09:50 +0700 Subject: [PATCH] windows/*: add more PowerShell commands (#11612) * windows/*: add more PowerShell commands * get-commandL fix typo * Update install-module.md Co-authored-by: Sebastiaan Speck <12570668+sebastiaanspeck@users.noreply.github.com> --------- Co-authored-by: Sebastiaan Speck <12570668+sebastiaanspeck@users.noreply.github.com> --- pages/windows/get-command.md | 29 +++++++++++++++++++++++++ pages/windows/get-help.md | 24 ++++++++++----------- pages/windows/get-wuapiversion.md | 13 +++++++++++ pages/windows/get-wuhistory.md | 25 +++++++++++++++++++++ pages/windows/get-wusettings.md | 13 +++++++++++ pages/windows/install-module.md | 36 +++++++++++++++++++++++++++++++ pages/windows/pswindowsupdate.md | 13 +++++++++++ 7 files changed, 141 insertions(+), 12 deletions(-) create mode 100644 pages/windows/get-command.md create mode 100644 pages/windows/get-wuapiversion.md create mode 100644 pages/windows/get-wuhistory.md create mode 100644 pages/windows/get-wusettings.md create mode 100644 pages/windows/install-module.md create mode 100644 pages/windows/pswindowsupdate.md diff --git a/pages/windows/get-command.md b/pages/windows/get-command.md new file mode 100644 index 000000000..0a45e0cad --- /dev/null +++ b/pages/windows/get-command.md @@ -0,0 +1,29 @@ +# Get-Command + +> List and get available commands in the current PowerShell session. +> This command can only be run through PowerShell. +> More information: . + +- List all available PowerShell commands (aliases, cmdlets, functions) in the current computer: + +`Get-Command` + +- List all available PowerShell commands in the current session: + +`Get-Command -ListImported` + +- List only PowerShell aliases/cmdlets/functions available in the computer: + +`Get-Command -Type {{Alias|Cmdlet|Function}}` + +- List only programs or commands available on PATH in the current session: + +`Get-Command -Type Application` + +- List only PowerShell commands by the module name, e.g. `Microsoft.PowerShell.Utility` for utility-related commands: + +`Get-Command -Module {{module}}` + +- Get the command information (e.g. version number or module name) by its name: + +`Get-Command {{command}}` diff --git a/pages/windows/get-help.md b/pages/windows/get-help.md index 8ae34b4d9..be31847b0 100644 --- a/pages/windows/get-help.md +++ b/pages/windows/get-help.md @@ -1,28 +1,28 @@ # Get-Help -> Display help information and documentation for PowerShell commands, aka. cmdlets. +> Display help information and documentation for PowerShell commands (aliases, cmdlets, and functions). > This command can only be run through PowerShell. > More information: . -- Display general help information for a specific cmdlet: +- Display general help information for a specific PowerShell command: -`Get-Help {{cmdlet}}` +`Get-Help {{command}}` -- Display a more detailed documentation for a specific cmdlet: +- Display a more detailed documentation for a specific PowerShell command: -`Get-Help {{cmdlet}} -Detailed` +`Get-Help {{command}} -Detailed` -- Display the full technical documentation for a specific cmdlet: +- Display the full technical documentation for a specific PowerShell command: -`Get-Help {{cmdlet}} -Full` +`Get-Help {{command}} -Full` -- Print only the documentation for a specific parameter of the cmdlet (use `*` to show all parameters), if available: +- Print only the documentation for a specific parameter of the PowerShell command (use `*` to show all parameters), if available: -`Get-Help {{cmdlet}} -Parameter {{parameter}}` +`Get-Help {{command}} -Parameter {{parameter}}` - Print only the examples of the cmdlet, if available: -`Get-Help {{cmdlet}} -Examples` +`Get-Help {{command}} -Examples` - List all available cmdlet help pages: @@ -32,6 +32,6 @@ `Update-Help` -- View an online version of cmdlet documentation in the default web browser: +- View an online version of PowerShell command documentation in the default web browser: -`Get-Help {{cmdlet}} -Online` +`Get-Help {{command}} -Online` diff --git a/pages/windows/get-wuapiversion.md b/pages/windows/get-wuapiversion.md new file mode 100644 index 000000000..c03817e3b --- /dev/null +++ b/pages/windows/get-wuapiversion.md @@ -0,0 +1,13 @@ +# Get-WUApiVersion + +> Get the Windows Update Agent version. Part of external `PSWindowsUpdate` module. +> This command can only be run under PowerShell. +> More information: . + +- Get the currently-installed Windows Update Agent version: + +`Get-WUApiVersion` + +- Send the current configuration data via email (SMTP): + +`Get-WUApiVersion -SendReport -PSWUSettings @{SmtpServer="{{smtp_server}}"; Port={{smtp_port}} From="{{sender_email}}" To="{{receiver_email}}"}` diff --git a/pages/windows/get-wuhistory.md b/pages/windows/get-wuhistory.md new file mode 100644 index 000000000..22ee5d49c --- /dev/null +++ b/pages/windows/get-wuhistory.md @@ -0,0 +1,25 @@ +# Get-WUHistory + +> Get the history of installed updates from Windows Update. Part of external `PSWindowsUpdate` module. +> This command can only be run under PowerShell. +> More information: . + +- Get list of update history: + +`Get-WUHistory` + +- List the last 10 installed updates: + +`Get-WUHistory -Last {{10}}` + +- List all updates installed from a specific date to today: + +`Get-WUHistory -MaxDate {{date}}` + +- List all updates installed in the past 24 hours: + +`Get-WUHistory -MaxDate (Get-Date).AddDays(-1)` + +- Send the results via email (SMTP): + +`Get-WUHistory -SendReport -PSWUSettings @{SmtpServer="{{smtp_server}}"; Port={{smtp_port}} From="{{sender_email}}" To="{{receiver_email}}"}` diff --git a/pages/windows/get-wusettings.md b/pages/windows/get-wusettings.md new file mode 100644 index 000000000..2c1c9c05a --- /dev/null +++ b/pages/windows/get-wusettings.md @@ -0,0 +1,13 @@ +# Get-WUSettings + +> Get the current Windows Update Agent configuration. Part of external `PSWindowsUpdate` module. +> This command can only be run under PowerShell. +> More information: . + +- Get the current Windows Update Agent configuration: + +`Get-WUSettings` + +- Send the current configuration data via email (SMTP): + +`Get-WUSettings -SendReport -PSWUSettings @{SmtpServer="{{smtp_server}}"; Port={{smtp_port}} From="{{sender_email}}" To="{{receiver_email}}"}` diff --git a/pages/windows/install-module.md b/pages/windows/install-module.md new file mode 100644 index 000000000..37a2e0406 --- /dev/null +++ b/pages/windows/install-module.md @@ -0,0 +1,36 @@ +# Install-Module + +> Install PowerShell modules from PowerShell Gallery, NuGet, and other repositories. +> More information: . + +- Install a module, or update it to the latest available version: + +`Install-Module {{module}}` + +- Install a module with a specific version: + +`Install-Module {{module}} -RequiredVersion {{version}}` + +- Install a module no earlier than a specific version: + +`Install-Module {{module}} -MinimumVersion {{version}}` + +- Specify a range of supported versions (inclusive) of the required module: + +`Install-Module {{module}} -MinimumVersion {{minimum_version}} -MaximumVersion {{maximum_version}}` + +- Install module from a specific repository: + +`Install-Module {{module}} -Repository {{repository}}` + +- Install module from specific repositories: + +`Install-Module {{module}} -Repository {{repository1 , repository2 , ...}}` + +- Install the module for all/current user: + +`Install-Module {{module}} -Scope {{AllUsers|CurrentUser}}` + +- Perform a dry run to determine which modules will be installed, upgraded, or removed through `Install-Module`: + +`Install-Module {{module}} -WhatIf` diff --git a/pages/windows/pswindowsupdate.md b/pages/windows/pswindowsupdate.md new file mode 100644 index 000000000..da0dd27cb --- /dev/null +++ b/pages/windows/pswindowsupdate.md @@ -0,0 +1,13 @@ +# PSWindowsUpdate + +> A PowerShell external module to manage Windows Update. +> This tool provides multiple commands that all can only be run through PowerShell. +> More information: . + +- Install the module using `Install-Module`: + +`Install-Module PSWindowsUpdate` + +- List all commands available under the module: + +`Get-Command -Module PSWindowsUpdate`