I am newish to PowerShell, and I have a very Java-centric development background. As such, I lean very heavily on the Javadoc for any API that I am using. I am now trying to write some PowerShell code that is a little more robust than just a simple script. I want to use Try/Catch/Finally, for example, to catch errors and handle them. However, I don't want to just catch the base [system.exception]
class.
In Javadoc, if an action throws an Exception, I can see very clearly in the Javadoc what that Exception is, and catch it (in the case where several exceptions may be thrown, and I want to do different things depending on which one it is for example).
I am looking for the analogous documentation for PowerShell. For example,
New-Item F:\ExistingFolder\NewFolder -Type Directory
would throw an exception if NewFolder
already exists. It might also throw a different exception if ExistingFolder
does not exist.
Where is such documentation if it is available?
You'd have to find out the underlying .NET method that's used to do the work and look at its documentation. In case of your example, probably the
CreateDirectory
method:I'm not aware of official (or unofficial) documentation that references the .NET methods called by PowerShell cmdlets.