Yes there is only one machine name per line in the text file.
As for permissions I use the same creds to RDP into the same machines and it works fine the account I am using it a domain account that is added to the local administrators group of all the devices in out Domain.
So I am not sure why it would not work due to permissions.
They are all pingable with the host names. I have another script to ping the devices to check or should I say test the connection before I ever run this script to enable PSRemoting. All are online and as I stated before from my computer I can use RDP with the machine name and connect and log into each device if I tried them all I have connected to about 8 of the devices successfully. I have not however tried to enable PSRemoting by using their IP addresses I suppose it is worth a shot. I will do that in the morning and see what happens with a few.
CategoryInfo : NotSpecified: (The handle is invalid.:String) , RemoteException
FullyQualifiedErrorId : NativeCommandError
Connecting to 172.16.94.93…
Couldn’t access 172.16.94.93:
Connecting to 172.16.94.93…
Does anyone have a script that they have successfully used to enable PSRemoting on Windows devices on their network that I can use as a template?
My problem is when I try to install software via PowerShell remotely it fails with an error about WSMAN not being enabled so I try to enable PSRemoting which I was instructed to do and get this error of psexec : The handle is invalid.
I believe this is a PSExec issue, probably permissions related. Couple of questions is the computer your are running the script from on the same domain? If so, are you using domain account that is in the admin group?
Another option you might try is to just use the Get-Service cmdlet to start the WinRM service on the remote computers. That cmdlet does not require Windows PowerShell remoting to function remotely.
Error:
VERBOSE: Performing the operation “Start-Service” on target “Windows Remote Management (WS-Management) (WinR
M)”.
Start-Service : Service ‘Windows Remote Management (WS-Management) (WinRM)’ cannot be started due to the
following error: Cannot open WinRM service on computer ‘.’.
At line:6 char:40
… ach ($Computer in $Computers) {Start-Service -Name WinRM -Verbose}
You can’t start the service remotely with just Start-Service because that cmdlet doesn’t have a computername parameter. You need to do it just like my last post (use Get-Service and pipe to Start-Service). There is no need to create a credential object either because Get-Service remoting will be based on the credentials you are running PowerShell locally. If you need to use different credentials, start PowerShell with the runas utility and the /netonly switch.
If you still get an error, please post it and I’ll see if I can help.
If you need to run with different credentials (use the runas utility), open cmd.exe and do this to open PowerShell or the ISE (whichever one you want to use) and then run the commands above in the new console.