Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Using .NET Classes with Powershell

$
0
0

Hello all,

I am starting to experiment with using .NET classes with Powershell but I lack understanding as to why this doesn't work:

Add-Type -AssemblyName System
$obj = New-Object System.Diagnostics.Process

$obj.Start('Notepad')

Cannot find an overload for "Start" and the argument count: "1".
At line:4 char:1
+ [void]$obj.Start('Notepad')
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest

However this does work:

Add-Type -AssemblyName System
[System.Diagnostics.Process]::Start('Notepad')

Thanks for any help or insight you can provide. Smile

 


Viewing all articles
Browse latest Browse all 6937

Latest Images

Trending Articles



Latest Images