问题
Lets say I have retrieved an entity from my table. I want to set one of the property to null. How can I do it? This is what I did:
$myData.PropertyOne = $null
$myData | Update-AzureStorageTableRow -table $destStorageTable
But I got error:
Exception calling "Execute" with "1" argument(s): "Object reference not set to an instance of an object." At C:\Program Files\WindowsPowerShell\Modules\AzureRmStorageTable\1.0.0.21\AzureRmStorageTableCoreHelper.psm1:629 char:13 + ... return ($table.CloudTable.Execute((invoke-expression "[Microsoft ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : StorageException
回答1:
How can I do it?
The problem is that because azure table storage does not have a schema, the null column actually doesn't exist. You could do something like store an empty string if you really have to.
$myData.PropertyOne = ""
$myData | Update-AzureStorageTableRow -table $destStorageTable
回答2:
I think you need to remove the column -
$myData.psobject.Properties.Remove('PropertyOne')
$myData | Update-AzureStorageTableRow -table $destStorageTable
来源:https://stackoverflow.com/questions/48339835/how-to-use-powershell-to-update-property-of-an-entity-in-azure-table-storage-to