Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I've the following result from a PowerShell array:
Level ----- 0
How can I convert it to an Int to retrieve only the value which is the number under the level?
$myArray.Level
$myArray | Select-Object -Expand Level
Like Ansgar said, use Select-Object with the -ExpandProperty parameter. I like that best as if .value isnt there for some reason it wont error out.
If it MUST be a INT then you can cast it like this:
[int]($MyArray | select -ExpandProperty Level)
Add a comment
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
$myArray.Levelshould do. What you're seeing is an object with a property (probably).$myArray | Select-Object -Expand Level.