{"id":18445700,"url":"https://github.com/voronenko/ps_oneliners","last_synced_at":"2026-05-17T19:34:51.324Z","repository":{"id":145345725,"uuid":"169253319","full_name":"Voronenko/ps_oneliners","owner":"Voronenko","description":"POC on creating one liner bootstrap powershell scripts with parameters","archived":false,"fork":false,"pushed_at":"2019-02-15T10:34:11.000Z","size":10,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-27T20:32:26.241Z","etag":null,"topics":["bootstrap","invoke-expression","oneliner","powershell"],"latest_commit_sha":null,"homepage":"","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Voronenko.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-02-05T14:23:19.000Z","updated_at":"2020-11-25T17:28:30.000Z","dependencies_parsed_at":"2023-07-03T09:17:15.008Z","dependency_job_id":null,"html_url":"https://github.com/Voronenko/ps_oneliners","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Voronenko/ps_oneliners","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Voronenko%2Fps_oneliners","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Voronenko%2Fps_oneliners/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Voronenko%2Fps_oneliners/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Voronenko%2Fps_oneliners/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Voronenko","download_url":"https://codeload.github.com/Voronenko/ps_oneliners/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Voronenko%2Fps_oneliners/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33151847,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-17T09:28:26.183Z","status":"ssl_error","status_checked_at":"2026-05-17T09:27:52.702Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["bootstrap","invoke-expression","oneliner","powershell"],"created_at":"2024-11-06T07:06:56.130Z","updated_at":"2026-05-17T19:34:51.305Z","avatar_url":"https://github.com/Voronenko.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n## Intro\n\nComing from unix world, I really enjoy so-called one-liners - easy to remember commands that do some useful bootstrapping.\n\nFew examples from my dotfiles: https://github.com/voronenko/dotfiles\n\nSaying, if I want to configure my favorite shell on some new VPS\n\n\n```sh\n\ncurl -sSL https://bit.ly/getmyshell \u003e getmyshell.sh \u0026\u0026 chmod +x getmyshell.sh \u0026\u0026 ./getmyshell.sh\n# might be shortened to, if I do not need to inspect shell file contents\ncurl -sSL https://bit.ly/getmyshell | bash -s\n\n```\n\nor configure my dotfiles configuration on a more permanent box\n\n```sh\n\ncurl -sSL https://bit.ly/slavkodotfiles \u003e bootstrap.sh \u0026\u0026 chmod +x bootstrap.sh\n./bootstrap.sh  \u003coptional: simple | full | docker\u003e\n```\n\nThat approach works pretty well on linux, thus when I have windows related work, I am trying to reuse similar approach.\nFew examples from my winfiles:  script below configures my PowerShell profile on a new windows server, and optionally installs my \"swiss knife\" set of tools for the windows system.\n\n```ps\n\nSet-ExecutionPolicy Bypass -Scope Process -Force; \niex ((New-Object System.Net.WebClient).DownloadString('https://bit.ly/winfiles'))\n```\n\nSometimes on Windows it is needed to additionally pre-configure bootstrap script. This article is actually note for myself how to do it quick next time :)\n\n## Challenge definition\n\nAssume we have some bootstrap logic implemented in PowerShell, uploaded to some public location and we need one-liner for easier install.\nFor purposes of the demo - that might be script, that installs some custom MSI artifact:\n\n```ps\n\n#Automated bootstrap file for some activity\nparam (\n    [Parameter(Mandatory = $true)]\n    [string]$requiredParam = \"THIS_PARAM_IS_REQUIRED\",\n    [string]$optionalParamWithDefault = \"https://github.com/Voronenko/ps_oneliners\",\n    [string]$optionalParamFromEnvironment = $env:computername\n)\n\nWrite-Host \"About to execute some bootstrap logic with params $requiredParam $optionalParamWithDefault on $optionalParamFromEnvironment\"\n\nFunction Download_MSI_Installer {\n    Write-Host  \"For example, we download smth from internet\"    \n    # Write-Host \"About to download $uri to $out\"\n    # Invoke-WebRequest -uri $uri -OutFile $out\n    # $msifile = Get-ChildItem -Path $out -File -Filter '*.ms*'\n    # Write-Host  MSI $msifile \"\n}\n\nFunction Install_Script {\n    # $msifile = Get-ChildItem -Path $out -File -Filter '*.ms*'\n    # $FileExists = Test-Path $msifile -IsValid\n    $msifile = \"c:\\some.msi\"\n\n    $DataStamp = get-date -Format yyyyMMddTHHmmss\n    $logFile = 'somelog-{0}.log' -f $DataStamp\n    $MSIArguments = @(\n        \"/i\"\n        ('\"{0}\"' -f $msifile)\n        \"/qn\"\n        \"/norestart\"\n        \"/L*v\"\n        $logFile\n        \" REQUIRED_PARAM=$requiredParam OPTIONAL_PARAM_WITH_DEFAULT=$optionalParamWithDefault OPTIONAL_PARAM_FROM_ENVIRONMENT=$optionalParamFromEnvironment\"\n    )\n    write-host \"About to install msifile with arguments \"$MSIArguments\n    # If ($FileExists -eq $True) {\n    #     Start-Process \"msiexec.exe\" -ArgumentList $MSIArguments -passthru | wait-process\n    #     Write-Host \"Finished msi \"$msifile\n    # }\n\n    # Else {Write-Host \"File $out doesn't exists - failed to download or corrupted. Please check.\"}\n}\n\nDownload_MSI_Installer\nInstall_Script\n```\n\nuser can tune following script parameters:\n\n```ps\n\n    [Parameter(Mandatory = $true)]\n    [string]$requiredParam = \"THIS_PARAM_IS_REQUIRED\",\n    [string]$optionalParamWithDefault = \"https://github.com/Voronenko/ps_oneliners\",\n    [string]$optionalParamFromEnvironment = $env:computername\n\n```\n\n## Option A - almost manual \"bootstrap.ps1 -param value\"\n\nPros: actually nothing is needed, just works\n\nCons: harder to tune parameters programmatically\n\n```ps\n\n# optional download\n(new-object net.webclient).DownloadFile('https://raw.githubusercontent.com/Voronenko/ps_oneliners/master/bootstrap.ps1','c:\\bootstrap.ps1')\n# install with optional overrides\nc:\\bootstrap.ps1 -requiredParam AAA -optionalParamWithDefault BBB -optionalParamFromEnvironment CCC\n\n```\n\nValidation - no overrides\n\n```\nPS C:\\\u003e c:\\bootstrap.ps1\n\ncmdlet bootstrap.ps1 at command pipeline position 1\nSupply values for the following parameters:\nrequiredParam: RRR\nAbout to execute some bootstrap logic with params RRR https://github.com/Voronenko/ps_oneliners on EC2AMAZ-9A8TRAV\nFor example, we download smth from internet\nAbout to install msifile with arguments  /i \"c:\\some.msi\" /qn /norestart /L*v c:\\some.msi-20190205T221234.log  REQUIRED_PARAM=RRR OPTIONAL_PARAM_WITH_DEFAULT=https://github.com/Voronenko/ps_oneliners OPTIONAL_PARAM_FROM_ENVIRONMENT=EC2AMAZ-9A8TRAV\n```\n\nValidation - with overrides\n\n```\nPS C:\\\u003e c:\\bootstrap.ps1 -requiredParam AAA -optionalParamWithDefault BBB -optionalParamFromEnvironment CCC\nAbout to execute some bootstrap logic with params AAA BBB on CCC\nFor example, we download smth from internet\nAbout to install msifile with arguments  /i \"c:\\some.msi\" /qn /norestart /L*v c:\\some.msi-20190205T221400.log  REQUIRED_PARAM=AAA OPTIONAL_PARAM_WITH_DEFAULT=BBB OPTIONAL_PARAM_FROM_ENVIRONMENT=CCC\n```\n\nAcceptance: PASSED\n\n\n\n\n## Option B - X-Liner from pre-downloaded script\n\n\nPut overrides only into $overrideParams , other will be picked up from default values in install script.\nPros - you can detect and programmatically amend override parameters.\n\n\n```ps\n\n$overrideParams = @{\n    requiredParam = 'AAAA'\n    optionalParamWithDefault='BBB'\n    optionalParamFromEnvironment='CCC'\n}\n\n$ScriptPath = 'c:\\bootstrap.ps1'\n$sb = [scriptblock]::create(\".{$(get-content $ScriptPath -Raw)} $(\u0026{$args} @overrideParams)\")\nInvoke-Command -ScriptBlock $sb\n\n# ...\n\n# Validation:\nAbout to execute some bootstrap logic with params RRR https://github.com/Voronenko/ps_oneliners on EC2AMAZ-9A8TRAV\n\n# Validation - no overrides\n\n$overrideParamsNone = @{\n    requiredParam = 'RRR'\n}\n$sb = [scriptblock]::create(\".{$(get-content $ScriptPath -Raw)} $(\u0026{$args} @overrideParamsNone)\")\nInvoke-Command -ScriptBlock $sb\n# ...\nAbout to execute some bootstrap logic with params AAAA BBB on CCC\n\n\n```\n\nAcceptance: PASSED\n\n\n## Option C - X-Liner executing script from remote location\n\nPut overrides only into $overrideParams , other will be picked up from default values in install script, downloaded from the remote location\n\nPros - you can detect and programmatically amend override parameters, bootstrap script can be located on your download location.\n\n```ps\n\n$overrideParams = @{\n    requiredParam = 'AAAA'\n    optionalParamWithDefault='BBB'\n    optionalParamFromEnvironment='CCC'\n}\n\n\n$ScriptPath = ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/Voronenko/ps_oneliners/master/bootstrap.ps1'))\n$sb = [scriptblock]::create(\".{$($ScriptPath)} $(\u0026{$args} @overrideParams)\")\nInvoke-Command -ScriptBlock $sb\n\n# output of the ^ command\nAbout to execute some bootstrap logic with params AAAA BBB on CCC\n\n$overrideParamsNone = @{\n    requiredParam = 'RRR'\n}\n\n$ScriptPath = ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/Voronenko/ps_oneliners/master/bootstrap.ps1'))\n$sb = [scriptblock]::create(\".{$($ScriptPath)} $(\u0026{$args} @overrideParamsNone)\")\nInvoke-Command -ScriptBlock $sb\n\n# output of the ^ command\nAbout to execute some bootstrap logic with params RRR https://github.com/Voronenko/ps_oneliners on EC2AMAZ-9A8TRAV\nFor example, we download smth from internet\n\n```\n\nAcceptance: PASSED\n\n\n## Option D - Real one-liner using PowerShell module and iwr + iex\n\nAs stated, requiries installation logic packed as a PowerShell module (see `bootstrap-module.ps1`)\n\n`. { iwr -useb https://path/to/bootsrap.ps1 } | iex; function -param value`\n\n```ps\n\n. { iwr -useb https://raw.githubusercontent.com/Voronenko/ps_oneliners/master/bootstrap-module.ps1 } | iex; install -requiredParam AAA -optionalParamWithDefault BBB -optionalParamFromEnvironment CCC\n\n# output of the ^ command\n\nModuleType Version    Name                                ExportedCommands\n---------- -------    ----                                ----------------\nScript     0.0        CustomInstaller                     {Install-Project, install}\nAbout to execute some bootstrap logic with params AAA BBB on CCC\n\n# Validation - no overrides\n\n. { iwr -useb https://raw.githubusercontent.com/Voronenko/ps_oneliners/master/bootstrap-module.ps1 } | iex; install\n\n# output of the ^ command\n\nModuleType Version    Name                                ExportedCommands\n---------- -------    ----                                ----------------\nScript     0.0        CustomInstaller                     {Install-Project, install}\n\ncmdlet Install-Project at command pipeline position 1\nSupply values for the following parameters:\nrequiredParam: RRR\n\n```\n\nAcceptance: PASSED\n\nwhere bootstrap-module.ps1 is our original bootstrap file, but packed/wrapped into a module.\n\n```ps\n\n#Download and Run MSI package for Automated install\nnew-module -name CustomInstaller -scriptblock {\n    [Console]::OutputEncoding = New-Object -typename System.Text.ASCIIEncoding\n    [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]'Tls,Tls11,Tls12'\n\n    function Install-Project {\n        param (\n            [Parameter(Mandatory = $true)]\n            [string]$requiredParam = \"THIS_PARAM_IS_REQUIRED\",\n            [string]$optionalParamWithDefault = \"https://github.com/Voronenko/ps_oneliners\",\n            [string]$optionalParamFromEnvironment = $env:computername\n        )\n\n\n        Write-Host \"About to execute some bootstrap logic with params $requiredParam $optionalParamWithDefault on $optionalParamFromEnvironment\"\n\n        Function Download_MSI_Installer {\n            Write-Host  \"For example, we download smth from internet\"    \n            # Write-Host \"About to download $uri to $out\"\n            # Invoke-WebRequest -uri $uri -OutFile $out\n            # $msifile = Get-ChildItem -Path $out -File -Filter '*.ms*'\n            # Write-Host  MSI $msifile \"\n        }\n\n        Function Install_Script {\n            # $msifile = Get-ChildItem -Path $out -File -Filter '*.ms*'\n            # $FileExists = Test-Path $msifile -IsValid\n\n            $DataStamp = get-date -Format yyyyMMddTHHmmss\n            $logFile = '{0}-{1}.log' -f $msifile.fullname, $DataStamp\n            $MSIArguments = @(\n                \"/i\"\n                ('\"{0}\"' -f $msifile)\n                \"/qn\"\n                \"/norestart\"\n                \"/L*v\"\n                $logFile\n                \" REQUIRED_PARAM=$requiredParam OPTIONAL_PARAM_WITH_DEFAULT=$optionalParamWithDefault OPTIONAL_PARAM_FROM_ENVIRONMENT=$optionalParamFromEnvironment\"\n            )\n            write-host \"About to install msifile with arguments \"$MSIArguments\n            # If ($FileExists -eq $True) {\n            #     Start-Process \"msiexec.exe\" -ArgumentList $MSIArguments -passthru | wait-process\n            #     Write-Host \"Finished msi \"$msifile\n            # }\n\n            # Else {Write-Host \"File $out doesn't exists - failed to download or corrupted. Please check.\"}\n        }\n\n        Download_MSI_Installer\n        Install_Script        \n\n    }\n\n    set-alias install -value Install-Project\n\n    export-modulemember -function 'Install-Project' -alias 'install'\n\n}\n\n\n```\n\nSo far option D is the most one-linish :)\n\nCheck out  https://github.com/Voronenko/ps_oneliners for examples from article.\n\n# Summary\n\nWe now have few approaches to choose from, to implement short \"one-liners\" to bootstrap some logic with PowerShell\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvoronenko%2Fps_oneliners","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvoronenko%2Fps_oneliners","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvoronenko%2Fps_oneliners/lists"}