Forum Discussion
darrenge
Aug 17, 2020Microsoft
How to delete rows in Azure using Like (and wildcard) in Az model
How can I delete all the rows in a table where it is a like a wildcard (*) and a Like? I am using Powershell 7. In Powershell 5, there was a cmdlet where you could use "like" and a "*" on the end. Unfortunately, the Powershell 7 Az model only has "-operator Equal" in it. I would love to put a "*" on the end of $ObjectName and have operator Like instead of Equal.
$ctx = New-AzStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageKey
$tableName = "craconnectiontable"
$storageTable = Get-AzStorageTable -Name $tableName -Context $ctx
Get-AzTableRow -table $storageTable.CloudTable -columnName "PartitionKey" -value $ObjectName -operator Equal | Remove-AzTableRow -table $storageTable.CloudTable
Thanks
Darren
Got a solution from a coworker ...
Get-AzTableRow -table $storageTable.CloudTable | Where-Object -Property “PartitionKey” -CLike $ObjectName "*” | Remove-AzTableRow -table $storageTable.CloudTable