SharePoint PowerShell to restart IIS on all your farm’s servers

This script will loop through the servers on your farm based on the server role , and will execute an IISreset on all servers matching the role.
$spserver = get-spserver | ?{$_.role -eq "custom"}  # you will need to change the custom based on ther server role ( front end, apppliation )
foreach ($server in $spserver) {
 write-host "Performing IIS Reset on Server:"$
  # option A  iisreset $server.Name 
  # option B
{Invoke-Command -ComputerName $_.Address {iisreset}}