### Send a query to the AIShell agent Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/ps-modules/AIShell/Invoke-AIShell.md This example demonstrates how to start the AIShell agent and then send a query to it. Responses are displayed within the AIShell window. ```powershell Start-AIShell Invoke-AIShell -Query "How do I list out the 5 most CPU intensive processes?" ``` -------------------------------- ### List GPTs Example Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/AIShell/how-to/aishell-reference.md Example of listing available GPTs and their descriptions. Shows how to view GPT details. ```powershell /gpt list Name Active Description ─────────────────────────────────────────────────────────────────────────────────────────────────── az-entraId-gpt-4o A GPT instance with expertise in PowerShell scripting using Entra ID authentication. az-aikey-gpt-4o true A GPT instance with expertise in PowerShell scripting using Entra ID authentication. ``` -------------------------------- ### Create and Convert ExampleInfo to JSON Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/ps-modules/Microsoft.PowerShell.Crescendo/New-ExampleInfo.md This example demonstrates how to use New-ExampleInfo to create an example object and then convert it to JSON format. This is useful for generating configuration data for Crescendo. ```powershell New-ExampleInfo -command Get-Something -originalCommand native.exe -description 'this is some text' | ConvertTo-Json ``` ```json { "Command": "Get-Something", "OriginalCommand": "native.exe", "Description": "this is some text" } ``` -------------------------------- ### Get SecretStore Configuration Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/ps-modules/Microsoft.PowerShell.SecretStore/Get-SecretStoreConfiguration.md This example retrieves and displays the current configuration of the SecretStore. It shows the scope, authentication method, password timeout, and interaction settings. ```powershell PS C:\> Get-SecretStoreConfiguration Scope Authentication PasswordTimeout Interaction ----- -------------- --------------- ----------- CurrentUser Password 900 Prompt ``` -------------------------------- ### Install Local MCP Servers Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/AIShell/how-to/mcp-support.md Installs the @modelcontextprotocol/server-everything and @modelcontextprotocol/server-filesystem MCP servers globally using npm. Requires Node.js to be installed. ```powershell npm install -g @modelcontextprotocol/server-everything npm install -g @modelcontextprotocol/server-filesystem ``` -------------------------------- ### Update Crescendo Module Help Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/Crescendo/get-started/install-crescendo.md Run this command to install the latest help content for the Crescendo module. The -Force parameter ensures you get the most up-to-date help. ```powershell Update-Help -Module Microsoft.PowerShell.Crescendo -Force ``` -------------------------------- ### New-ExampleInfo Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/ps-modules/Microsoft.PowerShell.Crescendo/Microsoft.PowerShell.Crescendo.md Creates a PowerShell object representing an example used in a Crescendo command object. ```APIDOC ## New-ExampleInfo ### Description Creates a PowerShell object representing an example used in a Crescendo command object. ### Method Not applicable (PowerShell cmdlet) ### Endpoint Not applicable (PowerShell cmdlet) ### Parameters (Parameters not explicitly detailed in the source text, refer to New-ExampleInfo.md for details) ### Request Example (Request example not explicitly detailed in the source text) ### Response (Response details not explicitly detailed in the source text) ``` -------------------------------- ### Example Cmdlet Usage Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/PlatyPS/step-2-edit-markdown-help.md Demonstrates how to use a cmdlet to retrieve a specific widget by its name. ```powershell Get-Widget -Name "Widget1" ``` -------------------------------- ### Correct Casing Example Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseCorrectCasing.md This example shows the correct casing for a foreach loop, Get-ChildItem cmdlet, and the -eq operator, as well as for the Invoke-Command cmdlet and -RunAsAdministrator parameter. ```powershell foreach ($file in Get-ChildItem -Recurse) { $file.Extension -eq '.txt' } Invoke-Command { 'foo' } -RunAsAdministrator ``` -------------------------------- ### Output Type Example Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/PlatyPS/step-2-edit-markdown-help.md Shows how to document the types of objects a cmdlet returns. ```markdown ## OUTPUTS ### Widget Outputs Widget objects representing the retrieved widgets. ``` -------------------------------- ### Pipeline Input Example Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/PlatyPS/step-2-edit-markdown-help.md Illustrates how to document the types of objects a cmdlet accepts via pipeline input. ```markdown ## INPUTS ### System.String This cmdlet accepts pipeline input for the name of the widget. ``` -------------------------------- ### Install Crescendo using Microsoft.PowerShell.PSResourceGet Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/Crescendo/get-started/install-crescendo.md Use this command to install the current release of the Crescendo module with Microsoft.PowerShell.PSResourceGet. The -Reinstall parameter is recommended if you have an older version installed. ```powershell # Install the current release Install-PSResource Microsoft.PowerShell.Crescendo -Reinstall ``` -------------------------------- ### Install Crescendo using PowerShellGet 2.x Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/Crescendo/get-started/install-crescendo.md Use this command to install the current release of the Crescendo module with PowerShellGet 2.x. The -Force parameter is recommended if you have an older version installed. ```powershell # Install the current release Install-Module Microsoft.PowerShell.Crescendo -Force ``` -------------------------------- ### Aligned Hashtable and Enum Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/PSScriptAnalyzer/Rules/AlignAssignmentStatement.md Example demonstrating the aligned version of the hashtable and enum from the previous example. ```powershell $hashtable = @{ property = 'value' anotherProperty = 'another value' } enum Enum { member = 1 anotherMember = 2 } ``` -------------------------------- ### Example: Add-Type Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseConstrainedLanguageMode.md This example demonstrates the use of Add-Type, which is restricted in Constrained Language Mode for unsigned scripts. ```powershell # Example of Add-Type, which is restricted in CLM for unsigned scripts. # To fix, use allowed cmdlets or pre-compile assemblies. ``` -------------------------------- ### Install PlatyPS Module Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/PlatyPS/step-1-create-new-markdown-help.md Installs the Microsoft.PowerShell.PlatyPS module from the PowerShell Gallery. This is a prerequisite for using PlatyPS. ```powershell Install-PSResource -Name Microsoft.PowerShell.PlatyPS ``` -------------------------------- ### PowerShell 7 Platform Profile Example (Ubuntu) Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseCompatibleTypes.md An example of a PowerShell platform profile for PowerShell 7.0 running on Ubuntu 18.04 LTS. ```powershell ubuntu_x64_18.04_7.0.0_x64_3.1.2_core ``` -------------------------------- ### Install SecretStore and SecretManagement Modules Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/SecretManagement/how-to/using-secrets-in-automation.md Installs the necessary modules for using SecretStore and SecretManagement. Ensure you are running these commands in the user context of the automation account on the host. ```powershell Install-Module -Name Microsoft.PowerShell.SecretStore -Repository PSGallery -Force Install-Module -Name Microsoft.PowerShell.SecretManagement -Repository PSGallery -Force Import-Module Microsoft.PowerShell.SecretStore Import-Module Microsoft.PowerShell.SecretManagement ``` -------------------------------- ### Add Examples to Crescendo Command Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/Crescendo/advanced/using-crescendo-cmdlets.md This snippet shows how to add multiple usage examples to a Crescendo command, each with a command alias, description, and the original command-line invocation. ```powershell $example = @{ Command = 'Get-VssShadow' Description = 'Get a list of VSS shadow copies' OriginalCommand = 'vssadmin list shadows' } $newCommand.Examples += New-ExampleInfo @example $example = @{ Command = 'Get-VssShadow -For C:' Description = 'Get a list of VSS shadow copies for volume C:' OriginalCommand = 'vssadmin list shadows /For=C:' } $newCommand.Examples += New-ExampleInfo @example $example = @{ Command = "Get-VssShadow -Shadow '{c17ebda1-5da3-4f4a-a3dc-f5920c30ed0f}'" Description = 'Get a specific shadow copy' OriginalCommand = 'vssadmin list shadows /Shadow={3872a791-51b6-4d10-813f-64b4beb9f935}' } $newCommand.Examples += New-ExampleInfo @example ``` -------------------------------- ### OutputFolder Parameter Example Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/ps-modules/Microsoft.PowerShell.PlatyPS/Export-YamlCommandHelp.md Specifies the folder where the markdown file will be saved. The folder is created if it does not exist. ```yaml Type: System.String DefaultValue: None SupportsWildcards: false Aliases: [] ParameterSets: - Name: (All) Position: Named IsRequired: false ValueFromPipeline: false ValueFromPipelineByPropertyName: false ValueFromRemainingArguments: false DontShow: false AcceptedValues: [] HelpMessage: '' ``` -------------------------------- ### Start Foundry Local Service and Load Model Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/AIShell/how-to/agent-openai.md These PowerShell commands start the Foundry Local service, load a specific model, and then list the models currently running in the service. This is a prerequisite for configuring the OpenAI agent to use Foundry Local. ```powershell PS> foundry service start 🟢 Service is already running on http://127.0.0.1:56952/. PS> foundry model load phi-3.5-mini 🕔 Loading model... 🟢 Model phi-3.5-mini loaded successfully PS> foundry service ps Models running in service: Alias Model ID 🟢 phi-3.5-mini Phi-3.5-mini-instruct-generic-cpu ``` -------------------------------- ### Correct function with PSCredential parameter Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingUsernameAndPasswordParams.md This example demonstrates the recommended approach using a single PSCredential object parameter. ```powershell function Test-Script { [CmdletBinding()] Param ( [PSCredential] $Credential ) ... } ``` -------------------------------- ### WhatIf Parameter Example Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/ps-modules/Microsoft.PowerShell.PlatyPS/Export-YamlCommandHelp.md Enables a mode that reports what would happen without performing the actions. ```yaml Type: System.Management.Automation.SwitchParameter DefaultValue: False SupportsWildcards: false Aliases: - wi ParameterSets: - Name: (All) Position: Named IsRequired: false ValueFromPipeline: false ValueFromPipelineByPropertyName: false ValueFromRemainingArguments: false DontShow: false AcceptedValues: [] HelpMessage: '' ``` -------------------------------- ### PowerShell Platform Profile Example Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseCompatibleTypes.md Illustrates the format of a PowerShell platform profile used for compatibility analysis. This example shows a profile for PowerShell 5.1 on Windows 10 Enterprise. ```powershell win-48_x64_10.0.17763.0_5.1.17763.316_x64_4.0.30319.42000_framework ``` -------------------------------- ### Get Crescendo Agent Config Property Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/Crescendo/get-started/generate-module.md This example shows how to use the `Get-AzCmAgentConfigProperty` cmdlet to retrieve specific configuration settings, such as proxy URL. ```powershell Get-AzCmAgentConfigProperty -Property proxy.url ``` -------------------------------- ### Example Usage of Get-InstalledPackage Cmdlet Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/ps-modules/Microsoft.PowerShell.Crescendo/About/about_Crescendo.md Demonstrates how to use the `Get-InstalledPackage` cmdlet generated by Crescendo to filter packages by name and group them by architecture. ```powershell PS> Get-InstalledPackage | Where-Object { $_.name -match "libc"} Name Version Architecture State ---- ------- ------------ ----- c6-bin 2.31-0ubuntu9.1 amd64 {installed, local} c6 2.31-0ubuntu9.1 amd64 {installed, local} libcap-ng0 0.7.9-2.1build1 amd64 {installed, local} libcom-err2 1.45.5-2ubuntu1 amd64 {installed, local} libcrypt1 1:4.4.10-10ubuntu4 amd64 {installed, local} PS> Get-InstalledPackage | Group-Object Architecture Count Name Group ----- ---- ----- 10 all {@{Name=adduser; Version=3.118ubuntu2; Architecture=all; State=System.String[]}, @{Name=debconf; V… 82 amd64 {@{Name=apt; Version=2.0.2ubuntu0.1; Architecture=amd64; State=System.String[]}, @{Name=base-files… ``` -------------------------------- ### Get Azure OpenAI Account Endpoint Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/AIShell/developer/deploy-azure-openai.md Retrieves the endpoint for an Azure Cognitive Services account. This is part of the setup for deploying Azure OpenAI. ```powershell $AzCognitiveServicesAccountSplat = @{ ResourceGroupName = '' Name = '' } Get-AzCognitiveServicesAccount @AzCognitiveServicesAccountSplat | Select-Object -Property Endpoint ``` -------------------------------- ### Create Updateable Help Files for a Module Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/ps-modules/Microsoft.PowerShell.PlatyPS/New-HelpCabinetFile.md This example demonstrates how to create updateable help files for a module using New-HelpCabinetFile. It defines parameters for the cabinet files folder, the module's Markdown file, and the output folder. ```powershell $params = @{ CabinetFilesFolder = '.\maml\Microsoft.PowerShell.PlatyPS' MarkdownModuleFile = '.\Microsoft.PowerShell.PlatyPS\Microsoft.PowerShell.PlatyPS.md' OutputFolder = '.\cab' } New-HelpCabinetFile @params ``` -------------------------------- ### Missing DefaultParameterSetName Example Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseConsistentParameterSetName.md Demonstrates a function where parameter sets are used without specifying a DefaultParameterSetName. ```powershell function Get-Data { [CmdletBinding()] param( [Parameter(ParameterSetName='ByName')] [string]$Name, [Parameter(ParameterSetName='ByID')] [int]$ID ) } ``` -------------------------------- ### Import MAML Help from a File Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/ps-modules/Microsoft.PowerShell.PlatyPS/Import-MamlHelp.md This example shows how to import MAML help from a specified file using the -Path parameter. Ensure the MAML file exists at the specified location. ```powershell Import-MamlHelp -Path .\maml\Microsoft.PowerShell.PlatyPS.dll-Help.xml ``` -------------------------------- ### Get DSC Rules with Error Severity Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/ps-modules/PSScriptAnalyzer/Get-ScriptAnalyzerRule.md Retrieves DSC rules with an 'Error' severity and prepares them for use with Invoke-ScriptAnalyzer. This example demonstrates filtering by both severity and source name. ```powershell $DSCError = Get-ScriptAnalyzerRule -Severity Error | Where-Object SourceName -eq PSDSC $Path = "$home\Documents\WindowsPowerShell\Modules\MyDSCModule\*" Invoke-ScriptAnalyzerRule -Path $Path -IncludeRule $DSCError -Recurse ``` -------------------------------- ### Preview PlatyPS Help Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/ps-modules/platyPS/Get-HelpPreview.md This example shows how to preview the generated help for the platyPS module. It first stores the help object in a variable and then displays the 'Name' property of each help item. ```powershell PS C:\> $Help = Get-HelpPreview -Path ".\out\platyPS\en-US\PlatyPS-help.xml" PS C:\> $Help.Name Get-HelpPreview Get-MarkdownMetadata New-ExternalHelp New-ExternalHelpCab New-MarkdownHelp Update-MarkdownHelp Update-MarkdownHelpModule Update-MarkdownHelpSchema ``` -------------------------------- ### Get All Secret Metadata Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/ps-modules/Microsoft.PowerShell.SecretManagement/Get-SecretInfo.md Retrieves metadata for all stored secrets across all registered vaults by using a wildcard for the Name parameter. This example demonstrates the various types of secrets that can be stored. ```powershell Get-SecretInfo -Name * ``` -------------------------------- ### Retrieve a secret using pipeline input Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/ps-modules/Microsoft.PowerShell.SecretManagement/Get-Secret.md This example demonstrates retrieving a secret as plain text by first getting secret information using Get-SecretInfo and then piping the result to Get-Secret with the -AsPlainText parameter. ```powershell Get-SecretInfo -Name Secret2 -Vault SecretStore | Get-Secret -AsPlainText ``` -------------------------------- ### Resolve the last error using Resolve-Error Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/ps-modules/AIShell/Resolve-Error.md This example demonstrates how to use the Resolve-Error cmdlet to send the last occurring error to the AIShell agent for resolution. Ensure AIShell is started before using this command. ```powershell PS> Start-AIShell #User receives an error PS> Resolve-Error ``` -------------------------------- ### New-HelpCabinetFile Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/ps-modules/Microsoft.PowerShell.PlatyPS/New-HelpCabinetFile.md Creates a help cabinet file for a module that can be published as updateable help content. ```APIDOC ## New-HelpCabinetFile ### Description Creates a help cabinet file for a module that can be published as updateable help content. This cmdlet creates `.cab` and `.zip` files that contain help files for a module, and also generates or updates an existing `Helpinfo.xml` file for versioning and locale details. It depends on the `MakeCab.exe` command and is only available on Windows. ### Method `New-HelpCabinetFile` ### Parameters #### Path Parameters - **CabinetFilesFolder** (string) - Required - The path to the folder containing the MAML file to be packaged. - **MarkdownModuleFile** (string) - Required - Specifies the full path of the module Markdown file. - **OutputFolder** (string) - Required - The location where you want to write the `.cab`, `.zip`, and `HelpInfo.xml` files. #### Switch Parameters - **Confirm** (SwitchParameter) - Optional - Prompts you for confirmation before running the cmdlet. - **WhatIf** (SwitchParameter) - Optional - Runs the command in a mode that only reports what would happen without performing the actions. ### Example ```powershell $params = @{ CabinetFilesFolder = '.\maml\Microsoft.PowerShell.PlatyPS' MarkdownModuleFile = '.\Microsoft.PowerShell.PlatyPS\Microsoft.PowerShell.PlatyPS.md' OutputFolder = '.\cab' } New-HelpCabinetFile @params ``` ### Outputs - **System.IO.FileInfo** - The **FileInfo** objects that represent the files created by this cmdlet. ``` -------------------------------- ### Register Az.KeyVault Extension Vault with Parameters Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/ps-modules/Microsoft.PowerShell.SecretManagement/Register-SecretVault.md This example registers the Az.KeyVault extension vault, specifying vault parameters for Azure Key Vault name and subscription ID. The Az.KeyVault module must be installed beforehand. The registered vault is set as the default. ```powershell $parameters = @{ Name = 'Azure' ModuleName = 'Az.KeyVault' VaultParameters = @{ AZKVaultName = 'AzureKeyVault' SubscriptionId = (Get-AzContext).Subscription.Id } DefaultVault = $true } Register-SecretVault @parameters Get-SecretVault ``` -------------------------------- ### Create a new .NET class library project Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/AIShell/developer/create-ollama-agent.md Use the dotnet CLI to create a new class library project for your agent. ```shell dotnet new classlib ``` -------------------------------- ### Correct Parameter Set Configuration Example Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseConsistentParameterSetName.md Shows a properly configured function with a DefaultParameterSetName and consistent casing across all parameter set references. ```powershell function Get-Data { [CmdletBinding(DefaultParameterSetName='ByName')] param( [Parameter(ParameterSetName='ByName', Mandatory)] [string]$Name, [Parameter(ParameterSetName='ByName')] [Parameter(ParameterSetName='ByID')] [string]$ComputerName, [Parameter(ParameterSetName='ByID', Mandatory)] [int]$ID ) } ``` -------------------------------- ### Install AIShell PowerShell Module on Windows Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/AIShell/install-aishell.md Install the AIShell module from the PowerShell Gallery on Windows systems as part of the manual installation process. ```powershell Install-PSResource -Name AIShell -Preview ``` -------------------------------- ### Create a CAB file with New-ExternalHelpCab Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/ps-modules/platyPS/New-ExternalHelpCab.md This example demonstrates how to use the New-ExternalHelpCab cmdlet to create a .cab file. It specifies the folder containing help content, the path to the module's landing page for metadata, and the output folder for the generated .cab file. ```powershell $params = @{ CabFilesFolder = 'C:\Module\ExternalHelpContent' LandingPagePath = 'C:\Module\ModuleName.md' OutputFolder = 'C:\Module\Cab\' } New-ExternalHelpCab @params ``` -------------------------------- ### Install PSScriptAnalyzer using PowerShellGet Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/PSScriptAnalyzer/overview.md Use this command to install the PSScriptAnalyzer module with PowerShellGet version 2.x. The -Force parameter is necessary to reinstall or install if an older version exists. ```powershell Install-Module -Name PSScriptAnalyzer -Force ``` -------------------------------- ### AI Shell Agent List Command Example Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/AIShell/how-to/aishell-reference.md Shows how to list all available AI agents and their descriptions. This helps in understanding which agents are available and their primary functions. ```bash > /agent list ``` -------------------------------- ### Use Direct Command Execution Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingInvokeExpression.md Shows the correct way to achieve the same result as the 'Wrong' example by directly executing the command. ```powershell Get-Process ``` -------------------------------- ### Install AI Shell using PowerShell Script Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/AIShell/install-aishell.md Use this command to install AI Shell on Windows and macOS systems. It installs the 'aish' executable and the AIShell PowerShell module. ```powershell Invoke-Expression "& { $(Invoke-RestMethod 'https://aka.ms/install-aishell.ps1') }" ``` -------------------------------- ### Install PSScriptAnalyzer using PSResourceGet Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/PSScriptAnalyzer/overview.md Use this command to install the PSScriptAnalyzer module with PSResourceGet version 1.x. The -Reinstall parameter ensures the latest version is installed or an existing one is reinstalled. ```powershell Install-PSResource -Name PSScriptAnalyzer -Reinstall ``` -------------------------------- ### New-ExampleInfo Cmdlet Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/ps-modules/Microsoft.PowerShell.Crescendo/New-ExampleInfo.md Creates a PowerShell object representing an example used in a Crescendo command object. The resulting object can be converted to JSON to be inserted into a configuration file or added to a command object conversion to JSON later. ```APIDOC ## New-ExampleInfo ### Description Creates a PowerShell object representing an example used in a Crescendo command object. The resulting object can be converted to JSON to be inserted into a configuration file or added to a command object conversion to JSON later. ### Method `New-ExampleInfo` ### Parameters #### Command Line Parameters - **-command** (System.String) - Required - The command line for the example being described. - **-description** (System.String) - Required - The description of the example. - **-originalCommand** (System.String) - Optional - The original native command that's run for this cmdlet example. ### Request Example ```powershell New-ExampleInfo -command Get-Something -originalCommand native.exe -description 'this is some text' | ConvertTo-Json ``` ### Response Example ```json { "Command": "Get-Something", "OriginalCommand": "native.exe", "Description": "this is some text" } ``` ``` -------------------------------- ### Create Markdown Help from a Module Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/ps-modules/platyPS/New-MarkdownHelp.md Generates Markdown help for all cmdlets within a specified module. This example imports the PlatyPS module and then creates help files in the '.\[docs]' folder, overwriting existing files due to the -Force parameter. ```powershell PS C:\> Import-Module -Module "PlatyPS" PS C:\> New-MarkdownHelp -Module "PlatyPS" -OutputFolder ".\docs" -Force ``` -------------------------------- ### AI Shell Agent Config Command Example Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/AIShell/how-to/aishell-reference.md Demonstrates how to open the configuration file for a specific AI agent, like 'openai-gpt'. This is useful for customizing agent settings. ```bash /agent config openai-gpt ``` -------------------------------- ### New-MarkdownHelp - FromModule Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/ps-modules/platyPS/New-MarkdownHelp.md Creates markdown help files for all commands within a specified module. ```APIDOC ## New-MarkdownHelp - FromModule ### Description Creates markdown help files for all commands within a specified module. ### Method `New-MarkdownHelp` ### Parameters #### Path Parameters - **Module** (String[]) - Required - The name of the module for which to create help files. - **OutputFolder** (String) - Required - The folder where the markdown help files will be saved. #### Optional Parameters - **Session** (PSSession) - Specifies a PowerShell session to use for creating help. - **Force** - Overwrites existing markdown help files without prompting. - **AlphabeticParamsOrder** - Sorts parameters alphabetically in the generated help. - **Metadata** (Hashtable) - A hashtable containing metadata to include in the help files. - **NoMetadata** - Excludes metadata from the generated help files. - **UseFullTypeName** - Uses the full type name for parameters in the help files. - **Encoding** (Encoding) - Specifies the file encoding for the generated help files. - **WithModulePage** - Creates a module landing page in markdown format. - **ModulePagePath** (String) - Specifies the path for the module landing page. - **Locale** (String) - Specifies the locale for the help files. - **HelpVersion** (String) - Specifies the version of the help files. - **FwLink** (String) - Specifies a framework link to include in the help files. - **ExcludeDontShow** - Excludes commands marked with 'DontShow' from help generation. - **CommonParameters** - Includes common parameters available in PowerShell cmdlets. ``` -------------------------------- ### Test a Markdown Help File Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/ps-modules/Microsoft.PowerShell.PlatyPS/Test-MarkdownCommandHelp.md This example demonstrates testing a Markdown Module help file. The test is expected to fail as it's designed for command help files, showcasing the detailed output from the DetailView parameter. ```powershell Test-MarkdownCommandHelp .\v2\Microsoft.PowerShell.PlatyPS\Microsoft.PowerShell.PlatyPS.md -DetailView ``` -------------------------------- ### Install SecretManagement and SecretStore modules with PSResourceGet 1.x Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/SecretManagement/get-started/using-secretstore.md Installs the SecretManagement and SecretStore modules using PSResourceGet version 1.x. ```powershell # Install with PSResourceGet 1.x Install-PSResource Microsoft.PowerShell.SecretManagement Install-PSResource Microsoft.PowerShell.SecretStore ``` -------------------------------- ### Install SecretManagement and SecretStore modules with PowerShellGet 2.x Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/SecretManagement/get-started/using-secretstore.md Installs the SecretManagement and SecretStore modules using PowerShellGet version 2.x. ```powershell # Install with PowerShellGet 2.x Install-Module Microsoft.PowerShell.SecretManagement Install-Module Microsoft.PowerShell.SecretStore ``` -------------------------------- ### DSC Resource MOF Definition Example Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/PSScriptAnalyzer/Rules/DSCUseIdenticalMandatoryParametersForDSC.md Example of a MOF file defining a DSC resource with Key and Required attributes. ```powershell class WaitForAny : OMI_BaseResource { [key, Description("Name of Resource on remote machine")] string Name; [required, Description("List of remote machines")] string NodeName[]; }; ``` -------------------------------- ### YAML Frontmatter Example Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/PlatyPS/step-2-edit-markdown-help.md Shows the minimum required metadata properties for PlatyPS Markdown help files. Ensure 'title' matches the cmdlet name. ```yaml --- document type: cmdlet external help file: WidgetModule-Help.xml HelpUri: '' Locale: en-US Module Name: WidgetModule ms.date: 10/09/2025 PlatyPS schema version: 2024-05-01 title: Get-Widget --- ``` -------------------------------- ### fizztool.exe Failure Example Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/Crescendo/advanced/handling-errors.md This example demonstrates an invocation of `fizztool.exe` that produces an error. Both the copyright line and the error message are written to stderr. ```powershell fizztool.exe --key buzz | ConvertFrom-Json ``` -------------------------------- ### New-MarkdownHelp - FromCommand Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/ps-modules/platyPS/New-MarkdownHelp.md Creates a markdown help file for a specific command. ```APIDOC ## New-MarkdownHelp - FromCommand ### Description Creates a markdown help file for a specific command. ### Method `New-MarkdownHelp` ### Parameters #### Path Parameters - **Command** (String[]) - Required - The name of the command for which to create help. - **OutputFolder** (String) - Required - The folder where the markdown help file will be saved. #### Optional Parameters - **Session** (PSSession) - Specifies a PowerShell session to use for creating help. - **Force** - Overwrites existing markdown help files without prompting. - **AlphabeticParamsOrder** - Sorts parameters alphabetically in the generated help. - **Metadata** (Hashtable) - A hashtable containing metadata to include in the help files. - **OnlineVersionUrl** (String) - Specifies the URL for the online version of the help. - **NoMetadata** - Excludes metadata from the generated help files. - **UseFullTypeName** - Uses the full type name for parameters in the help files. - **Encoding** (Encoding) - Specifies the file encoding for the generated help files. - **ExcludeDontShow** - Excludes commands marked with 'DontShow' from help generation. - **CommonParameters** - Includes common parameters available in PowerShell cmdlets. ``` -------------------------------- ### Get Help for VSSAdmin Commands Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/Crescendo/advanced/using-crescendo-cmdlets.md Use these commands to get help for the `vssadmin list providers` and `vssadmin list shadows` commands. ```powershell vssadmin list providers /? ``` ```powershell vssadmin list shadows /? ``` -------------------------------- ### Test-MarkdownCommandHelp Output Example Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/ps-modules/Microsoft.PowerShell.PlatyPS/Test-MarkdownCommandHelp.md This is an example of the detailed output from Test-MarkdownCommandHelp when run with the -DetailView parameter, showing validation results and specific messages for each section. ```powershell Test-MarkdownCommandHelp Valid: False File: D:\Git\PS-Src\platyPS\v2docs\v2\Microsoft.PowerShell.PlatyPS\Microsoft.PowerShell.PlatyPS.md Messages: PASS: First element is a thematic break FAIL: SYNOPSIS not found. FAIL: SYNTAX not found. FAIL: DESCRIPTION not found. FAIL: EXAMPLES not found. FAIL: PARAMETERS not found. FAIL: INPUTS not found. FAIL: OUTPUTS not found. FAIL: NOTES not found. FAIL: RELATED LINKS not found. ``` -------------------------------- ### Parameter Metadata Example Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/PlatyPS/step-2-edit-markdown-help.md Shows the YAML structure for documenting a cmdlet parameter, including its type, default value, and support for wildcards. ```yaml Type: System.ConsoleColor DefaultValue: '' SupportsWildcards: false Aliases: [] ParameterSets: - Name: (All) Position: Named IsRequired: false ValueFromPipeline: false ValueFromPipelineByPropertyName: false ValueFromRemainingArguments: false DontShow: false AcceptedValues: [] HelpMessage: '' ``` -------------------------------- ### AI Shell Agent Use Command Example Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/AIShell/how-to/aishell-reference.md Illustrates how to specify an AI agent to use for the current session. If no agent is specified, AI Shell prompts the user to choose from available agents. ```bash /agent use [] [options] ``` -------------------------------- ### Package Help Files for Updatable Help Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/PlatyPS/step-4-convert-publish-help.md Creates an Updatable Help package including MAML and text-based help files, along with a HelpInfo.xml file. Requires the module manifest to have a HelpInfoUri property. ```powershell $params = @{ CabinetFilesFolder = '.\maml\WidgetModule' MarkdownModuleFile = '.\WidgetModule\WidgetModule.md' OutputFolder = '.\helppackage' } New-HelpCabinetFile @params ``` -------------------------------- ### Unused Parameter Example (Wrong) Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/PSScriptAnalyzer/Rules/ReviewUnusedParameter.md This example demonstrates a function with an unused parameter ($Parameter2). The PSScriptAnalyzer rule ReviewUnusedParameter would flag this as a warning. ```powershell function Test-Parameter { Param ( $Parameter1, # this parameter is never called in the function $Parameter2 ) Get-Something $Parameter1 } ``` -------------------------------- ### Export CommandHelp Objects to MAML Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/ps-modules/Microsoft.PowerShell.PlatyPS/Export-MamlCommandHelp.md This example demonstrates how to create a MAML help file for a module. It first measures markdown files, filters for CommandHelp types, imports them, and then exports them to a MAML file in the specified output folder. ```powershell $mdfiles = Measure-PlatyPSMarkdown -Path .\v2\Microsoft.PowerShell.PlatyPS\*.md $mdfiles | Where-Object Filetype -match 'CommandHelp' | Import-MarkdownCommandHelp -Path {$_.FilePath} | Export-MamlCommandHelp -OutputFolder .\maml ``` -------------------------------- ### Start-AIShell Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/ps-modules/AIShell/AIShell.md Starts an AIShell session in a split pane window of Windows Terminal and iTerm2 and connects a communication channel to the PowerShell session that started it. ```APIDOC ## Start-AIShell ### Description Starts an AIShell session in a split pane window of Windows Terminal and iTerm2 and connects a communication channel to the PowerShell session that started it. ### Method Not specified ### Endpoint Not specified ### Parameters Not specified ### Request Example Not specified ### Response Not specified ``` -------------------------------- ### Import a Yaml Module File Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/ps-modules/Microsoft.PowerShell.PlatyPS/Import-YamlModuleFile.md This example demonstrates how to import a Yaml module file using its path. The output shows the resulting ModuleHelp object's properties. ```powershell Import-YamlModuleFile .\v2\yaml\Microsoft.PowerShell.PlatyPS.yml ``` -------------------------------- ### Create a Usage Object and Convert to JSON Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/ps-modules/Microsoft.PowerShell.Crescendo/New-UsageInfo.md Demonstrates how to create a Usage object using New-UsageInfo and then convert it to JSON format. This is useful for generating configuration files. ```powershell $usage = New-UsageInfo -usage 'This is a description for how to use the cmdlet.' $usage | ConvertTo-Json ``` ```json { "Synopsis": "This is a description for how to use the cmdlet.", "SupportsFlags": false, "HasOptions": false, "OriginalText": null } ``` -------------------------------- ### Incorrect Casing Example Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseCorrectCasing.md This example demonstrates incorrect casing for a ForEach loop, Get-childitem cmdlet, and the -EQ operator, as well as for the invoke-command cmdlet and -runasadministrator parameter. ```powershell ForEach ($file in Get-childitem -Recurse) { $file.Extension -EQ '.txt' } invoke-command { 'foo' } -runasadministrator ``` -------------------------------- ### Used Parameter Example (Correct) Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/PSScriptAnalyzer/Rules/ReviewUnusedParameter.md This example shows the corrected version of the function where the previously unused parameter ($Parameter2) is now utilized. This resolves the warning from the ReviewUnusedParameter rule. ```powershell function Test-Parameter { Param ( $Parameter1, # now this parameter is being called in the same scope $Parameter2 ) Get-Something $Parameter1 $Parameter2 } ``` -------------------------------- ### Create Module File from Command List Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/ps-modules/Microsoft.PowerShell.PlatyPS/New-MarkdownModuleFile.md This example shows how to create a module's Markdown file using a splatting technique to pass parameters to New-MarkdownModuleFile. It first retrieves commands for a specific module, converts them to CommandHelp objects, and then uses New-MarkdownModuleFile with the `-Force` parameter. ```powershell $newMarkdownCommandHelpSplat = @{ CommandHelp = Get-Command -Module Microsoft.PowerShell.PlatyPS | New-CommandHelp OutputFolder = '.\new' Force = $true } New-MarkdownModuleFile @newMarkdownCommandHelpSplat ``` -------------------------------- ### Function With Comment Help Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/PSScriptAnalyzer/Rules/ProvideCommentHelp.md This example demonstrates a function definition that includes comprehensive comment-based help, adhering to standard PowerShell help topics. This format satisfies the PSProvideCommentHelp rule. ```powershell <# .Synopsis Short description .DESCRIPTION Long description .EXAMPLE Example of how to use this cmdlet .EXAMPLE Another example of how to use this cmdlet .INPUTS Inputs to this cmdlet (if any) .OUTPUTS Output from this cmdlet (if any) .NOTES General notes .COMPONENT The component this cmdlet belongs to .ROLE The role this cmdlet belongs to .FUNCTIONALITY The functionality that best describes this cmdlet #> function Get-File { [CmdletBinding()] Param ( ... ) } ``` -------------------------------- ### Start AI Shell Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/AIShell/get-started/aishell-powershell.md Use the `Start-AIShell` command to open the AI Shell sidecar experience in Windows Terminal. You will be prompted to choose an agent upon starting. ```powershell Start-AIShell ``` -------------------------------- ### Compare CommandHelp Objects Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/ps-modules/Microsoft.PowerShell.PlatyPS/Compare-CommandHelp.md This example demonstrates how to import two CommandHelp objects from different Markdown file versions and then compare them, saving the differences to a log file. ```powershell $refcmd = Import-MarkdownCommandHelp -Path .\v1\Microsoft.PowerShell.PlatyPS\Compare-CommandHelp.md $diffcmd = Import-MarkdownCommandHelp -Path .\v2\Microsoft.PowerShell.PlatyPS\Compare-CommandHelp.md Compare-CommandHelp -ReferenceCommandHelp $refcmd -DifferenceCommandHelp $diffcmd > .\diff.log ``` -------------------------------- ### fizztool.exe Success Example Source: https://github.com/microsoftdocs/powershell-docs-modules/blob/main/reference/docs-conceptual/Crescendo/advanced/handling-errors.md This example shows a successful invocation of `fizztool.exe` where informational messages are written to stderr and JSON data to stdout. The output can be converted to PowerShell objects. ```powershell fizztool.exe --key fizz | ConvertFrom-Json ```