I have a two envirment a dev envirment and a prod envirement, I have built a Powershell script to get the xml text of an infopath item inside a form library it works fine in the dev envirment but when i have tried it in the prod envirment, it send back an error message that indicate the File field of the item is null, is that possible with InfoPath ? In the full script I can edit a field of an infopath item with powershell.
#Params
$WebURL = Read-Host 'WebURL '
$InfoPathLibraryName = Read-Host 'InfoPathLibraryName '
$ItemID = Read-Host 'ItemID '
#Get Objects
$web = Get-SPWeb $WebURL
$InfoPathLibrary = $web.Lists[$InfoPathLibraryName]
$Item = $InfoPathLibrary.GetItemById($ItemID)
Write-Output $Item
#Execution
$file = $Item.File
$data = $file.OpenBinary()
$encode = New-Object System.Text.UTF8Encoding
$uu = $encode.GetString($data)
Write-Output $uu
Were you able to retrieve the list $Item correctly? Try below :
$Item = $InfoPathLibrary.GetItemById(Convert.ToInt32($ItemID))