Intermediate PowerShell test (Intermediate)
30 questions · 35 minutes · Free
Functions, modules, error handling, remoting, files, services and the registry.
Take the Intermediate PowerShell test
What it covers
- PowerShell functions and parameters
- PowerShell modules
- PowerShell error handling
- PowerShell remoting
- PowerShell files, registry and services
Interview format
- Questions: 30 questions — 18 multiple choice, 9 multi-answer, 3 predict-the-output
- Time: 35 minutes, timed from the first question
- Difficulty: Intermediate
- Skill area: DevOps & cloud
- Price: Free
Earn a certificate
The Intermediate PowerShell test is one of the 6 tests of the Systems Administrator learning path. Pass it and the other 5 tests at 70% or more and readyforhires issues you a verifiable certificate in your name, with its own code and verify link to share or add to LinkedIn.
Sample questions
5 sample questions from the Intermediate PowerShell test, with the answers. Samples are taken out of the live test, so you will not meet these when you sit it.
Which PowerShell command correctly reads a CSV file with custom headers 'Name' and 'Age' from the path 'C:\data\file.csv' using UTF8 encoding?
- Get-Content -Path 'C:\data\file.csv' | ConvertFrom-Csv -Encoding UTF8 -Header 'Name', 'Age'
- Export-Csv -Path 'C:\data\file.csv' -Encoding UTF8 -Header 'Name', 'Age'
- Import-Csv -Path 'C:\data\file.csv' -Encoding UTF8 -Header 'Name', 'Age'
- Read-File -Path 'C:\data\file.csv' -Delimiter ',' -Header 'Name', 'Age'
Answer: C. Import-Csv -Path 'C:\data\file.csv' -Encoding UTF8 -Header 'Name', 'Age'
The `Import-Csv` cmdlet is used to read CSV files. The `-Encoding` parameter specifies the encoding of the file, and the `-Header` parameter is used to define custom headers if the CSV does not have them. Using UTF8 encoding ensures compatibility with a wide range of systems and is a best practice for modern files. Other options are incorrect because they use incorrect syntax, parameters, or cmdlets that are not used for reading CSV files.
Consider the following PowerShell function: `function Get-EvenNumber { [CmdletBinding()] param([Parameter(Mandatory, ValueFromPipeline)][int]$Number) process { $Number * 2 } }`. If you run `1..3 | Get-EvenNumber`, what will be the output?
- The function will output 2, 4, 6 because the `$Number` parameter is not bound to the pipeline input, and the function uses the default value instead.
- The function will output 1, 2, 3 because the pipeline input is not processed correctly in the `process {}` block.
- The function will output 2, 4, 6 because the pipeline processes each object in the `process {}` block, and the `$Number` variable is correctly bound to each item in the pipeline.
- The function will not output anything because the `process {}` block is not used, and the pipeline input is ignored.
Answer: C. The function will output 2, 4, 6 because the pipeline processes each object in the `process {}` block, and the `$Number` variable is correctly bound to each item in the pipeline.
The function `Get-EvenNumber` uses the `process {}` block to process each pipeline object, and the `$Number` parameter is correctly bound to each item in the pipeline. Since the pipeline input is 1, 2, 3, the function multiplies each by 2, resulting in 2, 4, 6 being output. Other options may suggest incorrect behavior due to misunderstandings about how pipeline input is processed in advanced functions.
Which of the following is the correct way to create a new PowerShell remoting endpoint on port 5986 using HTTPS?
- Use `New-PSSession` with the `-Port` and `-UseSSL` parameters to create a new endpoint.
- Run `Enable-PSRemoting -Force` with the `-UseSSL` parameter to create an HTTPS endpoint.
- Modify the registry key `HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WinRM\Client` to define a new endpoint.
- Use the WinRM configuration tool to create a new endpoint on port 5986 with HTTPS.
Answer: D. Use the WinRM configuration tool to create a new endpoint on port 5986 with HTTPS.
To create a remoting endpoint, you must use the WinRM configuration tool to set up a new endpoint on the desired port with the appropriate protocol (e.g., HTTPS). Simply enabling remoting with `Enable-PSRemoting` does not create a specific endpoint, and using `New-PSSession` or `Invoke-Command` without configuring the endpoint will not result in a new endpoint being created. PowerShell does not allow dynamically creating remoting endpoints via commands like `New-PSRemotingEndpoint` for HTTPS; WinRM must be used for this configuration.
Which block in a PowerShell function is used to handle each object passed through the pipeline?
- Use the `process` block to handle each object in the pipeline
- Use the `end` block to handle each object in the pipeline
- Use the `begin` block to handle each object in the pipeline
- Use the `param` block to handle each object in the pipeline
Answer: A. Use the `process` block to handle each object in the pipeline
In PowerShell functions, the `process` block is specifically designed to handle each object passed through the pipeline. The `begin` block runs once at the beginning, and the `end` block runs once at the end, but the `process` block executes for each object in the pipeline, making it the correct choice for handling pipeline input.
Which PowerShell cmdlet is used to retrieve registry values under a specific key?
- Get-RegistryValue
- Get-Item
- Get-ItemProperty
- Get-ChildItem
Answer: C. Get-ItemProperty
To retrieve registry values in PowerShell, the `Get-ItemProperty` cmdlet is used. This cmdlet retrieves the properties of an item, which in the case of the registry, includes the values stored under a specific key. The `Get-ChildItem` cmdlet is used for listing subkeys, not for retrieving values. The `Get-Item` cmdlet is used for retrieving the key itself, not the values. The `Get-RegistryValue` cmdlet does not exist in PowerShell.
Frequently asked questions
- How many questions are in the Intermediate PowerShell test?
- 30 questions (18 multiple choice, 9 multi-answer, 3 predict-the-output), with 35 minutes to answer them.
- What does the Intermediate PowerShell test cover?
- PowerShell functions and parameters, PowerShell modules, PowerShell error handling, PowerShell remoting, PowerShell files, registry and services.
- Is the Intermediate PowerShell test free?
- Yes. It is free to take with a readyforhires account.
- What level is the Intermediate PowerShell test?
- Intermediate, in DevOps & cloud.