Management

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 785 other subscribers

Social

  • LinkedIn
  • RSS Feed for Posts
  • Twitter
  • StumbleUpon

Powershell: Array doesn’t show multiple items, it shows only one item.

When creating a array you might get a different result than expected.

Sometime the Array show only one item instead of multiple items.

Create a array:

$FileArray = “”

 $FileArray = $FileArray + “Test1.html”

$FileArray = $FileArray + “Test2.html”

$FileArray = $FileArray + “Test3.html”

 $FileArray

 

The result is 1 item and not 3 items as expected.

Adding item count to verify the array :

$ItemNumber = $FileArray.count

Changing the start of the array to : $FileArray = @()

Script:

$FileArray = @()

$FileArray = $FileArray + “Test1.html”

$FileArray = $FileArray + “Test2.html”

$FileArray = $FileArray + “Test3.html”

$FileArray

$ItemNumber = $FileArray.count

Write-Host “The number of items = $ItemNumber”

 


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.