### Install-PSFModule Usage Examples Source: https://psframework.org/docs/Commands/PSFramework.NuGet/Install-PSFModule Common usage patterns for installing modules locally or on remote computers. ```powershell Install-PSFModule -Name EntraAuth ``` ```powershell Install-PSFModule -Name ADMF -ComputerName AdminHost1, AdminHost2 ``` ```powershell Install-PSFModule -Name string, PoshRSJob -ComputerName $sshSessions -Scope ScriptModules ``` -------------------------------- ### Get-PSMDHelp Syntax: Examples View Source: https://psframework.org/docs/Commands/PSModuleDevelopment/Get-PSMDHelp Displays examples for a help topic. This parameter is effective only when help files for the command are installed. ```powershell Get-PSMDHelp [-Examples] [-Category ] [-Component ] [[-Name] ] [[-Language] ] [-SetLanguage ] [-Path ] [-Functionality ] [-Role ] [] ``` -------------------------------- ### Console Logging Style Examples Source: https://psframework.org/docs/PSFramework/Logging/loggingto/console Examples of formatting strings using placeholders. ```powershell %Time% %Message% 14:02:08.229 Test Message ``` ```powershell [%Level%] %Message% [Warning] %Test Message ``` ```powershell %File% : %Line%`n [%Level%] %Message% C:\scripts\demo.ps1 : 14 [Verbose] Test Message ``` -------------------------------- ### Get-PSMDTemplate Usage Examples Source: https://psframework.org/docs/Commands/PSModuleDevelopment/Get-PSMDTemplate Basic usage examples for retrieving templates. ```powershell Get-PSMDTemplate ``` ```powershell Get-PSMDTemplate -TemplateName module ``` -------------------------------- ### Example: Start a timer for 170 seconds with a message Source: https://psframework.org/docs/Commands/PSUtil/Start-PSUTimer This example demonstrates how to start a timer for 170 seconds and display a message when it expires. The 'Duration' parameter accepts a numerical value representing seconds. ```powershell timer 170 Tea ``` -------------------------------- ### Get-PSMDHelp Example: Detailed Help Source: https://psframework.org/docs/Commands/PSModuleDevelopment/Get-PSMDHelp Gets the detailed help text of Get-Help in English. This demonstrates retrieving specific help content. ```powershell Get-PSMDHelp Get-Help "en-us" -Detailed ``` -------------------------------- ### Update-PSFTeppCompletion Usage Example Source: https://psframework.org/docs/Commands/PSFramework/Update-PSFTeppCompletion A basic example showing how to call the cmdlet in a PowerShell session. ```PowerShell PS C:\> Update-PSFTeppCompletion ``` -------------------------------- ### Read-PSFRunspaceQueue Usage Examples Source: https://psframework.org/docs/Commands/PSFramework/Read-PSFRunspaceQueue Practical examples for retrieving data from workflow queues. ```powershell $workflow | Read-PSFRunspaceQueue -Name Done -All ``` ```powershell Read-PSFRunspaceQueue -Name extraData ``` -------------------------------- ### Write-PSFRunspaceQueue Bulk Example Source: https://psframework.org/docs/Commands/PSFramework/Write-PSFRunspaceQueue Example demonstrating how to provide multiple values as input to a specific queue. ```powershell $workflow | Write-PSFRunspaceQueue -Name input -BulkValues $entries ``` -------------------------------- ### Full Example with Invoke-PSFCommand Source: https://psframework.org/docs/PSFramework/ParameterClasses/computer-parameter This example demonstrates using `Invoke-PSFCommand` with `[PSFComputer[]]` to enable reuse of existing PSRemoting sessions, improving efficiency. ```powershell function Get-OSInfo { [CmdletBinding()] param ( [PSFComputer[]] $ComputerName, [pscredential] $Credential ) $param = @{} if ($ComputerName) { $param.ComputerName = $ComputerName } if ($Credential) { $param.Credential = $Credential } Invoke-PSFCommand @param -ScriptBlock { Get-CimInstance win32_OperatingSystem } } ``` -------------------------------- ### SQL Logging Provider Installation Source: https://psframework.org/docs/PSFramework/Logging/providers/sql Instructions for installing the SQL Logging Provider and its prerequisites. ```APIDOC ## Installation The Sql provider requires the dbatools PowerShell Module installed on the system it is running on. To install the prerequisites use either: ```powershell Install-PSFLoggingProvider -Name Sql ``` Or manually deploy the required module. ``` -------------------------------- ### Usage Examples Source: https://psframework.org/docs/Commands/PSFramework/Write-PSFMessageProxy Examples demonstrating how to use the Write-PSFMessageProxy function. ```APIDOC ### EXAMPLE 1 ```powershell Write-PSFMessageProxy "Example Message" ``` Will write the message "Example Message" to verbose. ### EXAMPLE 2 ```powershell Set-Alias Write-Host Write-PSFMessageProxy Write-Host "Example Message" ``` This will create an alias named "Write-Host" pointing at "Write-PSFMessageProxy". Then it will write the message "Example Message", which is automatically written to Level "Important" (which by default will be written to host). ``` -------------------------------- ### Get-PSFLicense Examples Source: https://psframework.org/docs/Commands/PSFramework/Get-PSFLicense Examples showing how to filter licenses by product name or specific license and product types. ```powershell Get-PSFLicense *Microsoft* ``` ```powershell Get-PSFLicense -LicenseType Commercial -ProductType Library ``` -------------------------------- ### Register-PSFTempProvider Implementation Example Source: https://psframework.org/docs/Commands/PSFramework/Register-PSFTempProvider A practical example showing how to implement a temporary file provider using script blocks for creation, existence validation, and deletion. ```PowerShell Register-PSFTempProvider -Name TempFile -CreationScript { param ($Data) $newPath = Join-Path (Get-PSFPath temp) (Get-Random) New-Item -Path $newPath -ItemType File } -ExistsScript { param ($Data, $CreationData) Test-Path $CreationData.FullName } -DeleteScript { param ($Data, $CreationData) Remove-Item $CreationData.FullName } ``` -------------------------------- ### Test-PSFParameterBinding Usage Examples Source: https://psframework.org/docs/Commands/PSFramework/Test-PSFParameterBinding Examples demonstrating basic parameter binding checks, negation, and logical conjunction. ```PowerShell if (Test-PSFParameterBinding "Day") ``` ```PowerShell Test-PSFParameterBinding -Not 'Login', 'Spid', 'ExcludeSpid', 'Host', 'Program', 'Database' ``` ```PowerShell Test-PSFParameterBinding -And 'Login', 'Spid', 'ExcludeSpid', 'Host', 'Program', 'Database' ``` -------------------------------- ### Set-PSFFeature Examples Source: https://psframework.org/docs/Commands/PSFramework/Set-PSFFeature Examples showing how to set feature flags for specific modules or globally. ```powershell Set-PSFFeature -Name 'PSFramework.InheritEnableException' -Value $true -ModuleName SPReplicator ``` ```powershell Set-PSFFeature -Name 'MyModule.Feierabend' -Value $true ``` -------------------------------- ### Get-PSMDHelp Parameter: -Full Source: https://psframework.org/docs/Commands/PSModuleDevelopment/Get-PSMDHelp Displays the entire help topic, including parameter descriptions, attributes, examples, and notes. This parameter is effective only when help files for the command are installed. ```powershell Type: SwitchParameter Parameter Sets: AllUsersView Aliases: Required: False Position: Named Default value: False Accept pipeline input: False Accept wildcard characters: False ``` -------------------------------- ### Get-PSMDHelp Syntax: DetailedView Source: https://psframework.org/docs/Commands/PSModuleDevelopment/Get-PSMDHelp Adds parameter descriptions and examples to the basic help display. This parameter is effective only when help files for the command are installed. ```powershell Get-PSMDHelp [-Detailed] [-Category ] [-Component ] [[-Name] ] [[-Language] ] [-SetLanguage ] [-Path ] [-Functionality ] [-Role ] [] ``` -------------------------------- ### Resolve-PSFPath Examples Source: https://psframework.org/docs/Commands/PSFramework/Resolve-PSFPath Usage examples for resolving specific file paths and wildcard patterns. ```powershell Resolve-PSFPath -Path report.log -Provider FileSystem -NewChild -SingleItem ``` ```powershell Resolve-PSFPath -Path ..\* ``` -------------------------------- ### Full Example with PSFComputer Array Source: https://psframework.org/docs/PSFramework/ParameterClasses/computer-parameter This example shows a function `Get-OSInfo` using `[PSFComputer[]]` for multiple computer inputs and `Invoke-Command` to retrieve OS information. ```powershell function Get-OSInfo { [CmdletBinding()] param ( [PSFComputer[]] $ComputerName, [pscredential] $Credential ) $param = @{} if ($ComputerName) { $param.ComputerName = $ComputerName } if ($Credential) { $param.Credential = $Credential } Invoke-Command @param -ScriptBlock { Get-CimInstance win32_OperatingSystem } } ``` -------------------------------- ### Install a logging provider Source: https://psframework.org/docs/Commands/PSFramework/Install-PSFLoggingProvider Installs a logging provider named 'eventlog'. ```powershell Install-PSFLoggingProvider -Name Eventlog ``` -------------------------------- ### New-PSMDDotNetProject Install Syntax Source: https://psframework.org/docs/Commands/PSModuleDevelopment/New-PSMDDotNetProject Defines the syntax for installing a new project template using New-PSMDDotNetProject. The -Install parameter takes the template name to install from the VS marketplace. ```powershell New-PSMDDotNetProject [-Help] [-Force] -Install [-Arguments ] [-WhatIf] [-Confirm] [] ``` -------------------------------- ### Simple Module Installation Source: https://psframework.org/docs/PSFrameworkNuGet/install-modules Installs a specified module. This command returns information about all deployed modules, including dependencies. ```powershell Install-PSFModule 'MyModule' ``` ```powershell Install-PSFModule -Name JEAnalyzer ``` -------------------------------- ### Install GELF Logging Provider Source: https://psframework.org/docs/PSFramework/Logging/providers/gelf Installs the GELF logging provider and its prerequisites. Ensure the PSGELF PowerShell Module is installed. ```powershell Install-PSFLoggingProvider -Name GELF ``` -------------------------------- ### Get-PSFPipeline Usage Example Source: https://psframework.org/docs/Commands/PSFramework/Get-PSFPipeline A simple example showing how to call the pipeline meta-information generator. ```powershell Get-Pipeline ``` -------------------------------- ### Install Project Template Source: https://psframework.org/docs/Commands/PSModuleDevelopment/New-PSMDDotNetProject Installs a specified .NET project template from the Visual Studio Marketplace. ```APIDOC ## POST /api/projects/templates/install ### Description Installs a specified .NET project template from the Visual Studio Marketplace. This function is a wrapper around 'dotnet new --install'. ### Method POST ### Endpoint /api/projects/templates/install ### Parameters #### Query Parameters - **Install** (String) - Required - The name or NuGet package ID of the template to install. - **Help** (SwitchParameter) - Optional - Displays help information for the command. - **Force** (SwitchParameter) - Optional - Overwrites existing files. - **Arguments** (String[]) - Optional - Additional arguments to pass to the dotnet new command. - **WhatIf** (SwitchParameter) - Optional - Shows what would happen if the command were run without actually performing any actions. - **Confirm** (SwitchParameter) - Optional - Prompts for confirmation before executing the command. ### Request Example ```json { "Install": "Microsoft.DotNet.Web.Spa.ProjectTemplates::2.0.0" } ``` ### Response #### Success Response (200) - **Message** (String) - Confirmation message indicating the template was installed successfully. #### Response Example ```json { "Message": "Template 'Microsoft.DotNet.Web.Spa.ProjectTemplates::2.0.0' installed successfully." } ``` ``` -------------------------------- ### Install-PSFLoggingProvider Source: https://psframework.org/docs/Commands/PSFramework/Install-PSFLoggingProvider Installs a logging provider registered with the PSFramework. This command can handle providers that require special installation steps, such as installing binaries that need elevation, by executing an installation script provided by the provider. ```APIDOC ## Install-PSFLoggingProvider ### Description Installs a logging provider registered with the PSFramework. This command can handle providers that require special installation steps, such as installing binaries that need elevation, by executing an installation script provided by the provider. ### Syntax ```powershell Install-PSFLoggingProvider [[-Name] ] [-EnableException] [] ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters #### -Name The name of the provider to install. * **Type**: String * **Required**: False * **Aliases**: Provider, ProviderName #### -EnableException This parameter disables user-friendly warnings and enables the throwing of exceptions. This is less user-friendly, but allows catching exceptions in calling scripts. * **Type**: SwitchParameter * **Required**: False * **Default value**: False ### Request Example ```powershell Install-PSFLoggingProvider -Name Eventlog ``` This command installs a logging provider named 'eventlog'. ### Response #### Success Response (200) This command does not return a specific JSON response. Its success is indicated by the absence of errors and the successful installation of the logging provider. #### Response Example None ``` -------------------------------- ### Get-PSFLoggingProviderInstance Examples Source: https://psframework.org/docs/Commands/PSFramework/Get-PSFLoggingProviderInstance Usage examples for retrieving all enabled instances or filtering by provider name with the force flag. ```powershell Get-PSFLoggingProviderInstance ``` ```powershell Get-PSFLoggingProviderInstance -ProviderName logfile -Force ``` -------------------------------- ### Select-PSUFunctionCode Usage Examples Source: https://psframework.org/docs/Commands/PSUtil/Select-PSUFunctionCode Examples showing how to invoke the function directly or via the pipeline. ```powershell Select-PSUFunctionCode -function 'Start-PSUTimer' ``` ```powershell Get-Command timer | Select-PSUFunctionCode ``` -------------------------------- ### Invoke-MDDaemon Execution Example Source: https://psframework.org/docs/Commands/MailDaemon/Invoke-MDDaemon Standard usage example for processing the email queue. ```PowerShell Invoke-MDDaemon ``` -------------------------------- ### Set-PSFDynamicContentObject Examples Source: https://psframework.org/docs/Commands/PSFramework/Set-PSFDynamicContentObject Practical examples for setting dynamic content objects and thread-safe collections. ```powershell Set-PSFDynamicContentObject -Name Test -Value $Value ``` ```powershell Set-PSFDynamicContentObject -Name MyModule.Value -Queue ``` -------------------------------- ### Set-PSFTypeAlias Examples Source: https://psframework.org/docs/Commands/PSFramework/Set-PSFTypeAlias Usage examples for registering a single type alias or multiple aliases via a hashtable. ```powershell Set-PSFTypeAlias -AliasName 'file' -TypeName 'System.IO.File' ``` ```powershell Set-PSFTypeAlias -Mapping @{ file = 'System.IO.File' path = 'System.IO.Path' } ``` -------------------------------- ### Register-PSFMessageTransform Usage Examples Source: https://psframework.org/docs/Commands/PSFramework/Register-PSFMessageTransform Practical examples demonstrating how to register transformations for specific types and filtered patterns. ```powershell Register-PSFMessageTransform -TargetType 'mymodule.category.classname' -ScriptBlock $ScriptBlock ``` ```powershell Register-PSFMessageTransform -ExceptionType 'mymodule.category.exceptionname' -ScriptBlock $ScriptBlock ``` ```powershell Register-PSFMessageTransform -TargetTypeFilter 'mymodule.category.*' -ScriptBlock $ScriptBlock ``` -------------------------------- ### Manual Error Handling Example Source: https://psframework.org/docs/PSFramework/FlowControl/invoke-psfprotectedcommand This example demonstrates the manual implementation of error handling, message handling, and WhatIf/Confirm support, which can be verbose. ```powershell if ($PSCmdlet.ShouldProcess($Path, "Delete")) { try { Write-PSFMessage -Message "Deleting $Path" -Target $Path Remove-Item -Path $Path -Recurse -Force -Confirm:$false -ErrorAction Stop Write-PSFMessage -Message "Successfully deleted $Path" -Target $Path } catch { Write-PSFMessage -Level Warning -Message "Failed to delete $Path" -Target $Path -ErrorRecord $_ Write-Error $_ continue } } ``` -------------------------------- ### Example: Resolve-PSFItem with Path and LiteralPath Source: https://psframework.org/docs/Commands/PSFramework/Resolve-PSFItem Use this example to search all items found under the specified paths, providing both -Path and -LiteralPath parameters. ```powershell Resolve-PSFItem -Path $Path -LiteralPath $LiteralPath -Cmdlet $PSCmdlet ``` -------------------------------- ### Select-PSFObject - Example 5: Naming and styling Source: https://psframework.org/docs/Commands/PSFramework/Select-PSFObject Example showing how to set a type name and control property display using Select-PSFObject. ```APIDOC ## Example 5: Naming and styling ### Description Lists all items in the current path, selects the properties specified (whether they exist or not), then sets the name to "MyType" and hides the properties "Mode" and "Used" from the default display set. ### Code ```powershell Get-ChildItem | Select-PSFObject Name, Length, FullName, Used, LastWriteTime, Mode -TypeName MyType -ShowExcludeProperty Mode, Used ``` ``` -------------------------------- ### Simple Configuration Format Example Source: https://psframework.org/docs/PSFramework/Configuration/Schemata/schema-default Demonstrates the structure for a simple configuration entry, which uses full JSON serialization. Requires Version, FullName, and Data properties. ```json [ { "Version": 1, "FullName": "Demo.Simple", "Data": 42 } ] ``` -------------------------------- ### Get PowerShellGet Availability State Source: https://psframework.org/docs/Commands/PSFramework.NuGet/Get-PSFPowerShellGet Run this command to check the local PowerShellGet configuration and its prerequisites for module installation or publishing. ```powershell Get-PSFPowerShellGet ``` -------------------------------- ### Install SQL Logging Provider Source: https://psframework.org/docs/PSFramework/Logging/providers/sql Installs the SQL Logging Provider and its prerequisites. This command ensures the necessary dbatools module is available. ```powershell Install-PSFLoggingProvider -Name Sql ``` -------------------------------- ### Example Template File with Registered ScriptBlock Source: https://psframework.org/docs/PSModuleDevelopment/Templates/Templating/working-with-scriptblocks A sample PowerShell module manifest (psd1) utilizing a registered ScriptBlock for the GUID field. ```powershell @{ # Script module or binary module file associated with this manifest ModuleToProcess = 'þnameþ.psm1' # Version number of this module. ModuleVersion = '1.0.0.0' # ID used to uniquely identify this module GUID = 'þ!guid!þ' # Author of this module Author = 'þauthorþ' ``` -------------------------------- ### Example: Load a Build Project by Path and Name Source: https://psframework.org/docs/Commands/PSModuleDevelopment/Get-PSMDBuildProject This example demonstrates loading a specific build project by providing its directory path and name. The cmdlet will look for a file named '.build.json' within the specified path. ```powershell Get-PSMDBuildProject -Path 'C:\code\project' -Name project ``` -------------------------------- ### Get Default Template Parameters - PowerShell Source: https://psframework.org/docs/PSModuleDevelopment/Templates/Managing/default-template-parameters Retrieves all configuration settings that start with 'psmoduledevelopment.template.parameterdefault.*' to view existing default parameter values. ```powershell Get-PSFConfig psmoduledevelopment.template.parameterdefault.* ``` -------------------------------- ### List Installed Templates Source: https://psframework.org/docs/Commands/PSModuleDevelopment/New-PSMDDotNetProject Use this command to list all currently installed project templates. This is useful for discovering available templates before creating a new project. ```powershell dotnetnew -l ``` -------------------------------- ### Get-PSMDHelp Parameter: -Detailed Source: https://psframework.org/docs/Commands/PSModuleDevelopment/Get-PSMDHelp Adds parameter descriptions and examples to the basic help display. This parameter is effective only when help files for the command are installed. ```powershell Type: SwitchParameter Parameter Sets: DetailedView Aliases: Required: True Position: Named Default value: False Accept pipeline input: False Accept wildcard characters: False ``` -------------------------------- ### List all repositories Source: https://psframework.org/docs/Commands/PSFramework.NuGet/Get-PSFRepository Example usage to list all available repositories. ```powershell Get-PSFRepository ``` -------------------------------- ### Combined Configuration Settings Example Source: https://psframework.org/docs/PSFramework/Configuration/Schemata/schema-default Shows how to combine both simple and complex configuration settings within a single JSON file. This allows for flexible configuration management. ```json [ { "Style": "default", "Value": "42", "Version": 1, "FullName": "Demo.Complex", "Type": 3 }, { "Version": 1, "FullName": "Demo.Simple", "Data": 42 } ] ``` -------------------------------- ### Get All Registered Runspace Workflows Source: https://psframework.org/docs/Commands/PSFramework/Get-PSFRunspaceWorkflow Use this command to retrieve a list of all currently registered runspace workflows. No specific setup is required beyond having the PSFramework module loaded. ```powershell Get-PSFRunspaceWorkflow ``` -------------------------------- ### Download PowerShellGet V2 & V3 Source: https://psframework.org/docs/Commands/PSFramework.NuGet/Save-PSFPowerShellGet Downloads and deploys the latest version of Get V2 & V3 to the default path. This cmdlet is used to obtain the necessary packages for offline installations. ```powershell Save-PSFPowerShellGet ``` -------------------------------- ### Filter Loaded Assemblies by Name Source: https://psframework.org/docs/Commands/PSModuleDevelopment/Get-PSMDAssembly This command lists imported libraries whose names match a specified pattern. Wildcards can be used for flexible filtering. For example, to list all libraries starting with 'Microsoft.', use '-Filter "Microsoft.*"'. ```powershell Get-PSMDAsssembly -Filter "Microsoft.*" ``` -------------------------------- ### Configure and Execute PSFramework Logging Source: https://psframework.org/docs/quickstart/PSFramework/logging Example showing the initialization of a logging provider, message logging, and ensuring completion of asynchronous log writes. ```powershell # Setting up the logging $paramSetPSFLoggingProvider = @{ Name = 'logfile' InstanceName = '' FilePath = 'C:\Logs\TaskName-%Date%.csv' Enabled = $true Wait = $true } Set-PSFLoggingProvider @paramSetPSFLoggingProvider # Start Logging Write-PSFMessage "Starting Script" # Add script code here, using Write-PSFMessage wherever you want to log # ... Write-PSFMessage "Script Completed" # Wait for logging to complete Wait-PSFMessage ``` -------------------------------- ### Register-PSFConfig Examples Source: https://psframework.org/docs/Commands/PSFramework/Register-PSFConfig Common usage patterns for registering configuration items. ```powershell Get-PSFConfig psframework.message.* | Register-PSFConfig ``` ```powershell Register-PSFConfig -FullName "psframework.developer.mode.enable" -Scope SystemDefault ``` ```powershell Register-PSFConfig -Module MyModule -Scope SystemMandatory ``` -------------------------------- ### Install Module to a Specific Scope Source: https://psframework.org/docs/PSFrameworkNuGet/install-modules Installs a module to a specific scope. `AllUsersWinPS` installs the module in a path accessible by all PowerShell versions on the system. ```powershell Install-PSFModule 'MyModule' -Scope AllUsersWinPS ``` -------------------------------- ### Register Filesystem Logging Provider Example Source: https://psframework.org/docs/Commands/PSFramework/Register-PSFLoggingProvider Example of registering the 'filesystem' provider with all available event scriptblocks. Ensure variables and functions are uniquely named to avoid conflicts, especially in Version 1 providers. ```powershell Register-PSFLoggingProvider -Name "filesystem" -Enabled $true -RegistrationEvent $registrationEvent -BeginEvent $begin_event -StartEvent $start_event -MessageEvent $message_Event -ErrorEvent $error_Event -EndEvent $end_event -FinalEvent $final_event -ConfigurationParameters $configurationParameters -ConfigurationScript $configurationScript -IsInstalledScript $isInstalledScript -InstallationScript $installationScript -InstallationParameters $installationParameters -ConfigurationSettings $configuration_Settings ``` -------------------------------- ### Parameter metadata examples Source: https://psframework.org/docs/Commands/PSFramework/ConvertTo-PSFClixml Displays the configuration details for specific parameters. ```powershell Type: Int32 Parameter Sets: (All) Aliases: Required: False Position: 1 Default value: 0 Accept pipeline input: False Accept wildcard characters: False ``` ```powershell Type: Object Parameter Sets: (All) Aliases: Required: False Position: 2 Default value: None Accept pipeline input: True (ByValue) Accept wildcard characters: False ``` ```powershell Type: ClixmlDataStyle Parameter Sets: (All) Aliases: Accepted values: String, Byte Required: False Position: 3 Default value: String Accept pipeline input: False Accept wildcard characters: False ``` ```powershell Type: SwitchParameter Parameter Sets: (All) Aliases: Required: False Position: Named Default value: False Accept pipeline input: False Accept wildcard characters: False ``` -------------------------------- ### Find-PSMDType Examples Source: https://psframework.org/docs/Commands/PSModuleDevelopment/Find-PSMDType Examples demonstrating how to search for types by name or inheritance. ```powershell Find-PSMDType -Name "*String*" ``` ```powershell Find-PSMDType -InheritsFrom System.Management.Automation.Runspaces.Runspace ``` -------------------------------- ### Download a resource module Source: https://psframework.org/docs/Commands/PSFramework.NuGet/Save-PSFResourceModule Example of downloading a specific module by name to the current directory. ```powershell Save-PSFResourceModule -Name Psmd.Templates.MiniModule -Path . ``` -------------------------------- ### Example: Publish Resource Module to PSGallery Source: https://psframework.org/docs/Commands/PSFramework.NuGet/Publish-PSFResourceModule This example demonstrates publishing all files under the MyFunction folder to the PSGallery. The resource module is named 'Psmd.Template.MyFunction' and versioned as '1.1.0'. An API key is required for authentication. ```powershell Publish-PSFResourceModule -Name Psmd.Template.MyFunction -Version 1.1.0 -Path .\MyFunction\* -Repository PSGallery -ApiKey $key ``` -------------------------------- ### List Runspace GUIDs Source: https://psframework.org/docs/Commands/PSFramework/Get-PSFMessage Command to list available runspace GUIDs for filtering. ```powershell Get-Runspace | ft Id, Name, InstanceId -Autosize ``` -------------------------------- ### Install-PSFPowerShellGet Syntax Source: https://psframework.org/docs/Commands/PSFramework.NuGet/Install-PSFPowerShellGet The basic syntax for the Install-PSFPowerShellGet cmdlet. ```powershell Install-PSFPowerShellGet [[-Type] ] [[-ComputerName] ] [[-Credential] ] [[-SourcePath] ] [-Offline] [-NotInternal] [-UserMode] [] ``` -------------------------------- ### Install PSGELF Module Source: https://psframework.org/docs/PSFramework/Logging/loggingto/graylog Install the required PSGELF module for the Graylog logging provider. ```powershell Install-PSFLoggingProvider -Name gelf ``` -------------------------------- ### Display All Parameter Sets with Show-PSMDSyntax Source: https://psframework.org/docs/Commands/PSModuleDevelopment/Show-PSMDSyntax Use this example to display all parameter sets and their individual parameters for a given command. ```powershell Show-PSMDSyntax -CommandText "New-Item" -Mode "ShowParameters" ``` -------------------------------- ### Read all build steps Source: https://psframework.org/docs/Commands/PSModuleDevelopment/Get-PSMDBuildStep Retrieves all steps associated with the default build project. ```powershell Get-PSMDBuildStep ``` -------------------------------- ### Install-MDDaemon Syntax Source: https://psframework.org/docs/Commands/MailDaemon/Install-MDDaemon Displays the full parameter syntax for the Install-MDDaemon cmdlet. ```powershell Install-MDDaemon [[-ComputerName] ] [[-Credential] ] [-NoTask] [[-TaskUser] ] [[-PickupPath] ] [[-SentPath] ] [[-DaemonUser] ] [[-WriteUser] ] [[-MailSentRetention] ] [[-SmtpServer] ] [[-SenderDefault] ] [[-SenderCredential] ] [[-RecipientDefault] ] [] ``` -------------------------------- ### Remove-PSFTempItem Examples Source: https://psframework.org/docs/Commands/PSFramework/Remove-PSFTempItem Usage examples for removing temporary items using different parameters. ```powershell Remove-PSFTempItem -ClearExpired ``` ```powershell Get-PSFTempItem | Remove-PSFTempItem ``` ```powershell Remove-PSFTempItem -Name configFile -Module FWManager ``` ```powershell Remove-PSFTempItem -Name *beer* -Module Fridge ``` -------------------------------- ### Create a project template using a reference file Source: https://psframework.org/docs/PSModuleDevelopment/Templates/Templating/project-reference-file Invoke New-PSMDTemplate pointing to the folder containing the PSMDTemplate.ps1 file to build the template using the defined metadata. ```powershell New-PSMDTemplate -ReferencePath "C:\path\to\template\folder" ``` -------------------------------- ### Configure PSFramework Logging Provider Source: https://psframework.org/docs/PSFramework/Logging/basics/troubleshooting Examples of setting up a logging provider using a hash table of parameters. ```PowerShell $paramSetPSFLoggingProvider = @{ Name = 'logfile' InstanceName = 'Contoso-VMDeplyoment' FilePath = 'C:\Logs\Contoso-VMDeployment-%Date%.csv' } Set-PSFLoggingProvider @paramSetPSFLoggingProvider ``` ```PowerShell $paramSetPSFLoggingProvider = @{ Name = 'logfile' InstanceName = 'Contoso-VMDeplyoment' FilePath = 'C:\Lgs\Contoso-VMDeployment-%Date%.csv' Enabled = $true Wait = $true } Set-PSFLoggingProvider @paramSetPSFLoggingProvider ``` -------------------------------- ### Wait-PSFMessage Usage Examples Source: https://psframework.org/docs/Commands/PSFramework/Wait-PSFMessage Basic usage to flush logs and an example with timeout and termination parameters. ```powershell Wait-PSFMessage ``` ```powershell Wait-PSFMessage -Timeout 1m -Terminate ``` -------------------------------- ### Complex Configuration Format Example Source: https://psframework.org/docs/PSFramework/Configuration/Schemata/schema-default Illustrates the complex configuration entry format, which uses PSFramework syntax for values. Requires Style, Value, Version, FullName, and Type properties. ```json [ { "Style": "default", "Value": "42", "Version": 1, "FullName": "Demo.Complex", "Type": 3 } ] ``` -------------------------------- ### Write-PSFMessage Examples Source: https://psframework.org/docs/Commands/PSFramework/Write-PSFMessage Various usage examples for logging messages, warnings, and handling errors with PSFramework. ```powershell Write-PSFMessage -Message "Connecting to $computer" ``` ```powershell Write-PSFMessage -Level Warning -Message "Failed to retrieve additional network adapter information from $computer" ``` ```powershell Write-PSFMessage -Level Verbose -Message "Connecting to $computer" -Target $computer ``` ```powershell Write-PSFMessage -Level Host -Message "This command has been deprecated, use 'Get-NewExample' instead" -Once 'Get-Example' ``` ```powershell Write-PSFMessage -Level Warning -Message "Failed to retrieve additional network adapter information from $computer" -Target $computer -ErrorRecord $_ ``` ```powershell Write-PSFMessage -Level Warning -Message "Failed to change network adapter settings, this command requires elevation. Restart your console as admin and try again" -Target $computer -ErrorRecord $_ -OverrideExceptionMessage ``` ```powershell Write-PSFMessage -Message "Connecting to $computer" -Target $computer -Tag 'connect','CIM' ``` ```powershell Write-PSFMessage -Message "Connecting to $computer" -Line 21 -File "Connect-Computer.ps1" ``` -------------------------------- ### Install-PSFModule Syntax Definitions Source: https://psframework.org/docs/Commands/PSFramework.NuGet/Install-PSFModule Syntax definitions for installing modules by name or by object. ```powershell Install-PSFModule [-Name] [-Version ] [-Prerelease] [-Scope ] [-ComputerName ] [-SkipDependency] [-AuthenticodeCheck] [-Force] [-Credential ] [-RemotingCredential ] [-ThrottleLimit ] [-Repository ] [-TrustRepository] [-Type ] [-WhatIf] [-Confirm] [] ``` ```powershell Install-PSFModule [-Scope ] [-ComputerName ] [-SkipDependency] [-AuthenticodeCheck] [-Force] [-Credential ] [-RemotingCredential ] [-ThrottleLimit ] [-Repository ] [-TrustRepository] [-Type ] -InputObject [-WhatIf] [-Confirm] [] ``` -------------------------------- ### Select-PSFObject - Example 1: Renaming a property Source: https://psframework.org/docs/Commands/PSFramework/Select-PSFObject Example demonstrating how to rename a property using Select-PSFObject. ```APIDOC ## Example 1: Renaming a property ### Description Selects the properties Name and Length, renaming Length to Size in the process. ### Code ```powershell Get-ChildItem | Select-PSFObject Name, "Length as Size" ``` ``` -------------------------------- ### Install-PSFPowerShellGet Source: https://psframework.org/docs/category/psframeworknuget Installs PowerShellGet. ```APIDOC ## Install-PSFPowerShellGet ### Description Installs PowerShellGet. ### Method POST (assumed, as it's an install operation) ### Endpoint /websites/psframework/powershellget/install ### Response #### Success Response (200) - **Message** (string) - Confirmation message. ``` -------------------------------- ### Retrieve Started Instances Source: https://psframework.org/docs/PSFramework/Logging/loggingto/eventlog Queries the event log for EventID 999 to identify started instances. ```powershell Get-WinEvent -FilterXml @' '@ | Select-PSFObject @( 'Properties[2].Value as InstanceName' 'Properties[3].Value as LoggingID' 'Properties[1].Value as ProcessID' 'TimeCreated.ToUniversalTime() as StartTime' ) ``` -------------------------------- ### SQL Provider Configuration Root Example Source: https://psframework.org/docs/PSFramework/Logging/advanced/writing-logging-providers Illustrates the ConfigurationRoot namespace for the SQL logging provider. This defines the hierarchical path for its configuration settings. ```powershell PSFramework.Logging.Sql.Credential PSFramework.Logging.Sql.Database PSFramework.Logging.Sql.SqlServer PSFramework.Logging.Sql.Table ``` -------------------------------- ### Start All Runspace Workflows Source: https://psframework.org/docs/Commands/PSFramework/Start-PSFRunspaceWorkflow Starts all available Runspace Workflows by piping the output of Get-PSFRunspaceWorkflow to Start-PSFRunspaceWorkflow. ```powershell Get-PSFRunspaceWorkflow | Start-PSFRunspaceWorkflow ``` -------------------------------- ### Start a Specific Runspace Workflow Source: https://psframework.org/docs/Commands/PSFramework/Start-PSFRunspaceWorkflow Starts the Runspace Workflow named "MailboxAnalysis". ```powershell Start-PSFRunspaceWorkflow -Name MailboxAnalysis ``` -------------------------------- ### Initialize a template Source: https://psframework.org/docs/quickstart/PSModuleDevelopment/templates-use Creates a new file based on the specified template name. ```PowerShell Invoke-PSMDTemplate -TemplateName function ``` -------------------------------- ### Install a module using PSFramework.NuGet Source: https://psframework.org/docs/PSFrameworkNuGet/overview Use this command to install a module regardless of the underlying PowerShellGet version. ```powershell Install-PSFModule 'MyModule' ``` -------------------------------- ### Create Template from File Example Source: https://psframework.org/docs/Commands/PSModuleDevelopment/New-PSMDTemplate This example demonstrates creating a template named 'functiontest' based on the content of the file './þnameþ.Test.ps1'. The 'þnameþ' part indicates a parameter that will be replaced during template instantiation. ```powershell New-PSMDTemplate -FilePath .\þnameþ.Test.ps1 -TemplateName functiontest ``` -------------------------------- ### Install-PSFModule Parameters Source: https://psframework.org/docs/Commands/PSFramework.NuGet/Save-PSFResourceModule Details regarding the parameters used to control module installation from repositories. ```APIDOC ## Install-PSFModule Parameters ### Parameters #### -Type - **Type** (String) - Optional - What type of repository to download from. V2 uses classic Save-Module. V3 uses Save-PSResource. Default: All. #### -InputObject - **InputObject** (Object[]) - Required - The resource module to install. Takes the output of Get-Module, Find-Module, Find-PSResource and Find-PSFModule. #### -WhatIf - **WhatIf** (SwitchParameter) - Optional - If enabled, no actions are performed but informational messages are displayed. #### -Confirm - **Confirm** (SwitchParameter) - Optional - If enabled, prompts for confirmation before executing operations that change state. ``` -------------------------------- ### GELF Provider Configuration and Installation Source: https://psframework.org/docs/PSFramework/Logging/providers/gelf Details on installing the GELF provider and configuring its properties for Graylog integration. ```APIDOC ## GELF Logging Provider ### Description Allows logging to Graylog SIEM servers. ### Installation The GELF provider requires the PSGELF PowerShell Module installed on the system. Use the following command to install: `Install-PSFLoggingProvider -Name GELF` ### Properties Properties control the behavior of the provider and can be set via `Set-PSFLoggingProvider` or the Configuration system. - **GelfServer** (string) - The GELF server to send logs to - **Port** (integer) - The port number the GELF server listens on - **Encrypt** (boolean) - Default: True - Whether to use TLS encryption when communicating with the GELF server ``` -------------------------------- ### Full Example: Get-Alcohol with Conditional Tab Completion Source: https://psframework.org/docs/PSFramework/TabExpansion/Basics/previous-parameters A complete example demonstrating how to set up tab completion for multiple parameters of a function. It includes registering scriptblocks for parameter types and units, with unit suggestions dynamically changing based on the selected type. ```powershell function Get-Alcohol { [CmdletBinding()] Param ( [string] $Type, [string] $Unit = "Pitcher" ) Write-Host "Drinking a $Unit of $Type" } # Create scriptblock that collects information and name it Register-PSFTeppScriptblock -Name 'alcohol.type' -ScriptBlock { 'Beer','Mead','Whiskey','Wine','Vodka','Rum (3y)', 'Rum (5y)', 'Rum (7y)' } # Assign scriptblock to function Register-PSFTeppArgumentCompleter -Command Get-Alcohol -Parameter Type -Name 'alcohol.type' # Create scriptblock that checks what was bound to '-Type' so far and name it Register-PSFTeppScriptblock -Name 'alcohol.unit' -ScriptBlock { switch ($fakeBoundParameter.Type) { 'Mead' { 'Mug', 'Horn', 'Barrel' } 'Wine' { 'Glas', 'Bottle' } 'Beer' { 'Halbes Maß', 'Maß' } default { 'Glas', 'Pitcher' } } } # Assign scriptblock to function Register-PSFTeppArgumentCompleter -Command Get-Alcohol -Parameter Unit -Name 'alcohol.unit' ``` -------------------------------- ### Install SQL Logging Provider Source: https://psframework.org/docs/PSFramework/Logging/loggingto/sql Installs the required dbatools module dependency for the SQL logging provider. ```powershell Install-PSFLoggingProvider -Name sql ``` -------------------------------- ### Remove-PSMDTemplate Usage Examples Source: https://psframework.org/docs/Commands/PSModuleDevelopment/Remove-PSMDTemplate Practical examples demonstrating how to remove deprecated templates or specific versions of a template. ```powershell Remove-PSMDTemplate -TemplateName '*' -Deprecated ``` ```powershell Get-PSMDTemplate -TemplateName 'module' -RequiredVersion '1.2.2.1' | Remove-PSMDTemplate ```