I was looking for a way to make the necessary parameters in powershell when I discovered this blog post suggesting the following:
param( [string] $ObjectName = $(Throw "Parameter -ObjectName must be set to the name of a database object") );
After digesting for some time, I came to the conclusion that it would be better to throw an ArgumentException as opposed to a line:
param( [string] $ObjectName = $(Throw New-Object System.ArgumentException "Parameter -ObjectName must be set to the name of a database object","ObjectNamt") );
Now, in terms of C #, the latter will be better. Is there a reason this practice doesn't translate to powershell?
powershell
Justin Dearing
source share