Hello,
I'm trying to write some data to an SQL database using Write-SqlTableData.
I've tried the following code
$path = 'D:\';
$pathobject = [PSCustomObject] @{message = "Directories within $path"}
Write-SqlTableData -ServerInstance $server -credential $PSCredential -DatabaseName "log" -SchemaName "dbo" -TableName "log" -Force -InputData $pathobject
I've also tried
$pathobject = [PSCustomObject] @{message = "Directories within $path" } $pathobject| Select-Object -Property message | Write-SqlTableData -ServerInstance $server -credential $PSCredential -DatabaseName "log" -SchemaName "dbo" -TableName "log" -Force
The code seems to work until it is piped to the Write-SqlTableData which doesn't seem to be accepting the note property as input. I initially tried just passing as a string but this didn't work either. No error is given but no data is written.
I looked at the documentation
https://learn.microsoft.com/en-us/powershell/module/sqlserver/write-sqltabledata?view=sqlserver-ps
and this lists System.String[] as an input (bottom of page)
Before I give up and use an alternative command to write to SQL I thought I would ask here. I can find no documentation clearly saying if a note property will be accepted as input.
Kind regards,
Tim