none
Hi Ed, I need help with passing a csv file as pipeline to a command.

    Question

  • I have a csv file with 2 property, BrowserName and Accounts. The Accounts property has multiple comma separated values. I need to pipe the csv file to another cmdlet which accepts pipeline value by propertyname. The issue is when I import the csv file and pipe it to the cmdlet, the Accounts property is not resolving the account name because it is parsing all the values as single string instead of multiple values. Both the parameters are positional parameters and excepts string values.

    Below is the content of the CSV file.

    #TYPE Selected.Citrix.XenApp.Commands.XAApplicationReport
    "BrowserName","Accounts"
    "Webmail752F","Domain\09143635,Domain\09145288,Domain\09181294,Domain\09107673,Domain\09159672"

    After importing the file using import-csv and piping it to Add-XAApplicationAccount, I get the below error.

    Add-XAApplicationAccount : Error resolving account Domain\09143635,Domain\09145288,Domain\09181294,Domain\09107673,Domain\09159672
    (0x80320007)
    At line:1 char:52
    + Import-Csv .\testing.csv | Add-XAApplicationAccount <<<<
        + CategoryInfo          : ObjectNotFound: (Domain\09143635...Domain\09159672:String) [Add-XAApplicationAccount], C
       itrixException
        + FullyQualifiedErrorId : BatchResolveAccountNameToDN,Citrix.XenApp.Commands.AddAppAccountCmdlet<o:p></o:p>

    How to I go about fixing this. Please let me know if you need more information.<o:p></o:p>



    • Edited by Jain.Mayank Thursday, November 09, 2017 11:09 AM
    Thursday, November 09, 2017 11:07 AM

Answers

  • You can only pass a CSV into a pipeline if the next command can receive the CSV properties by name from the pipeline.

    Since you are using Citrix commands you need to post in the Citrix forum.

    Also read the error very carefully.  It is telling you that the account specified cannot be found.


    \_(ツ)_/

    Monday, November 13, 2017 6:47 PM

All replies

  • You might get better/faster results if you ask this in a Citrix forum: https://discussions.citrix.com/

    A quick search brings up this: https://discussions.citrix.com/topic/252759-errors-using-add-xaapplicationaccount/

    Additionally I would recommend that you create your csv file using the parameter "-NoTypeInformation". That eleminiates the needless header line.

    BTW: When you post code or error messages please use the code formatting tool from the editor. That way it's easier to read and avoids unwanted line breaks.


    Best regards (79,108,97,102|%{[char]$_})-join''




    • Edited by BOfH_666 Thursday, November 09, 2017 3:05 PM
    Thursday, November 09, 2017 12:54 PM
  • $accounts = $csv.Accounts -split ','

    This will give you an array of accounts.  Do this for each record in the csv

    Import-Csv file.csv |
         ForEach-Object{
              $_.Accounts -split ','
         }


    \_(ツ)_/

    • Proposed as answer by BOfH_666 Saturday, November 11, 2017 1:30 PM
    Friday, November 10, 2017 1:09 AM
  • I would remove TYPE Selected.Citrix.XenApp.Commands.XAApplicationReport from first line

    Thanks & Regards Ramandeep Singh

    Saturday, November 11, 2017 6:12 AM
  • I would remove TYPE Selected.Citrix.XenApp.Commands.XAApplicationReport from first line

    Thanks & Regards Ramandeep Singh

    The TYPE line has no effect on the ability to import a CSV in PowerShell.  It just sets the type of object to be created.  This can be very useful.


    \_(ツ)_/

    Saturday, November 11, 2017 6:30 AM
  • This did not work. Still getting the same error..
    Monday, November 13, 2017 12:05 PM
  • You can only pass a CSV into a pipeline if the next command can receive the CSV properties by name from the pipeline.

    Since you are using Citrix commands you need to post in the Citrix forum.

    Also read the error very carefully.  It is telling you that the account specified cannot be found.


    \_(ツ)_/

    Monday, November 13, 2017 6:47 PM