Tuesday, February 19, 2008

Want to Crash PowerShell?

Try -

$x=1; $x.$y=1

 


It seems like any indirect property reference, when the referencing variable is $null, will crash PowerShell. Consequently, you can do it on any built-in variable like this -


$input.$null=1

 


I will report it to Microsoft. I do not know whether it has been reported or not as my connect.microsoft.com connection to PowerShell does not work :(

2 comments:

Anonymous said...

Hiya, Per

I tried this on CTP2 and could not reproduce it.

PoSH> $x=1; $x.$y=1
Property '' cannot be found on this object; make sure it exists and is settable
.
At line:1 char:10
+ $x=1; $x. <<<< $y=1
PoSH> $input.$null=1
Property '' cannot be found on this object; make sure it exists and is settable
.
At line:1 char:8
+ $input. <<<< $null=1

Greetings /\/\o\/\/

jsnover said...

> I tried this on CTP2 and could not reproduce it.

Ditto. I looks like we fixed that one already.

Jeffrey Snover [MSFT]
Windows Management Partner Architect
Visit the Windows PowerShell Team blog at: http://blogs.msdn.com/PowerShell
Visit the Windows PowerShell ScriptCenter at: http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx