Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8442093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:45:19+00:00 2026-06-10T08:45:19+00:00

I have this file which I want to read with PowerShell: var myMap =

  • 0

I have this file which I want to read with PowerShell:

var myMap =
[
  {
    "name": "JSON Example",
    "attr": "Another attribute"
  }
]

My PowerShell v3 Code:

$str = Get-Content $file | Select -Skip 1;
$str | ConvertFrom-Json;

But I’m always getting this error:

ConvertFrom-Json : Invalid array passed in, ']' expected. (1): [
At S:\ome\Path\script.ps1:60 char:8
+ $str | ConvertFrom-Json;
+        ~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [ConvertFrom-Json], ArgumentException
    + FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.ConvertFromJsonCommand

If I copy and paste the JSON code manually into the code, everything is working fine:

'[
  {
    "name": "JSON Example",
    "attr": "Another attribute"
  }
]' | ConvertFrom-Json;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T08:45:21+00:00Added an answer on June 10, 2026 at 8:45 am

    Try to pipe to Out-String before piping to ConvertFrom-Json:

    Get-Content $file | Select -Skip 1 | Out-String | ConvertFrom-Json
    

    In your working example the JSON code is a string while the non-working example returns a collection of lines. Piping to Out-String converts the collection to a single string, which is what the InputObject parameter accept.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this file file.txt which I want to split into many smaller ones.
I have this file which I need to read the first bytes to check
I have this xml file which has text init. i.e Hi my name is
I have a text file which contains something like this: Hello, my name is
I have a .txt file with product data, which I want to read in
I have an xml file in which i want to read the child nodes
I have this structure which I want to write to a file: typedef struct
I have the following XML file with page nodes which I want to read
I have this text file acmst501:57:Runningacmst506:201:Runningacmst506:203:Runningacmst506:209:Runningacmst506:213:Failed which I want to split with delimiters. I
I have utf-8 file which I want to read and display in my java

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.