Link to home
Start Free TrialLog in
Avatar of kuzum
kuzum

asked on

remote powershell script

Dear Experts,

I have windows 10 enterprise edition and my users are on win7.

I need to run PowerShell command on few specific workstations to enable windows feature remotely so that I do not need to do floor walking for each machine.

Could someone please validate this script;

Invoke-Command -ComputerName 10.0.0.22, 10.0.0.23, 10.0.0.24 -ScriptBlock { Enable-WindowsOptionalFeature -online  -FeatureName "ServicesForNFS-ClientOnly" } -credential my username
thank you
ASKER CERTIFIED SOLUTION
Avatar of Ben Personick (Previously QCubed)
Ben Personick (Previously QCubed)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kuzum
kuzum

ASKER

Hi Ben,
thanks for your time. I just had a chance to test this and had below error?

At line:8 char:8
+ Foreach $Computer in $Computers {
+        ~
Missing opening '(' after keyword 'foreach'.
At line:8 char:19
+ Foreach $Computer in $Computers {
+                   ~~
Unexpected token 'in' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : MissingOpenParenthesisAfterKeyword
Avatar of kuzum

ASKER

I think you it is a typo error as I passed this stage by Foreach ($Computer in $Computers)

I am having another issue with it wondering if you could help please.


[10.x.x.x] Connecting to remote server 10.215.235.14 failed with the following error message : The WinRM client cannot process
the request. Default authentication may be used with an IP address under the following conditions: the transport is HTTPS or the
destination is in the TrustedHosts list, and explicit credentials are provided. Use winrm.cmd to configure TrustedHosts. Note that
computers in the TrustedHosts list might not be authenticated. For more information on how to set TrustedHosts run the following
command: winrm help config. For more information, see the about_Remote_Troubleshooting Help topic.
    + CategoryInfo          : OpenError: (10.215.235.14:String) [], PSRemotingTransportException
    + FullyQualifiedErrorId : CannotUseIPAddress,PSSessionStateBroken
Avatar of kuzum

ASKER

Hi Ben,

apologies for multiple threads, it seems issue was caused by IP address and not using the hostname. I managed to resolve it by
using the hostname and now ended with this

Error: 50

The operation is complete but ClientForNFS-Infrastructure feature was not enabled.
A required parent feature may not be enabled. You can use the /enable-feature /all option to automatically enable each parent feature
from the following list. If the parent feature(s) are already enabled, refer to the log file for further diagnostics.
ServicesForNFS-ClientOnly

The DISM log file can be found at C:\WINDOWS\Logs\DISM\dism.log
Avatar of kuzum

ASKER

Hi Ben,

after few hours of troubleshooting I manage to get this script partially working. It does now tick the box but it leaves the sub box expty. How do I force it to select the box I need?
I attached the screenshot and this is where I am now.

thanks
Avatar of kuzum

ASKER

with attachment
Capture.PNG
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kuzum

ASKER

thanks Ben, it was helpful.
Glad to help, sorry I missed your messages, last night we welcomed our second child into the world. :)