{"id":15203006,"url":"https://github.com/zalanlevai/posh-bootstrap","last_synced_at":"2026-02-06T16:33:56.342Z","repository":{"id":77592073,"uuid":"207705839","full_name":"zalanlevai/Posh-Bootstrap","owner":"zalanlevai","description":"A PowerShell module that allows for writing clean bootstrapper scripts.","archived":false,"fork":false,"pushed_at":"2019-09-13T20:03:57.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-05T09:46:55.482Z","etag":null,"topics":["powershell","powershell-core","powershell-gallery","powershell-module"],"latest_commit_sha":null,"homepage":null,"language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zalanlevai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-11T02:31:24.000Z","updated_at":"2019-09-13T20:03:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"6ee9528d-1989-44b5-bcb9-a98690aa9f60","html_url":"https://github.com/zalanlevai/Posh-Bootstrap","commit_stats":{"total_commits":13,"total_committers":1,"mean_commits":13.0,"dds":0.0,"last_synced_commit":"ef622975594040295ffc475a51354beb1c1bdcd1"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/zalanlevai/Posh-Bootstrap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zalanlevai%2FPosh-Bootstrap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zalanlevai%2FPosh-Bootstrap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zalanlevai%2FPosh-Bootstrap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zalanlevai%2FPosh-Bootstrap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zalanlevai","download_url":"https://codeload.github.com/zalanlevai/Posh-Bootstrap/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zalanlevai%2FPosh-Bootstrap/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265724746,"owners_count":23817866,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["powershell","powershell-core","powershell-gallery","powershell-module"],"created_at":"2024-09-28T04:21:46.142Z","updated_at":"2026-02-06T16:33:56.308Z","avatar_url":"https://github.com/zalanlevai.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Posh-Bootstrap\n\n[![latest release][GitHubReleaseBadge]][GitHubReleaseLink]\n[![powershellgallery version][PowerShellGalleryBadge]][PowerShellGalleryLink]\n[![license][LicenseBadge]][LicenseLink]\n\nA *PowerShell* module that allows for writing clean bootstrapper scripts.\n\n## Installation\n\n### PowerShell Gallery\n\nRun the following command in a *PowerShell* session to install the module:\n\n```PowerShell\nInstall-Module -Name Posh-Bootstrap\n```\n\nThis module runs on *Windows PowerShell* 5.1 or greater and *PowerShell Core*.\n\nIf you have an earlier version of the `Posh-Bootstrap` module installed from *PowerShell Gallery* and would like to update to the latest version, run the following command in a *PowerShell* session:\n\n```PowerShell\nUpdate-Module -Name Posh-Bootstrap\n```\n\n## Usage\n\nTo use the module in your scripts, first import it:\n\n```PowerShell\nImport-Module -Name Posh-Bootstrap\n```\n\nThen create your script structure:\n\n```PowerShell\n@(\n    $(New-Stage -Name \"Build\" -Action { }),\n    $(New-Stage -Name \"Copy\" -Action { }),\n    $(New-Stage -Name \"Run\", -Action { })\n)\n```\n\nThese stages will be invoked one after another. You can place your code in the `Action` *ScriptBlock*s as follows:\n\n```PowerShell\nNew-Stage -Name \"Build\" -Action {\n    Update-Progress -Progress 0 -CurrentOperation \"Initializing Build Engine\"\n\n    # This cmdlet calls the `OutputDelegate` ScriptBlock every time the process outputs a line to stdout.\n    Watch-Process -ProcessFileName \"dotnet\" -ProcessArgs \"publish $BuildPath\" -RedirectOutput -OutputDelegate { param($Output)\n        if ($Output.Contains(\"Microsoft (R) Build Engine\") -or $Output.Contains(\"Copyright (C) Microsoft Corporation\")) {\n            Update-Progress -Progress 5 -CurrentOperation \"Initialized Build Engine\"\n        } elseif ($Output.Contains(\" -\u003e \")) {\n            Update-Progress -Progress 95 -CurrentOperation \"Finished building solution\"\n        } else {\n            Update-Progress -Progress 15 -CurrentOperation \"Building solution\"\n        }\n    }\n}\n```\n\n```PowerShell\nNew-Stage -Name \"Run\" -Action {\n    Complete-Stage -CurrentOperation \"Running from remote at $Address\"\n    Invoke-Command -Session $script:Session {\n        Set-Location $using:ExecutionPath\n        dotnet $Executable\n    }\n}\n```\n\nNote the use of the cmdlets `Update-Progress` and `Complete-Stage`. These can be used inside script stages to update their running status.\n- `Update-Progress` updates the progress and the current operation of the currently running stage, and reflects these changes in the script's progress bar *(if any)*.\n- `Complete-Stage` marks the currently running stage as completed and updates its current operation in the process. This is useful when the script should exit earlier then the end of the final stage *(e.g. when the script prepares an interactive environment and the final stage drops into this environment - the script should be deemed complete even though the final stage is still waiting on the interactive environment to be closed)*.\n\nFinally, invoke the script as follows:\n\n```PowerShell\nInvoke-Script @(\n    $(New-Stage -Name \"Build\" -Action {\n        [...]\n    }),\n    $(New-Stage -Name \"Copy\" -Action {\n        [...]\n    }),\n    $(New-Stage -Name \"Run\", -Action {\n        [...]\n    })\n)\n```\n\nIn addition, you can set the progress bar display style to use when running the script:\n\n```PowerShell\nInvoke-Script @() -ProgressMode { Full | Compact | None }\n```\n\nBelow is an example for a complete script:\n\n```PowerShell\n#Requires -Modules Posh-Bootstrap\nImport-Module Posh-Bootstrap\n\ntry {\n    Invoke-Script @(\n        # Build the project using `dotnet publish`.\n        $(New-Stage \"Build\" {\n            Update-Progress 0 \"Initializing Build Engine\"\n\n            # This cmdlet calls the `OutputDelegate` ScriptBlock every time the process outputs a line to stdout.\n            Watch-Process -ProcessFileName \"dotnet\" -ProcessArgs \"publish $BuildPath\" -RedirectOutput -OutputDelegate { param($Output)\n                if ($Output.Contains(\"Microsoft (R) Build Engine\") -or $Output.Contains(\"Copyright (C) Microsoft Corporation\")) {\n                    Update-Progress 5 \"Initialized Build Engine\"\n                } elseif ($Output.Contains(\" -\u003e \")) {\n                    Update-Progress 95 \"Finished building solution\"\n                } else {\n                    Update-Progress 15 \"Building solution\"\n                }\n            }\n        }),\n        # Copy the build files to the remote machine.\n        $(New-Stage \"Copy\" {\n            Update-Progress 0 \"Establishing connection with the remote\"\n            $script:Session = New-PSSession -HostName $Address -UserName $User\n\n            Update-Progress 0 \"Copying files to remote\"\n            $Files = Get-ChildItem $Source -File -Recurse\n            for ($i = 0; $i -lt $Files.Count; $i++) {\n                $File = $Files[$i]\n\n                # This cmdlet returns the path relative to `Root`.\n                $RelativePath = Get-RelativePath -Path $File -Root $Source\n                $DestinationFile = Split-Path (Join-Path -Path $Destination -ChildPath $RelativePath.Substring(2))\n\n                Update-Progress $($i / $Files.Count * 100) \"Copying $RelativePath\"\n                Copy-Item $File -Destination $DestinationFile -ToSession $script:Session -Force\n\n                Write-Host \"Copied $RelativePath\"\n            }\n        }),\n        # Run the executable on the remote machine, piping its output back to the host.\n        $(New-Stage \"Run\" {\n            Complete-Stage \"Running from remote at $Address\"\n            Write-Host \"Running from remote at $Address\" -ForegroundColor Yellow\n            Invoke-Command -Session $script:Session {\n                Set-Location $using:ExecutionPath\n                dotnet $Executable\n            }\n        })\n    )\n} finally {\n    # Terminate the connection with the remote machine even when the script was interrupted.\n    Write-Host \"Terminating connection with remote.\" -ForegroundColor Yellow\n    Remove-PSSession -Session $script:Session\n}\n```\n\n### Cmdlet help and examples\n\nTo view the help content for a cmdlet, use the `Get-Help` cmdlet:\n\n```PowerShell\n# View the basic help content for Invoke-Script\nGet-Help -Name Invoke-Script\n\n# View the examples for Invoke-Script\nGet-Help -Name Invoke-Script -Examples\n\n# View the full help content for Invoke-Script\nGet-Help -Name Invoke-Script -Full\n```\n\n## Reporting Issues and Feedback\n\n### Issues\n\nIf you find any bugs when using `Posh-Bootstrap`, please file an issue on our [GitHub issues][GitHubIssuesLink] page.\n\n### Feedback\n\nIf there is a feature you would like to see in `Posh-Bootstrap`, please file an issue on our [GitHub issues][GitHubIssuesLink] page to provide feedback.\n\n## Contribute Code\n\nAny code contribution is welcome in the form of pull requests through GitHub.\n\n[GitHubReleaseBadge]: https://img.shields.io/github/v/release/zalanlevai/Posh-Bootstrap?style=flat-square\n[GitHubReleaseLink]: https://github.com/zalanlevai/Posh-Bootstrap/releases\n[PowerShellGalleryBadge]: https://img.shields.io/powershellgallery/v/Posh-Bootstrap?style=flat-square\n[PowerShellGalleryLink]: https://www.powershellgallery.com/packages/Posh-Bootstrap\n[LicenseBadge]: https://img.shields.io/github/license/zalanlevai/Posh-Bootstrap?style=flat-square\n[LicenseLink]: https://github.com/zalanlevai/Posh-Bootstrap/blob/master/LICENSE\n\n[GitHubIssuesLink]: https://github.com/zalanlevai/Posh-Bootstrap/issues","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzalanlevai%2Fposh-bootstrap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzalanlevai%2Fposh-bootstrap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzalanlevai%2Fposh-bootstrap/lists"}