February 2019
Intermediate to advanced
626 pages
15h 51m
English
The evaluation of elements in the AST is the method used by the PSScriptAnalyzer tool. The tool can be installed using the following code:
Install-Module PSScriptAnalyzer -Scope CurrentUser
PSScriptAnalyzer can be used to inspect a script with the Invoke-ScriptAnalzyer command. For example, the tool will flag warnings and errors about use of the Password parameter and variable, as it is not considered to be a good practice:
[CmdletBinding()]
param (
[Parameter(Mandatory)]
[String]$Password
)
$credential = [PSCredential]::new(
'.\user',
($Password | ConvertTo-SecureString -AsPlainText -Force)
)
$credential.GetNetworkCredential().Password
The script is saved to a file named Show-Password.ps1, and the analyzer is run against ...
Read now
Unlock full access