3

I am a beginner in PowerShell scripting.
I have tried to create a .Net object by executing the following command but it fails :

[System.Collections.Generic.List<System.String>]$myList = New-Object System.Collections.Generic.List<System.String>

An error message informs me the type [System.Collections.Generic.List] has not been found.
The error message also informs me I should check if the assembly containing the type is loaded.

I guess I have to load the assembly containing the type [System.Collections.Generic.List] but I do not know how to do it.

I also want to know from which .Net framework version I can use types in PowerShell.

Any help will be greatly appreciated

1 Answer 1

5

Wrong syntax. Types and Type parameters are delimited with square brackets, not angled ones.

$myList = New-Object 'System.Collections.Generic.List[System.String]'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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.

Ask question

Explore related questions

See similar questions with these tags.