One of the major advantages to the new provider model and the CIM IDE is that the metadata created by Visual Studio can be directly consumed by PowerShell. Instead of having to write functions that expose the functionality, or by using the generic CIM or WMI functions, we can just create specific functions for our provider. In the previous section we created PowerShell metadata as a CDXML file. This file is responsible for generating the functions. In order to generate the functions, we just import the metadata file using Import-Module
as follows:
PS C:\> Import-Module "C:\PS_WIN32_NetworkDrive.cdxml" -Verbose
VERBOSE: Importing function 'Disconnect-WIN32NetworkDrive'.
VERBOSE: Importing function 'Get-WIN32NetworkDrive'.
Now that they are imported we can use them just like we would any other function. If we investigate the syntax of the function we will also see that the parameters that we specified in the CIM IDE are exposed. This is done by using...