SOLVED

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

%3CLINGO-SUB%20id%3D%22lingo-sub-1594515%22%20slang%3D%22en-US%22%3EHow%20to%20delete%20rows%20in%20Azure%20using%20Like%20(and%20wildcard)%20in%20Az%20model%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1594515%22%20slang%3D%22en-US%22%3E%3CP%3EHow%20can%20I%20delete%20all%20the%20rows%20in%20a%20table%20where%20it%20is%20a%20like%20a%20wildcard%20(*)%20and%20a%20Like%3F%26nbsp%3B%20I%20am%20using%20Powershell%207.%26nbsp%3B%20In%20Powershell%205%2C%20there%20was%20a%20cmdlet%20where%20you%20could%20use%20%22like%22%20and%20a%20%22*%22%20on%20the%20end.%20Unfortunately%2C%20the%20Powershell%207%26nbsp%3B%20Az%20model%20only%20has%20%22%3CSPAN%3E-operator%26nbsp%3BEqual%3C%2FSPAN%3E%22%20in%20it.%26nbsp%3B%20I%20would%20love%20to%20put%20a%20%22*%22%20on%20the%20end%20of%20%24ObjectName%20and%20have%20operator%20Like%20instead%20of%20Equal.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%0A%3CDIV%3E%3CSPAN%3E%24ctx%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3D%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3ENew-AzStorageContext%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B-StorageAccountName%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%24storageAccountName%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B-StorageAccountKey%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%24storageKey%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3E%24tableName%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3D%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22craconnectiontable%22%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3E%24storageTable%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3D%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EGet-AzStorageTable%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B-Name%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%24tableName%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B-Context%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%24ctx%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3EGet-AzTableRow%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B-table%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%24storageTable%3C%2FSPAN%3E%3CSPAN%3E.CloudTable%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B-columnName%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22PartitionKey%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B-value%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%24ObjectName%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B-operator%26nbsp%3BEqual%26nbsp%3B%7C%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3ERemove-AzTableRow%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B-table%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%24storageTable%3C%2FSPAN%3E%3CSPAN%3E.CloudTable%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3EThanks%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3EDarren%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1594515%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EWindows%20PowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1596861%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20delete%20rows%20in%20Azure%20using%20Like%20(and%20wildcard)%20in%20Az%20model%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1596861%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F762482%22%20target%3D%22_blank%22%3E%40darrenge%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EGot%20a%20solution%20from%20a%20coworker%20...%3C%2FP%3E%0A%3CP%3EGet-AzTableRow%20-table%20%24storageTable.CloudTable%20%7C%20Where-Object%20-Property%20%E2%80%9CPartitionKey%E2%80%9D%20-CLike%20%3CSPAN%3E%24ObjectName%26nbsp%3B%22%3C%2FSPAN%3E*%E2%80%9D%20%7C%20Remove-AzTableRow%20-table%20%24storageTable.CloudTable%3C%2FP%3E%3C%2FLINGO-BODY%3E
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