```
$snapin = Get-PSSnapin | Where-Object { $_.Name -eq "Microsoft.SharePoint.Powershell" } 
#This script enables a feature on every site collection on a given web app

if ($snapin -eq $null) 
{ 
    Add-PSSnapin "Microsoft.SharePoint.Powershell" 
}

. .\environment.ps1

$featureName = "XXX.Publishing_SiteDisplayTemplates"

Get-SPFeature | where { $_.DisplayName -like $featureName }
$featureID = Get-SPFeature | where { $_.DisplayName -like $featureName } | Select Id

Write-host "Site: " $hostUrlPowershell

 $sites =  get-spsite -webapplication $hostUrlPowershell -Limit ALL
 $feature = $featureName #this might not be what you expect it to be, best to do get-spfeature | Select displayname

  Foreach ($oneweb in $sites)
  {
    write-host $oneweb
    $siteFeature = get-spfeature -site $oneweb | Where {$_.displayname -eq $feature}
    if ($siteFeature -eq $null)
    {
      Write-Host "Feature is not activated on $oneweb" -foregroundcolor Yellow
      Enable-SPFeature -Identity $Feature -URL $oneweb.URL -Confirm:$False
      #Disable-SPFeature -Identity $Feature -URL $oneweb.URL -Confirm:$False
    }
    else
    {
      Write-Host "Feature $feature is already activated on $oneweb, reactivating feature" -foregroundcolor green
      Disable-SPFeature -Identity $Feature -URL $oneweb.URL -Confirm:$False
      Enable-SPFeature -Identity $Feature -URL $oneweb.URL -Confirm:$False

    }
  }

```

I'm trying to reactivate a feature so I get the newest display templates available. But it seems that Powershell is only disable SPFeature. How can I wait for Disable-SPFeature to be done before enable the feature?