Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Monday, March 27, 2017 7:08 PM
Hi...I would like to get Admin group members in multiple server 2008 R2 using powershell script that's mentioned below. Its working fine in server 2012
$Output = 'C:\temp\Result.txt'
$Servers= Get-Content 'C:\temp\ServerNames.txt'
$ScriptBlock = {
$Groups = Get-WmiObject Win32_GroupUser -ComputerName $Using:ServerName
$LocalAdmins = $Groups | Where GroupComponent –like '*"Administrators"'
$LocalAdmins | ForEach-Object {
If($_.partcomponent –match ".+Domain\=(.+)\,Name\=(.+)$"){
$matches[1].trim('"') + "\" + $matches[2].trim('"')
}
}
}
ForEach ($ServerName in $Servers) {
# 1. To get Local Administrators group Members
"Local Admin group members in $ServerName" | Out-File $Output -Append
Invoke-command -ScriptBlock $ScriptBlock -ComputerName $ServerName | Out-File $Output -Append
# 2. Local user information
Write-Output "Local user information" | out-file $Output -Append
Get-WmiObject -class Win32_UserAccount -ComputerName $Servers -Namespace "root\cimv2" -Filter "LocalAccount='True'" | out-file $Output -Append
}
But when I run in server 2008 R2, I am getting error as mentioned below, I also checked if Windows Remote Management (WS-Management) is running and its running. I also ran winrm quick config...
Any other suggestions would you like suggest for that script to connect to multiple remote server 2008 R2 servers.
Connecting to remote server failed with the following error message : The client cannot connect to the destination specified in the request. Verify that the service on the destination is running and is accepting requests. Consult the logs and documentation for the WS-Management service running on the destination, most commonly IIS or WinRM. If the destination is the WinRM service, run the following command on the destination to analyze and configure theWinRM service: "winrm quickconfig".
For more information, see the about_Remote_Troubleshooting Help topic.
+ CategoryInfo : OpenError: (:) [], PSRemotingTransportException
+ FullyQualifiedErrorId : PSSessionStateBroken
Pls let me know.
VT
All replies (6)
Monday, March 27, 2017 8:36 PM ✅Answered
You have to fix or enable remoting on the 2008 server.
\(ツ)_/
Tuesday, March 28, 2017 7:42 AM
Hi,
Please also checking if the firewall has allowed the access for remote access.
Best regards,
Andy
Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact [email protected].
Wednesday, March 29, 2017 1:43 PM
Thanks jrv & Andy_Pan...I will check and fix that...
VT
Wednesday, April 5, 2017 9:50 AM
Hi,
did this issue was solved? if not, please tell us the current situation, for further assistance.
Best regards,
Andy
Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact [email protected].
Tuesday, April 18, 2017 11:32 AM
Hi Andy...I am working towards enabling / fixing remoting on 2008 servers as jrv mentioned...I will update soon...Thanks for your assistance.
VT
Tuesday, April 25, 2017 1:11 AM
You have to fix or enable remoting on the 2008 server.
\(ツ)_/
Enable-PSRemoting –force worked fine. This enabled WinRM & configured Firewall exception. Thanks JRV & Andy.
VT