![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
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.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| 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 Specs![]() |
| | #2 (permalink) |
| 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 Specs![]() |
| | #3 (permalink) |
| 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 Specs![]() |
| | #4 (permalink) |
| 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("GetItemDynamicParameters ath = " + 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 Specs![]() |
| | #5 (permalink) |
| 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("GetItemDynamicParameters ath = " + 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 Specs![]() |
| | #6 (permalink) |
| 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 Specs![]() |
| | #7 (permalink) |
| 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 Specs![]() |
![]() |
| 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 |