Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

How to pass a query/get parameter in PSWS?

$
0
0

Hello all,

I'm trying to get my head around PSWS/IIS OData extensions. 

I am having issues with how to pass parameters when doing a query/get to a function. The function is Called Get-MyUser in the relative path MyUser and it has a Parameter called Username. Calling without any parameter works just fine, it is with a parameter it doesn't work for me.

I call it in the following way:

http://localhost:7000/MyTest.svc/MyUser/?Username='steve'

And I get the following error:

The parameter Username is not a valid URL option for the cmdlet Get-MyUser. Parameter name: parameter

The param block of the function looks like this:

    param(
        [string]$Username
    )

The Mof class like this:

class MOFCLASS_MyUser

{
    [Key]       String  Username;
    [Required]  String  DisplayName;
};

The schema looks like this:

        <Resource>
            <RelativeUrl>MyUser</RelativeUrl>
            <Class>MOFCLASS_MyUser</Class>
        </Resource>

...

        <Class>
            <Name>MOFCLASS_MyUser</Name>
            <CmdletImplementation>
                <Query>
                    <Cmdlet>Get-MyUser</Cmdlet>
                        <ParameterSets>
                            <ParameterSet>
                                <Name>__AllParameterSets</Name>
                                <Parameter><Name>Username</Name></Parameter>
                            </ParameterSet>
                    </ParameterSets>
                </Query>
               <Update>
                    <Cmdlet>Set-MyUser</Cmdlet>
                    <ParameterSets>
                        <ParameterSet>
                            <Name>__AllParameterSets</Name>
                            <Parameter><Name>Username</Name></Parameter>
                            <Parameter><Name>DisplayName</Name></Parameter>
                        </ParameterSet>
                    </ParameterSets>
                </Update>
            </CmdletImplementation>
        </Class>

Anyone who can see what I am doing wrong? Any help appreciated.


--Neptune


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>