Why avoid hard-coded passwords?
Documentation: Microsoft Learn
Hard-coded passwords leak into logs, history, and repos — test the safer alternatives.
Overview
QUIZ
Core PowerShell · Question 7 of 12
Explanation
Secrets in source code can leak through source control, logs, backups or shared files.
Apply the reasoning
A credential committed to a script can survive in repository history even after the current file is edited. Copies in logs, backups or shared folders create additional exposure. Obtain secrets through the approved credential or secret-management mechanism for the automation identity.
Why the other choices fail
Saving a script does not encrypt password literals. A literal password does not inherently bind execution to the author’s computer or force a remote connection to use the current Windows identity. Replacing the literal is only part of remediation: rotate an exposed secret and review the places where it may have been copied.
Review the prerequisite
errors debugging
Primary documentation
Choose your answer
Choose one answer to see feedback.