Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

How can I create PSProvider specific parameters for cmdlets?

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 10-08-2006   #1 (permalink)
Sung M Kim
Guest


 

How can I create PSProvider specific parameters for cmdlets?

I was creating a PsProvider extending ContainerCmdletProvider.

While overriding methods, I came across, "NewItem" function that I had
to override(with the following C# method signature):
----------------------------------------
protected override void NewItem(string path, string itemTypeName,
object newItemValue)
----------------------------------------

Now, what I would like to accomplish is, I would like to have
"New-Item" to have more parameters inside the PsProvider I am writing.

How can I specify addiation provider-specific parameters?

For ex) within "Certificate" PsProvider, "Get-ChildItem" has
"-CodeSigningCert" parameter. I am wondering how it can be done.

By the way, "NewItem" is just one of the functions I would like to add
more parameters to.

Thank you in advance.


My System SpecsSystem Spec
Old 10-09-2006   #2 (permalink)
Narayanan Lakshmanan [MSFT]
Guest


 

Re: How can I create PSProvider specific parameters for cmdlets?

You can override the following function to enable it to take additional
parameters

protected override object NewItemDynamicParameters(string path,
string type, object newItemValue)

Refer to the PowerShell Managed Reference in the Windows SDK for
documentation on the same

--
Narayanan Lakshmanan [MSFT]
Windows PowerShell Development
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.


"Sung M Kim" <DontBotherMeWithSpam@gmail.com> wrote in message
news:1160346169.234021.107030@h48g2000cwc.googlegroups.com...
>I was creating a PsProvider extending ContainerCmdletProvider.
>
> While overriding methods, I came across, "NewItem" function that I had
> to override(with the following C# method signature):
> ----------------------------------------
> protected override void NewItem(string path, string itemTypeName,
> object newItemValue)
> ----------------------------------------
>
> Now, what I would like to accomplish is, I would like to have
> "New-Item" to have more parameters inside the PsProvider I am writing.
>
> How can I specify addiation provider-specific parameters?
>
> For ex) within "Certificate" PsProvider, "Get-ChildItem" has
> "-CodeSigningCert" parameter. I am wondering how it can be done.
>
> By the way, "NewItem" is just one of the functions I would like to add
> more parameters to.
>
> Thank you in advance.
>


My System SpecsSystem Spec
Old 10-09-2006   #3 (permalink)
Sung M Kim
Guest


 

Re: How can I create PSProvider specific parameters for cmdlets?

Ah great. Thank you for the direction to take


Narayanan Lakshmanan [MSFT] wrote:
> You can override the following function to enable it to take additional
> parameters
>
> protected override object NewItemDynamicParameters(string path,
> string type, object newItemValue)
>
> Refer to the PowerShell Managed Reference in the Windows SDK for
> documentation on the same
>
> --
> Narayanan Lakshmanan [MSFT]
> Windows PowerShell Development
> Microsoft Corporation
> This posting is provided "AS IS" with no warranties, and confers no rights.


My System SpecsSystem Spec
Old 10-09-2006   #4 (permalink)
Sung M Kim
Guest


 

Re: How can I create PSProvider specific parameters for cmdlets?

Ok, Now I am faced with a new problem but still related to the main
subject.
I have now created a new dynamic parameter for "Get-Item" cmdlet in
"GetItemDynamicParameters" and added "EventID" parameter to "Get-Item".

protected override object GetItemDynamicParameters(string path)
{
WriteVerbose("GetItemDynamicParametersath = " + path);

RuntimeDefinedParameterDictionary dic =
new RuntimeDefinedParameterDictionary();

ParameterAttribute attrib = new ParameterAttribute();
attrib.ParameterSetName = "Path";
attrib.Mandatory = false;
attrib.ValueFromPipeline = true;
Collection<Attribute> col =
new Collection<Attribute>();
col.Add(attrib);

RuntimeDefinedParameter eventIdParam =
new RuntimeDefinedParameter("EventID", typeof(int) ,
col);
dic.Add("EventID", eventIdParam);

return dic;
}

