Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Reply To: What am I doing wrong?

$
0
0

% 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.


Viewing all articles
Browse latest Browse all 13067

Trending Articles