Посмотрите описание get-help Export-Csv
. Это говорит -
DESCRIPTION
The Export-CSV cmdlet creates a CSV file of the objects that you submit. Each object is represented as a line or
row of the CSV. The row consists of a comma-separated list of the values of object properties. You can use this
cmdlet to create spreadsheets and share data with programs that take CSV files as input.
Do not format objects before sending them to the Export-CSV cmdlet. If you do, the format properties are
represented in the CSV file, instead of the properties of the original objects. To export only selected properties
of an object, use the Select-Object cmdlet.
Прочитайте строку, которая говорит - Строка состоит из разделенного запятыми списка значений свойств объекта . Случайные числа, которые вы видите, - это длина свойств, которые вы экспортировали в CSV.
Чтобы преодолеть это, вы можете использовать PSCustomObject
вот так -
$array= @()
dir IIS:\AppPools | ForEach-Object {
$obj = New-Object PSObject
$Name = Add-Member -MemberType NoteProperty -Name "Name" $_.Name
$managedRuntimeVersion = Add-Member -MemberType NoteProperty -Name "managedRuntimeVersion" $_.managedRuntimeVersion
.
.
#Rest of your properties
$array += $obj
}
$array | Export-Csv C:\bob.csv -NoTypeInformation
Снова к вашему вопросу, что вы делаете не так -
- Непонимание правильного типа ввода командлета
Export-Csv
.
- Использование
Exportto-Csv
вместо Export-Csv
. Я очень сомневаюсь, что существует командлет с именем Exportto-Csv
. Хотите знать, как вы получили результаты.
- Кодирование, когда ты злишься!