Now the problem is that, I am not sure how I can access the argument
passed to "EventID" parameter inside overriden "GetItem" method. Is
there a utility method that can be used to access the argument for the
dynamic parameter?

My System SpecsSystem Spec
Old 10-11-2006   #5 (permalink)
Lee Holmes [MSFT]
Guest


 

Re: How can I create PSProvider specific parameters for cmdlets?

Those are available through the DynamicParameters property.

Lee

"Sung M Kim" <DontBotherMeWithSpam@gmail.com> wrote in message
news:1160447650.743624.257530@m73g2000cwd.googlegroups.com...
> Ok, Now I am faced with a new problem but still related to the main
> subject.
> I have now created a new dynamic parameter for "Get-Item" cmdlet in
> "GetItemDynamicParameters" and added "EventID" parameter to "Get-Item".
>
> protected override object GetItemDynamicParameters(string path)
> {
> WriteVerbose("GetItemDynamicParametersath = " + path);
>
> RuntimeDefinedParameterDictionary dic =
> new RuntimeDefinedParameterDictionary();
>
> ParameterAttribute attrib = new ParameterAttribute();
> attrib.ParameterSetName = "Path";
> attrib.Mandatory = false;
> attrib.ValueFromPipeline = true;
> Collection<Attribute> col =
> new Collection<Attribute>();
> col.Add(attrib);
>
> RuntimeDefinedParameter eventIdParam =
> new RuntimeDefinedParameter("EventID", typeof(int) ,
> col);
> dic.Add("EventID", eventIdParam);
>
> return dic;
> }
>
> Now the problem is that, I am not sure how I can access the argument
> passed to "EventID" parameter inside overriden "GetItem" method. Is
> there a utility method that can be used to access the argument for the
> dynamic parameter?
>



My System SpecsSystem Spec
Old 10-11-2006   #6 (permalink)
Sung M Kim
Guest


 

Re: How can I create PSProvider specific parameters for cmdlets?


Lee Holmes [MSFT] wrote:
> Those are available through the DynamicParameters property.
>
> Lee


Not being able to navigate around(using tree views on MSDN) PowerShell
classes made it a bit harder for me to browse around...


Thank you for the tips there Lee.

By the way, when will System.Management.Automation.* classes for
PowerShell be available on MSDN?

My System SpecsSystem Spec
Old 10-12-2006   #7 (permalink)
Lee Holmes [MSFT]
Guest


 

Re: How can I create PSProvider specific parameters for cmdlets?

I'm not sure when they'll make it to msdn.microsoft.com (as opposed to
windowssdk.msdn.microsoft.com,) but they are already available online:
http://windowssdk.msdn.microsoft.com....provider.aspx

(We of course continue to add and improve them, but they exist.)

--
Lee Holmes [MSFT]
Windows PowerShell Development
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.

"Sung M Kim" <DontBotherMeWithSpam@gmail.com> wrote in message
news:1160607562.875902.198410@e3g2000cwe.googlegroups.com...
>
> Lee Holmes [MSFT] wrote:
>> Those are available through the DynamicParameters property.
>>
>> Lee

>
> Not being able to navigate around(using tree views on MSDN) PowerShell
> classes made it a bit harder for me to browse around...
>
>
> Thank you for the tips there Lee.
>
> By the way, when will System.Management.Automation.* classes for
> PowerShell be available on MSDN?
>



My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Request: Microsoft to Create a "Service Pack" Specific Group Trevor Vista General 8 04-01-2008 11:38 PM
Request for Microsoft to create Service Pack specific newsgroup for Vista Trevor Vista installation & setup 3 03-25-2008 01:33 PM
Bugs with Registry psProvider dreeschkind PowerShell 2 11-17-2006 03:04 PM
RC2 drop of SharePoint WSS 2003 PSProvider Oisin Grehan PowerShell 0 10-20-2006 03:09 PM
Suggestion: Cmdlet PSProvider Alex K. Angelopoulos [MVP] PowerShell 2 06-15-2006 07:23 PM


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51