I'm putting together a Powershell script that will recycle all currently running AppPools at a scheduled time early in the morning. For now I'm just trying to get it to work on a local machine and am getting an error "Cannot validate argument on Parameter 'Name'. The argument is null."

```
# Load IIS module:
Import-Module WebAdministration

# Get pool names:
$poolList = (Get-ChildItem -Path IIS:\AppPools | Where {$_.State -eq 
"Started"} | Select -ExpandProperty Name)

# Recycle Web App Pools
foreach ($item in $poolList)
{
Write-Host "Processing" $item -ForegroundColor Green
Invoke-Command -ComputerName localhost -ScriptBlock {Restart-WebAppPool -
Name $item}
}

```

When I run the script it cycles through each AppPool item. I see that with this line...

```
Write-Host "Processing" $item -ForegroundColor Green

```

...but the Invoke-Command says the parameter 'Name' is null. I'm sure I'm missing something simple but don't know what it is.

Thanks in advance for any and all help.