Powershell Connector ListingCommand

Is there any way to import objects using the Powershell connector with just the ListingCommand and not the full CommandSequence? The API I am connecting to have one command to list all data from all users and one command to list all data from a specific user. During synchronization with the code below, I am first opening a connection to get a list of all the users, then one connection for each users to import all the data. With several thousand users this is causing a lot of unnecessary connections if there is a way to collect all the data by only using the Get-AllUsers command.

<Schema>
    <!--
    Definition of a schema class 'user'
    -->
    <Class Name="User">
        <Properties>           
            <!-- ID -->
            <Property Name="ID" DataType="String" IsUniqueKey="true" IsMandatory="true" IsAutoFill="true">
                <ReturnBindings>
                    <Bind CommandResultOf="Get-AllUsers" Path="id" />
                    <Bind CommandResultOf="Get-UserById" Path="id" />
                    <Bind CommandResultOf="New-User" Path="id" />
                </ReturnBindings>
                <CommandMappings>
                    <Map ToCommand="Get-UserById" Parameter="userID"/>
                    <Map ToCommand="Update-UserById" Parameter="userID"/>
                    <Map ToCommand="Remove-UserById" Parameter="userID"/>
                    <Map ToCommand="Enable-UserById" Parameter="userID"/>
                </CommandMappings>
            </Property>
            
            <!-- email -->
            <Property Name="Email" DataType="String" IsDisplay="true" IsMandatory="true" IsUniqueKey="true">
                <ReturnBindings>
                    <Bind CommandResultOf="Get-AllUsers" Path="email" />
                    <Bind CommandResultOf="Get-UserById" Path="email" />
                </ReturnBindings> 
                <CommandMappings>
                    <Map ToCommand="New-User" Parameter="email"/>
                    <Map ToCommand="Update-UserById" Parameter="email"/>
                </CommandMappings>                                                             
                <ModifiedBy>
                    <ModBy Command="New-User" />
                    <ModBy Command="Update-UserById" />
                </ModifiedBy>
            </Property>
            
            <!-- Several other properties -->
                        
        </Properties>

        <ReadConfiguration>
            <ListingCommand Command="Get-AllUsers">
            </ListingCommand>
            <CommandSequence>
                <Item Command="Get-UserById" Order="1" >
                </Item>
            </CommandSequence>
        </ReadConfiguration>

        
        <MethodConfiguration>
            <!--Insert, Update, Delete-->
        </MethodConfiguration>
    </Class>
</Schema>

Parents
  • Hi Are Sandnes,

    Sorry to disturb you I need some help in building a PowerShell connector.

    My definition file is as below.

    Form my custom command I get data in table format but now I am stuck on how can I get this data displayed in the target system browse window.

    I did something in the definition file but I get an error like "No Property personid found" when I browse data.

    Could you please help me here. Thank you.

    <?xml version="1.0" encoding="utf-8" ?>
    <!--
    Some header data definint the id, the version and the description of this connector
    -->
    <PowershellConnectorDefinition Id="SampleConnector" Version="1.0" Description="Sample Powershell Connector (AD)">

    <PluginAssemblies>
    <!--<Assembly Path="VI.Projector.Exchange.Common.dll" />-->
    </PluginAssemblies>

    <ConnectionParameters>

    <ConnectionParameter Name="Username" Description="Username for the API" />
    <ConnectionParameter Name="Password" Description="Password" IsSensibleData="true" />

    </ConnectionParameters>

    <Initialization>

    <CustomCommands>

    <CustomCommand Name="Get-ApplicationGetUsers">
    <![CDATA[
    $User1 = "******"
    $Password1 = "******"
    $base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("$($User1):$($Password1)"))

    $Body = "{""expiration"": -1}"
    $Headers = @{'Content-Type' = 'application/json'
    'MAXAUTH' = $base64AuthInfo
    'Ocp-Apim-Subscription-Key' = 'fc7309d56acf4ae68158b7b58787ce9f'}
    $Outputvalue = Invoke-RestMethod -Uri 'https://<servername>/create?' -Body $Body -Method Post -Headers $Headers

    $apikeyval = $Outputvalue.apikey
    $Headers = @{'Content-Type' = 'application/json'
    'apikey' = $apikeyval
    'Ocp-Apim-Subscription-Key' = 'fc7309d56acf4ae68158b7b58787ce9f'}
    $Outputvalue1 = Invoke-RestMethod -Uri 'https://<servername>/NTUSER_MAXUSER/NTUSER_MAXUSER?lean=1&querytemplate=NTUSER_BASIC&oslc.pageSize=11' -Method GET -Headers $Headers


    $Outputvalue1.member | Format-Table -Property personid, userid, loginid,status

    ]]>
    </CustomCommand>

    </CustomCommands>

    <PredefinedCommands>
    <Command Name="Get-AllUsers" />
    </PredefinedCommands>

    <EnvironmentInitialization>

    <!--
    Commands to be executed when the powershell runspace is created
    -->
    <Connect>

    <CommandSequence>
    <Item Command="Get-ApplicationGetUsers" Order="1">
    <SetParameter Param="User" Source="ConnectionParameter" Value="Username" />
    <SetParameter Param="Password" Source="ConnectionParameter" Value="Password" />
    </Item>
    </CommandSequence>
    </Connect>

    <!--
    Commands to be executed when the runspace is closed (free resources etc.)
    -->
    <Disconnect>
    <CommandSequence>
    <Item Command="Get-ApplicationGetUsers" Order="1" />
    </CommandSequence>
    </Disconnect>

    </EnvironmentInitialization>
    </Initialization>


    <Schema>

    <Class Name="member">

    <Properties>

    <Property Name="personid" DataType="String" IsUniqueKey="true" IsDisplay="true" IsMandatory="true" IsAutoFill="false">
    <ReturnBindings>
    <Bind CommandResultOf="Get-ApplicationGetUsers" Path="personid" />
    </ReturnBindings>
    </Property>

    </Properties>

    <ReadConfiguration>
    <ListingCommand Command="Get-ApplicationGetUsers">
    </ListingCommand>
    <CommandSequence>
    <Item Command="Get-ApplicationGetUsers" Order="1" >
    <SetParameter Param="Properties" Source="FixedArray" Value="personid" />
    </Item>
    </CommandSequence>
    </ReadConfiguration>

    </Class>

    </Schema>

    </PowershellConnectorDefinition>

