13 Replies Latest reply on Oct 20, 2014 3:36 PM by Steve Cupp

    enable Powershell remoting

      Share This:

      Hi All,


      I am trying to enable powershell remoting on servers in the estate.  Command to execute nativly is:

      powershell enable-psremoting -force


      All attempts to get this to work from within BL have failed, including wrapping the command in a batch file with a deploy and execute.  Errors along the lines of access denied, probably because this command must be run from an admin shell.  Has anyone found a solution?  A suggestion for me to test?


      Thanks in advance!

        • 1. enable Powershell remoting

          What are the failures ?

          What is the user mapping ?

          Which windows version ?


          • 2. Re: enable Powershell remoting

            Haha Rohit


            I suspect that by design, this command needs to be run in an administrator shell and hence challenging to automate (by design they dont want some remote execution capabilities as it changes firewall settings etc)


            Errors suggest permissions.

            This fails with following error: Error   Nov 4, 2011 2:57:07 PM   Command returned non-zero exit code: 1
            1       Enable PSRemoting Warning Nov 4, 2011 2:57:07 PM     ickConfigCommand
                            Warning Nov 4, 2011 2:57:07 PM      + FullyQualifiedErrorId : WsManError,Microsoft.WSMan.Management.SetWSManQu
                            Warning Nov 4, 2011 2:57:07 PM     validOperationException
                            Warning Nov 4, 2011 2:57:07 PM      + CategoryInfo          : InvalidOperation: (:) [Set-WSManQuickConfig], In
                            Warning Nov 4, 2011 2:57:07 PM  +             Set-WSManQuickConfig <<<<  -force
                            Warning Nov 4, 2011 2:57:07 PM  At line:50 char:33
                            Warning Nov 4, 2011 2:57:07 PM   [stderr: 1]    Set-WSManQuickConfig : Access is denied.
            1       Enable PSRemoting


            Its possible that this can not be executed from BL - what do you think?


            edit to say all agents map to the local admin

            • 3. enable Powershell remoting

              Have your tried running the command locally on  the box with the same local admin ?

              does that work ?

              Is the machine added to a domain ?

              This can be the local security setting disallowing local admin on the boxes to this ?

              I think if you can do it with a user on the box, you can do it using BL as well mapped as the user ?

              Which windows version is this ?



              (BL Should do be able to do such stuff !! win2k8 did give us such problems, but automation principals works well with domain accounts which did help in win2k8).




              • 4. enable Powershell remoting

                Yes I can run it locally no problems.

                • 5. enable Powershell remoting

                  Quick Solution, switch to Unix platforms ! Forget Windows and Powershell, use Network Shell !

                  • 6. Re: enable Powershell remoting

                    Has anyone figured this one out yet? I'm running into the same problem...access denied...everything runs fine locally.



                    • 7. Re: enable Powershell remoting
                      Bill Robinson

                      what user are you mapped to and is that an administrator ?


                      what object are you trying to access w/ powershell ?

                      • 8. Re: enable Powershell remoting

                        I am mapped to the local administrator account using users.local. I am trying to use BSA to run a powershell command:  "enable-psremoting -force". Every other powershell command seems to work, including "set-executionpolicy remotesigned". I suspect it is a security feature of powershell, but you'd think BSA could run it under a local context, and hide the fact that it is running remotely.


                        I just want to pass the powershell command "enable-psremoting -force" to each server.



                        • 9. Re: enable Powershell remoting
                          Jim Campbell

                          For whatever reason I had to run this as a domain user in our server build process.  User mapping with the local administrator didn't work but it worked when run using an automation principal.  I never tried to figure out why.

                          • 10. Re: enable Powershell remoting
                            Bill Robinson

                            Probably the way user impersonation works might cause this.

                            • 11. Re: enable Powershell remoting

                              I finally got this working using "scheduled tasks", or schtasks.


                              I created an "empty" blpackage that runs the following external commands, separately...


                              schtasks /create /tn "bsa enable psremoting" /tr "powershell enable-psremoting -force" /sc once /st 19:00 /ru SYSTEM

                              schtasks /run /tn "bsa enable psremoting"

                              powershell -command "& {start-sleep -s 60}"

                              schtasks /delete /tn "bsa enable psremoting" /f


                              First line creates a scheduled task, scheduled once for 7p. The 7p time is just a dummy time. Notice it runs as SYSTEM.

                              Second line runs the task NOW.

                              Third line waits 60 seconds...Server 2003 doesn't like the scheduled task disappearing before it is done. 2008 doesn't seem to care.

                              Last line deletes the task.



                              1 of 1 people found this helpful
                              • 12. Re: enable Powershell remoting
                                Joe Piotrowski

                                Thanks for sharing that Chris.

                                • 13. Re: enable Powershell remoting
                                  Steve Cupp

                                  Hey Chris. . your solution worked GREAT!!!! I was pulling my hair out over this psremoting thing. Thx for sharing this very helpful solution.