SOLVED

How to delete rows in Azure using Like (and wildcard) in Az model

Microsoft

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
 
1 Reply
best response confirmed by darrenge (Microsoft)
Solution

@darrenge 

Got a solution from a coworker ...

Get-AzTableRow -table $storageTable.CloudTable | Where-Object -Property “PartitionKey” -CLike $ObjectName "*” | Remove-AzTableRow -table $storageTable.CloudTable

1 best response

Accepted Solutions
best response confirmed by darrenge (Microsoft)
Solution

@darrenge 

Got a solution from a coworker ...

Get-AzTableRow -table $storageTable.CloudTable | Where-Object -Property “PartitionKey” -CLike $ObjectName "*” | Remove-AzTableRow -table $storageTable.CloudTable

View solution in original post