Reply
  • Hi Are Sandnes,

    Sorry to disturb you I need some help in building a PowerShell connector.

    My definition file is as below.

    Form my custom command I get data in table format but now I am stuck on how can I get this data displayed in the target system browse window.

    I did something in the definition file but I get an error like "No Property personid found" when I browse data.

    Could you please help me here. Thank you.

    <?xml version="1.0" encoding="utf-8" ?>
    <!--
    Some header data definint the id, the version and the description of this connector
    -->
    <PowershellConnectorDefinition Id="SampleConnector" Version="1.0" Description="Sample Powershell Connector (AD)">

    <PluginAssemblies>
    <!--<Assembly Path="VI.Projector.Exchange.Common.dll" />-->
    </PluginAssemblies>

    <ConnectionParameters>

    <ConnectionParameter Name="Username" Description="Username for the API" />
    <ConnectionParameter Name="Password" Description="Password" IsSensibleData="true" />

    </ConnectionParameters>

    <Initialization>

    <CustomCommands>

    <CustomCommand Name="Get-ApplicationGetUsers">
    <![CDATA[
    $User1 = "******"
    $Password1 = "******"
    $base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("$($User1):$($Password1)"))

    $Body = "{""expiration"": -1}"
    $Headers = @{'Content-Type' = 'application/json'
    'MAXAUTH' = $base64AuthInfo
    'Ocp-Apim-Subscription-Key' = 'fc7309d56acf4ae68158b7b58787ce9f'}
    $Outputvalue = Invoke-RestMethod -Uri 'https://<servername>/create?' -Body $Body -Method Post -Headers $Headers

    $apikeyval = $Outputvalue.apikey
    $Headers = @{'Content-Type' = 'application/json'
    'apikey' = $apikeyval
    'Ocp-Apim-Subscription-Key' = 'fc7309d56acf4ae68158b7b58787ce9f'}
    $Outputvalue1 = Invoke-RestMethod -Uri 'https://<servername>/NTUSER_MAXUSER/NTUSER_MAXUSER?lean=1&querytemplate=NTUSER_BASIC&oslc.pageSize=11' -Method GET -Headers $Headers


    $Outputvalue1.member | Format-Table -Property personid, userid, loginid,status

    ]]>
    </CustomCommand>

    </CustomCommands>

    <PredefinedCommands>
    <Command Name="Get-AllUsers" />
    </PredefinedCommands>

    <EnvironmentInitialization>

    <!--
    Commands to be executed when the powershell runspace is created
    -->
    <Connect>

    <CommandSequence>
    <Item Command="Get-ApplicationGetUsers" Order="1">
    <SetParameter Param="User" Source="ConnectionParameter" Value="Username" />
    <SetParameter Param="Password" Source="ConnectionParameter" Value="Password" />
    </Item>
    </CommandSequence>
    </Connect>

    <!--
    Commands to be executed when the runspace is closed (free resources etc.)
    -->
    <Disconnect>
    <CommandSequence>
    <Item Command="Get-ApplicationGetUsers" Order="1" />
    </CommandSequence>
    </Disconnect>

    </EnvironmentInitialization>
    </Initialization>


    <Schema>

    <Class Name="member">

    <Properties>

    <Property Name="personid" DataType="String" IsUniqueKey="true" IsDisplay="true" IsMandatory="true" IsAutoFill="false">
    <ReturnBindings>
    <Bind CommandResultOf="Get-ApplicationGetUsers" Path="personid" />
    </ReturnBindings>
    </Property>

    </Properties>

    <ReadConfiguration>
    <ListingCommand Command="Get-ApplicationGetUsers">
    </ListingCommand>
    <CommandSequence>
    <Item Command="Get-ApplicationGetUsers" Order="1" >
    <SetParameter Param="Properties" Source="FixedArray" Value="personid" />
    </Item>
    </CommandSequence>
    </ReadConfiguration>

    </Class>

    </Schema>

    </PowershellConnectorDefinition>

Children
No Data