come trovare un refuso in mezzo a 1000 righe di codice di scripting powershell?
A project I’m working on involves 1000s of lines of code, across numerous modules and folders. When I make changes, like everyone else, I sometimes mistype a command. When your system throws an error and its in nested several levels deep in your code and you’re not sure where it is – who you going to call?
Unfortunately, Ghostbusters can’t help you. But PowerShell can help. I’d type [swtch] instead of [switch]. Nice easy way to find the spelling mistake. Open a PowerShell prompt in the top folder and
Get-ChildItem -Recurse -File | Select-String -Pattern “[swtch]” –SimpleMatch
You will get the file and line number containing the typo. Simple.