$aliases = @( 'Invoke-WebRequest', 'iwr', 'curl', 'wget' ) Get-ChildItem -Path .\ -Recurse -Include *.ps1,*.psm1 -File | ForEach-Object { $file = $_.FullName $errors = $null $ast = [System.Management.Automation.Language.Parser]::ParseFile( $file, [ref]$null, [ref]$errors ) if ($errors) { return } $ast.FindAll( { param($node) if (-not ($node -is [System.Management.Automation.Language.CommandAst])) { return $false } $cmdName = $node.GetCommandName() if (-not $cmdName) { return $false } if ($aliases -notcontains $cmdName) { return $false } $params = $node.CommandElements | Where-Object { $_ -is [System.Management.Automation.Language.CommandParameterAst] } $hasOutFile = $params | Where-Object { $_.ParameterName -ieq 'OutFile' } $hasBasic = $params | Where-Object { $_.ParameterName -ieq 'UseBasicParsing' } return (-not $hasOutFile) -and (-not $hasBasic) }, $true ) | ForEach-Object { [pscustomobject]@{ Path = $file LineNumber = $_.Extent.StartLineNumber Command = $_.Extent.Text.Trim() CommandName= $cmdName } } }