PowerTip: Find References to Uninitialized Variables in PowerShell

Doctor Scripto

Summary: Easily find references to uninitialized variables in Windows PowerShell.

Hey, Scripting Guy! Question My extremely long script keeps failing and I suspect it may be because of variables that are not
           initialized prior to being used. How can I find uninitialized variables?

Hey, Scripting Guy! Answer Use the Set-StrictMode cmdlet and set it to –version 1 to ensure that all references to 
           initialized variables generate an error:

Set-StrictMode –version 1

0 comments

Discussion is closed.

Feedback usabilla icon