Advanced PowerShell test (Advanced)
40 questions · 40 minutes · Free
Advanced functions, DSC, automation at scale and secure scripting.
Take the Advanced PowerShell test
What it covers
- PowerShell advanced functions
- PowerShell Desired State Configuration
- PowerShell automation at scale
- Secure PowerShell scripting
- PowerShell classes
Interview format
- Questions: 40 questions — 24 multiple choice, 12 multi-answer, 4 predict-the-output
- Time: 40 minutes, timed from the first question
- Difficulty: Advanced
- Skill area: DevOps & cloud
- Price: Free
Earn a certificate
The Advanced PowerShell test is one of the 6 tests of the Systems Administrator: Advanced 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 Advanced PowerShell test, with the answers. Samples are taken out of the live test, so you will not meet these when you sit it.
What will happen if the Local Configuration Manager (LCM) is configured with 'ConfigurationMode' set to 'ApplyAndMonitor'?
- The Local Configuration Manager (LCM) will not apply the configuration and will not monitor for drift.
- The Local Configuration Manager (LCM) will not apply the configuration, but will monitor for drift.
- The Local Configuration Manager (LCM) will apply the configuration and automatically correct any drift.
- The Local Configuration Manager (LCM) will apply the configuration and monitor for drift, but will not automatically correct it.
Answer: D. The Local Configuration Manager (LCM) will apply the configuration and monitor for drift, but will not automatically correct it.
In DSC, when the ConfigurationMode is set to 'ApplyAndMonitor', the LCM applies the configuration and continuously monitors for drift. However, it does not automatically correct the drift. Automatic correction is only enabled when ConfigurationMode is set to 'ApplyAndAutoCorrect'.
You are encountering an issue where a DSC resource is repeatedly modifying a system even though it is already in the desired state. What is the most likely cause of this problem?
- The DSC resource's Get method is not implemented correctly.
- The DSC resource's Test method is not returning $true when the system is already in the desired state.
- The LCM is configured to use ApplyOnly mode instead of ApplyAndAutoCorrect.
- The DSC configuration file is not properly signed with a code-signing certificate.
Answer: B. The DSC resource's Test method is not returning $true when the system is already in the desired state.
In PowerShell Desired State Configuration (DSC), a resource must implement the Test method to return $true if the system is already in the desired state. If the Test method does not return $true, the Set method will be unnecessarily invoked, leading to potential misconfigurations or unintended changes. The other options describe issues that are unrelated to the core behavior of DSC resources.
What will the following PowerShell code do when executed: `1..3 | Get-Square` if the function `Get-Square` is defined as: `function Get-Square { [CmdletBinding()] param([Parameter(ValueFromPipeline)][int]$N) process { $N * $N } }`?
- The function will not process any numbers in the pipeline and will output an error
- The function will output only the last item in the pipeline (3) and its square (9)
- The function will output only the first item in the pipeline (1) and its square (1)
- The function will process each number in the pipeline and output their squares: 1, 4, 9
Answer: D. The function will process each number in the pipeline and output their squares: 1, 4, 9
The `process` block in the `Get-Square` function is executed once for each input object passed through the pipeline. In this case, the numbers 1, 2, and 3 are passed through the pipeline, and each is squared and outputted, resulting in 1, 4, and 9. The use of `[Parameter(ValueFromPipeline)]` allows the function to accept input from the pipeline, and the `process` block ensures that each item is processed individually.
What happens when a DSC configuration is refreshed by the Local Configuration Manager (LCM)?
- The LCM waits for user confirmation before applying the configuration.
- The system is rebooted automatically after the configuration is applied.
- The LCM applies the configuration in the background without interrupting the system.
- The configuration is applied only during scheduled maintenance windows.
Answer: C. The LCM applies the configuration in the background without interrupting the system.
When a DSC configuration is refreshed, the Local Configuration Manager (LCM) applies the configuration in the background without interrupting the system. This ensures that systems remain operational while changes are made. Other options are incorrect because they do not accurately describe how the LCM handles configuration refreshes.
Consider the following PowerShell function: function Validate-UserInput { [CmdletBinding()] param([Parameter(Mandatory)][ValidateScript({$_ -gt 0})][int]$Number) Write-Output $Number } When a user attempts to run Validate-UserInput -Number -5, the script fails. What is the reason for the failure?
- The script fails because the parameter is not marked as Mandatory.
- The script fails because the ValidateScript block is not enclosed in parentheses.
- The script fails because the ValidateScript block does not return a boolean value, which is required for validation.
- The script fails because the parameter is not assigned a default value.
Answer: C. The script fails because the ValidateScript block does not return a boolean value, which is required for validation.
The [ValidateScript()] attribute requires the script block to return a boolean value (true or false) to indicate whether the input is valid. If the script block does not return a boolean, the validation will fail, and the parameter will not be accepted. In the given scenario, the script block is not returning a boolean, which is the reason for the failure.
Frequently asked questions
- How many questions are in the Advanced PowerShell test?
- 40 questions (24 multiple choice, 12 multi-answer, 4 predict-the-output), with 40 minutes to answer them.
- What does the Advanced PowerShell test cover?
- PowerShell advanced functions, PowerShell Desired State Configuration, PowerShell automation at scale, Secure PowerShell scripting, PowerShell classes.
- Is the Advanced PowerShell test free?
- Yes. It is free to take with a readyforhires account.
- What level is the Advanced PowerShell test?
- Advanced, in DevOps & cloud.