Author Posts

January 20, 2017 at 10:26 pm

Invoke-Command -ComputerName SERVERNAME -ScriptBlock {Import-Module 'WebAdministration'; Get-ChildItem -Path IIS:\Sites}

When I use this command on all Win2012 R2 servers and 90% of Win2008 R2 I get information back from remote servers. But on a couple of Win2008 R2 I don't get an error I just get the PS> prompt with no info. What needs to be turned on these Win2008 R2 to get the information. Enable-Remoting -Force is turned on. I did a WinRM Quickconfig but nothing. I've compared the Win2008 R2 servers that work with the ones that don't work and can't seem to find the difference.

Thanks

January 20, 2017 at 10:28 pm

Well... we need to maybe troubleshoot. You've run a lot of stuff but I'm not sure if it's helping or hurting.

On one of the not-working machines, can you just

Invoke-Command -ComputerName WHATEVER -Script { Dir c:\ }

And get results?

January 20, 2017 at 10:31 pm

Yes, I got a directory of info on the remote server.

January 20, 2017 at 10:33 pm

OK, great. So Remoting is fine. All that Enable-PSRemoting and WSMan Quickconfig was for naught ;).

The problem, then, is with WebAdministration. Are you able to log on to one of those servers' consoles and run:

Import-Module 'WebAdministration'
Get-ChildItem -Path IIS:\Sites

And get anything? Whilst making a note of the user account you use to do this?

January 20, 2017 at 10:37 pm

Import-Module worked with no errors and Get-Childitems returned what I was looking for using the Invoke-Command.

January 20, 2017 at 10:39 pm

EXCELLENT. Now we're making progress. The components all work, just not together. I'm assuming that one of the following two are true, but I want you to confirm:

1. When you run Invoke-Command, you're logged onto your computer as the same user that you just used to log onto the servers' consoles, and your computer and the servers are all in the same domain or in trusting domains

OR

2. When you run Invoke-Command, you specify -Credential and provide the same username that you just used to log onto the servers' consoles.

Is one or both of these true?

January 20, 2017 at 10:42 pm

1. Yes
2. I don't provide -Credentials because my credentials are Admin credentials and I don't use -Credentials for the 40 servers that work okay.

January 20, 2017 at 10:44 pm

I know you don't do this for the ones that are working, but these ones aren't working, so we take some extra steps to try and pinpoint the problem. One potential problem is credential delegation not working for some reason; were you to try #2 and explicitly provide a credential, it'd eliminate that as a possibility. We've already determined that Remoting is fine, and that the WebAdministration module works. So we have to start branching out and testing other things.

Additionally, try using Enter-PSSession to connect to a non-working server, load WebAdministration and try your IIS: drive. Do you get results, or still just a blank prompt, or maybe an error message? You can do this with or without -Credential.

January 20, 2017 at 10:47 pm

Can you give me the Enter-PSSession commands / load WebAdministration command you want me to enter so I can do exactly like you want.

January 20, 2017 at 10:49 pm

Yup!

Enter-PSSession -ComputerName WHATEVER
Import-Module 'WebAdministration'
Get-ChildItem -Path IIS:\Sites
Exit

January 20, 2017 at 10:53 pm

Everything worked like a charm and I got results.

January 20, 2017 at 10:56 pm

Well. That is odd.

Invoke-Command -ComputerName WHATEVER -Script { Import-Module 'WebAdministration'; Start-Sleep 5000; Get-ChildItem -Path IIS:\Sites }

How about that? See, Enter-PSSession and Invoke-Command do the exact same thing, in the same way. Enter-PSSession wasn't supposed to work. The only thing I can think of is some kind of timing in WebAdministration loading, so I'm having you try Start-Sleep.

January 20, 2017 at 10:58 pm

No error... just came back with a Prompt again.

January 21, 2017 at 7:01 am

Kind of sheepish here, because I'm new, but could you run the following code?

Invoke-Commmand -ComputerName Computer -ScriptBlock {([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")}

If that returns false, you may be running into a weird UAC issue. Might try running your console as administrator and giving the code above another try. Should return true if you have elevated rights (which is needed to import the WebAdministration Module).

January 24, 2017 at 3:18 am

I solved half the problem. It must be a firewall issue. I RDP into another server and ran the invoke-command to all the servers that showed just a prompt and it worked fine. I got the results. My PC from home via VPN must be blocking results from these servers.

Derek

January 24, 2017 at 3:19 am

I got a TRUE results... as mentioned on another reply .....

I solved half the problem. It must be a firewall issue. I RDP into another server and ran the invoke-command to all the servers that showed just a prompt and it worked fine. I got the results. My PC from home via VPN must be blocking results from these servers.

Derek