Document not found (404)
176 |This URL is invalid, sorry. Please use the navigation bar or search to continue.
177 | 178 |├── .github └── workflows │ └── render.yml ├── book.toml ├── docs ├── 404.html ├── FontAwesome │ ├── css │ │ └── font-awesome.css │ └── fonts │ │ ├── FontAwesome.ttf │ │ ├── fontawesome-webfont.eot │ │ ├── fontawesome-webfont.svg │ │ ├── fontawesome-webfont.ttf │ │ ├── fontawesome-webfont.woff │ │ └── fontawesome-webfont.woff2 ├── ace.js ├── ayu-highlight.css ├── book.js ├── clipboard.min.js ├── css │ ├── chrome.css │ ├── general.css │ ├── print.css │ └── variables.css ├── editor.js ├── elasticlunr.min.js ├── favicon.png ├── favicon.svg ├── fonts │ ├── OPEN-SANS-LICENSE.txt │ ├── SOURCE-CODE-PRO-LICENSE.txt │ ├── fonts.css │ ├── open-sans-v17-all-charsets-300.woff2 │ ├── open-sans-v17-all-charsets-300italic.woff2 │ ├── open-sans-v17-all-charsets-600.woff2 │ ├── open-sans-v17-all-charsets-600italic.woff2 │ ├── open-sans-v17-all-charsets-700.woff2 │ ├── open-sans-v17-all-charsets-700italic.woff2 │ ├── open-sans-v17-all-charsets-800.woff2 │ ├── open-sans-v17-all-charsets-800italic.woff2 │ ├── open-sans-v17-all-charsets-italic.woff2 │ ├── open-sans-v17-all-charsets-regular.woff2 │ └── source-code-pro-v11-all-charsets-500.woff2 ├── frequently-asked-faq-questions │ ├── contributing.html │ └── license.html ├── getting-started │ ├── environment-variables.html │ ├── execution-policy.html │ ├── parameters.html │ ├── powershell-version.html │ └── script-root.html ├── highlight.css ├── highlight.js ├── index.html ├── justification │ └── why-powershell.html ├── learning-paths │ ├── books-for-newbies.html │ ├── books-for-programmers.html │ ├── free-ebooks.html │ ├── learning-powershell.html │ └── video-resources.html ├── mark.min.js ├── mode-rust.js ├── print.html ├── searcher.js ├── searchindex.js ├── searchindex.json ├── theme-dawn.js ├── theme-tomorrow_night.js └── tomorrow-night.css └── src ├── README.md ├── SUMMARY.md ├── frequently-asked-faq-questions ├── contributing.md └── license.md ├── getting-started ├── environment-variables.md ├── execution-policy.md ├── parameters.md ├── powershell-version.md └── script-root.md ├── justification └── why-powershell.md └── learning-paths ├── books-for-newbies.md ├── books-for-programmers.md ├── free-ebooks.md ├── learning-powershell.md └── video-resources.md /.github/workflows/render.yml: -------------------------------------------------------------------------------- 1 | name: Update GitHub Pages 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | release: 10 | name: GitHub Pages 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - name: Checkout Repository 15 | uses: actions/checkout@v2 16 | 17 | # Todo: cache this as a tool 18 | - name: Setup mdBook 19 | shell: pwsh 20 | run: | 21 | Invoke-WebRequest -OutFile mdbook.tgz ( 22 | Invoke-RestMethod https://api.github.com/repos/rust-lang/mdBook/releases/latest 23 | ).assets.where{$_.name -like "*linux-gnu.tar.gz"}.browser_download_url 24 | tar -zxvf mdbook.tgz 25 | Remove-Item mdbook.tgz 26 | mkdir ~/bin 27 | Move-Item ./mdbook ~/bin/mdbook 28 | "~/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append 29 | 30 | # - name: Checkout PR 31 | # env: 32 | # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 33 | # run: gh pr checkout ${{ github.event.pull_request.number }} 34 | 35 | - name: Build Book 36 | run: | 37 | mdbook build 38 | # cp ./config/CNAME ./book/CNAME 39 | 40 | - name: Setup git config 41 | run: | 42 | # setup the username and email. 43 | git config user.name "mdbook build bot" 44 | git config user.email "<>" 45 | 46 | - name: Push changes 47 | env: 48 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 49 | run: | 50 | git add docs/* 51 | git commit -m "mdbook build output" 52 | git push 53 | 54 | # - name: Deploy Book 55 | # env: 56 | # ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }} 57 | # PUBLISH_BRANCH: gh-pages 58 | # PUBLISH_DIR: ./book 59 | # SCRIPT_MODE: true 60 | # run: | 61 | # wget https://raw.githubusercontent.com/peaceiris/actions-gh-pages/v2.5.0/entrypoint.sh 62 | # bash ./entrypoint.sh -------------------------------------------------------------------------------- /book.toml: -------------------------------------------------------------------------------- 1 | [book] 2 | title = "PowerShell FAQ" 3 | author = "PoshCode Community" 4 | description = "Frequently Asked Questions in the PowerShell Community" 5 | language = "en" 6 | src = "src" 7 | 8 | [build] 9 | build-dir = "docs" 10 | create-missing = false 11 | 12 | [preprocessor.index] 13 | 14 | [preprocessor.links] 15 | 16 | [output.html] 17 | mathjax-support = true 18 | site-url = "/" 19 | git-repository-url = "https://github.com/PoshCode/PowerShellFAQ" 20 | 21 | 22 | [output.html.playground] 23 | editable = true 24 | line-numbers = true 25 | 26 | [output.html.search] 27 | limit-results = 20 28 | use-boolean-and = true 29 | boost-title = 2 30 | boost-hierarchy = 2 31 | boost-paragraph = 1 32 | expand = true 33 | heading-split-level = 2 34 | 35 | [rust] 36 | edition = "2018" -------------------------------------------------------------------------------- /docs/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 |This URL is invalid, sorry. Please use the navigation bar or search to continue.
177 | 178 |Passing arguments in PowerShell is the same as in any other shell: you just type the command name, and then each argument, separated by spaces. If you need to specify the parameter name, you prefix it with a dash like -Name
and then after a space (or a colon), the value. If the parameter is a "switch" then specifying it's name sets it to True, so you should not provide a value. Passing multiple values to the same parameter requires commas (and optionally, the @(...)
array specifier).
Accepting parameters in a PowerShell script (or function) is done by adding a param
block at the top with a comma-separated list of parameter names:
function Test-Script {
177 | param($Name,$Age)
178 | "$Name is roughly $Age years old"
179 | }
180 |
181 | Test-Script "The Doctor" "4.5 billion"
182 | Test-Script -Name Mother -Age 29
183 |
184 |
185 | The version of PowerShell is always available within PowerShell in the $PSVersionTable
as the "PSVersion" property. As of PowerShell 5, there is also a "PSEdition" property (which is also available as it's own $PSEdition
variable) to distinguish Windows PowerShell (the "Desktop" edition) from PowerShell Core (the "Core" edition).
Ever since PowerShell 3, there is an automatic variable $PSScriptRoot
which is set to the path of the directory that contains the currently-executing module or script. Additionally, there is $PSCommandPath
which contains the path (including the file name) to the currently executing script.
A collection of questions (and answers), curated by the PowerShell Virtual User Group on Discord and Slack.
175 | 176 |PowerShell is a cross-platform shell and scripting language that's required for managing Windows servers, and is capable of managing the cloud, including Linux and Windows, Azure, AWS and GCP. If you want to automate something, PowerShell is both a task-based command-line shell, and a powerful scripting language -- with full access to the .Net Framework. It's also the standard for managing Windows Server and other Microsoft server products and services.
175 |If you need more, Warren Frame and Don Jones wrote a short eBook on the subject. Why PowerShell?
176 | 177 |There are a lot of free eBooks available. A great list of PowerShell books (which includes some free ones) was compiled a few years ago by Jason Hofferle. It includes many from PowerShell.org, and there are more published under the "Devops Collective" on GitBook. Our favorites are Why PowerShell? and The Big Book of PowerShell Gotchas.
175 |Most PowerShell content from Microsoft is in the form of product-specific training. As far as the language itself, there's rarely more than the introduction to PowerShell on Microsoft Learn. You should also check out PS Koans. There are a lot of videos, books, and commercial classes, but that's a different question.
175 | 176 |