Kamen Yotov
Saturday, August 12, 2006
IPropertyCmdletProvider and its GetProperty method

The IPropertyCmdletProvider Windows PowerShell interface and particularly its GetProperty method have poor documentation (here and here).

The second source mentioned above also gives the following (wrong) example:
public void GetProperty(
    string path,
    Collection providerSpecificPickList)
{
    PSObject PShObject = new PSObject();
    PSObject.AddNote(propertyName, propertyValue);
    WritePropertyObject(propertyValue, path);
}
Fortunately there is a hint that the standard FileSystemProvider implements the IPropertyCmdletProvider interface. Looking at the disassembly of "C:\Program Files\Windows PowerShell\v1.0\System.Management.Automation.dll" (where FileSystemProvider lives), one can conclude that the above example should in fact be:
public void GetProperty(
    string path,
    Collection providerSpecificPickList)
{
    PSObject o = new PSObject();
    o.Properties.Add(new PSNoteProperty(name, value));
    WritePropertyObject(o, path);
}
I hope you find this information useful! Keywords: Windows, PowerShell, Provider
 
Comments: Post a Comment



<< Home

ARCHIVES
August 2006 /


Powered by Blogger

 View...