We have images stored in a SQL database as the image datatype. I need to pull these images out of the SQL Table and save them as a .jpg file. I have been able to pull the data from SQL but cant figure out how to save it as normal image file. With a bit of search and cut\paste I have ended up with the following. Not sure if I am on the right path here but saving the data into a Memory Stream and then trying to save that as an image with System.drawing.image. Currently stuck on using the System.drawing.image with the following error message. Thanks.
Exception calling "FromStream" with "1" argument(s): "Parameter is not valid."
$Result = $ds.tables[0].Rows[1]
$bytes = $Result.LNL_BLOB
[void][reflection.assembly]::LoadWithPartialName("System.IO")
$memoryStream = new-object System.IO.MemoryStream
$memoryStream.write($bytes,78,$bytes.Length - 78)
## on down cant seem to figure out how to use system.drawing.image
[void][reflection.assembly]::LoadWithPartialName("System.Drawing")
$Image = [System.Drawing.Image]::FromStream