I want to write a script that creates a directory which does not exist and create a file in that folder. The script should also be able to assign a value to the file. The following is my code, but it does not assign the value to the file. In this case, i'm trying to insert the array into the file.
$myarray=@()
for($x=0;$x -lt 20; $x++) {
$myarray += $x
}
New-Item -Path C:\temp -Force -Name myarray.log -ItemType File -Value $myarray
when I open the file, myarray.log all I see is 'System.Object[]' but not the array. Need some help here.