vendredi 28 septembre 2018

Workaround for piping to an if-statement in powershell?

I wanted to pipe an object to a PowerShell if-statement, but it doesn't work:

for($i = 1; $i -le 70; $i++) {
    Get-AzureRmRedisCache -Name "isi$i" -ResourceGroupName "iaas101" | if ($_.ProvisioningState -eq 'Succeeded') {
    Remove-AzureRmRedisCache $_ -Force
}}

"The term 'if' is not recognized as the name of a cmdlet, function, script file, or operable program". So what should I do instead?

Aucun commentaire:

Enregistrer un commentaire