Challenge - 5 Problems
Code Signing Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of this PowerShell code signing command?
Consider the following PowerShell command that attempts to sign a script file. What will be the output if the certificate thumbprint is invalid or not found?
PowerShell
Set-AuthenticodeSignature -FilePath script.ps1 -Certificate (Get-ChildItem Cert:\CurrentUser\My\INVALIDTHUMBPRINT)
Attempts:
2 left
💡 Hint
Think about what happens if the certificate object is null or empty.
✗ Incorrect
If the certificate thumbprint does not match any certificate in the store, Get-ChildItem returns nothing, causing Set-AuthenticodeSignature to fail with an error about the missing certificate.
💻 Command Output
intermediate2:00remaining
What does this PowerShell snippet output when verifying a signed script?
Given a signed script file 'signedScript.ps1', what will this command output?
PowerShell
Get-AuthenticodeSignature -FilePath signedScript.ps1 | Select-Object Status
Attempts:
2 left
💡 Hint
The script is signed and not tampered with.
✗ Incorrect
Get-AuthenticodeSignature returns a Status property indicating the signature validity. For a properly signed and untampered script, the status is 'Valid'.
📝 Syntax
advanced2:00remaining
Which option correctly signs a script with a certificate from the CurrentUser store?
Select the PowerShell command that correctly signs 'myscript.ps1' using a certificate with thumbprint 'ABC123' from the CurrentUser\My store.
Attempts:
2 left
💡 Hint
Get-ChildItem with a path ending with thumbprint does not work as expected; filtering is needed.
✗ Incorrect
Get-ChildItem does not accept a thumbprint as a direct path segment. Instead, you list certificates and filter by Thumbprint property using Where-Object.
🔧 Debug
advanced2:00remaining
Why does this code signing command fail with a null certificate error?
Analyze the following code snippet and select the reason it fails with a null certificate error.
PowerShell
$cert = Get-ChildItem Cert:\CurrentUser\My | Where-Object { $_.Subject -like '*MyCert*' }
Set-AuthenticodeSignature -FilePath script.ps1 -Certificate $certAttempts:
2 left
💡 Hint
Consider what happens if the filter returns more than one certificate.
✗ Incorrect
If the filter returns multiple certificates, $cert becomes a collection, but Set-AuthenticodeSignature expects a single certificate object, causing an error.
🚀 Application
expert3:00remaining
How to automate signing multiple scripts with error handling in PowerShell?
You want to sign all '.ps1' files in a folder using a certificate with thumbprint 'DEF456'. Which script correctly signs each file and logs errors without stopping the entire process?
Attempts:
2 left
💡 Hint
You want to continue signing even if one file fails and log the error.
✗ Incorrect
Option A uses try-catch inside the loop to handle errors per file and logs failures without stopping the entire process. Option A stops on first error, B lacks error handling, C suppresses errors silently without logging.