I have been able to create an array and store a list of fields, I am trying to convert this to a CSV file. However, I need all my outputs to be as a string. Currently I have text coming out as a string, however for example I need my note to come out as a string but it comes out as taxonomy value and not sure how to change this?
Below is my code I have just now:
# Get the web
$web = Get-SPWeb "specified_website"
# Get the target list
$list = $web.Lists["List_name"]
# Items used to hold the data
$Items = $list.Items
$array = @()
# Get all the items in the list
foreach ($item in $Items) {
$id = $item.id
Write-Host "Processing item number $id" -ForegroundColor Green
# every item has a Field e.g. my item has a title, etc.
foreach ($field in $item.Fields) {
# Get the type of the field
Write-Host $field.Type
# Print the field type out to a string
switch ($field.Type) {
"Text" { $msg = checkifTextisNull($item[$field.InternalName]) }
"Note" {
Write-Host $item[$field.InternalName] -ForegroundColor Cyan
}
"Lookup" { $item[$field.InternalName] -ForegroundColor Yellow }
"URL" { Write-Host $item[$field.InternalName] -ForegroundColor Magenta }
"Invalid" {
#Write-Host $item[$field.InternalName] -ForegroundColor Cyan
}
"Guid" { Write-Host $item[$field.InternalName]-ForegroundColor Yellow }
"Choice" { Write-Host $item[$field.InternalName] -ForegroundColor Cyan }
"Boolean" {
$msg = returnBooleanValue($item[$field.InternalName])
Write-Host $msg -ForegroundColor DarkCyan
}
"Computed" { Write-Host $item[$field.InternalName] -ForegroundColor White }
"Integer" {
Write-Host $item[$field.InternalName]
}
"User" { Write-Host $item[$field.InternalName] -ForegroundColor DarkGreen }
"DateTime" {
Write-Host $item[$field.InternalName] -ForegroundColor DarkGreen
}
"Number" { Write-Host $item[$field.InternalName] -ForegroundColor Yellow }
"Counter" { Write-Host $item[$field.InternalName] -ForegroundColor Green }
"Multi-Choice" {
Write-Host $item[$field.InternalName]
}
"Attachments" { Write-Host $item[$field.InternalName] -ForegroundColor Magenta }
"ModStat" { Write-Host $item[$field.InternalName] -ForegroundColor DarkGreen }
"File" { Write-Host $item[$field.InternalName] -ForegroundColor White }
}
}
# Add the object with property to Items
$array += $Items
}
My output that I get is:
Note
Firm wide|0d3fbace-af9c-4f28-8be1-095e616893c0
And the Output I would expect is:
"FieldName", "DataType", "Value"
Site_type_0, Note , Firm Wide
When I Write out what the type of data is, I get taxonomy data, when I would want a string