% is an alias for ForEach-Object. I haven’t used these IIS-related commands before, but you may not need ForEach-Object at all. Try this (both in remoting and locally):
gci IIS:\apppools | Restart-WebAppPool Invoke-Command server {import-module WebAdministration; gci IIS:\apppools | Restart-WebAppPool } -cred $cred
If you do use ForEach-Object, then you need to do something with “$_” inside your script block, such as the gci IIS:\\apppools | % {Restart-WebAppPool $_.name} part of your second example.