powershell as system account.

Welcome Forums General PowerShell Q&A powershell as system account.

Viewing 4 reply threads
  • Author
    Posts
    • #192757
      Participant
      Topics: 1
      Replies: 2
      Points: -2
      Rank: Member

      I’ve been scouring the internet and haven’t found a solution.

      Generally I can get around most things.  But the DFSR commandlets don’t take credential parameters.

      So trying to run powershell as the system account has me stuck.

      as such none of the DFSR commandlets work.  Import-module DFSR doesn’t work either.

      I can’t seem to use anything outside of psexec to run the powershell commands as the appropriate user but i’d rather not.

      Thoughts anyone?

      Module dump and errors below.

      C:\Program Files\WindowsPowerShell\Modules;WindowsPowerShell\Modules;C:\Program Files (x86)\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
      import-module : The specified module ‘C:\windows\system32\windowspowershell\v1.0\Modules\DFSR\DFSR.PSD1’ was not
      loaded because no valid module file was found in any module directory.

    • #192805
      Participant
      Topics: 13
      Replies: 1683
      Points: 2,849
      Helping Hand
      Rank: Community Hero

      There appears to be other posts with the same issue:

      https://serverfault.com/questions/979118/how-do-i-install-the-dfsr-module-for-powershell-on-windows-server-2012r2

      This post also indicates there is a personal DFSR module and official module installed via Windows. Confirm you are using the official module.

      Next, the error received is indicating that the module was not found or there was an error loading the module, which appears to be the latter based on the short name (e.g. DFSR) resolving to a path (e.g. C:\windows\system32\windowspowershell\v1.0\Modules\DFSR\DFSR.PSD1). This can be further confirmed by importing the module using the full path:

      Import-Module C:\windows\system32\windowspowershell\v1.0\Modules\DFSR\DFSR.PSD1
      

      Assuming that the module still does not load, there is most likely a bug or issue in the module itself. You’ve mentioned you are trying to launch the Powershell session as SYSTEM, are you just troubleshooting to see if it works or you’ve confirmed that importing the module as SYSTEM works successfully?

    • #192820
      Participant
      Topics: 1
      Replies: 2
      Points: -2
      Rank: Member

      I am using the stock windows DFSR module.

      Importing the module as the system account doesn’t work.  (when ran from the deployment tool)  But using psexec it does work.  (IE: manually typing import-module dfsr after doing psexec -s -i powershell.exe

      But importing the module as any other domain account works fine. if executing it from the deployment tool.

      Since the commands inside the module aren’t designed to take alternative credentials and the deployment tool i’m using starts as the system account on the machine my options are normally using psexec.  But i’m trying to get away from using psexec to execute powershell scripts.

      Every other module i’ve seen either Active Directory or DHCP has some mechanism to take alternative credentials except for DFS.

    • #192895
      Participant
      Topics: 13
      Replies: 1683
      Points: 2,849
      Helping Hand
      Rank: Community Hero

      The best option is having the SYSTEM account launch another Powershell session as the needed user:

      https://blogs.technet.microsoft.com/benshy/2012/06/04/using-a-powershell-script-to-run-as-a-different-user-elevate-the-process/

      You can create a credential object with plain text, but that means you are storing the password as plain text. Secure string encryption uses the computer, so if you are deploying, you’ll need to look at storing credentials securely with certificate or another method.

    • #192994
      Participant
      Topics: 1
      Replies: 2
      Points: -2
      Rank: Member

      so the specific DFSR fixlets i want to use actually have to be ran from an administrator power shell.

      The URL you gave me earlier didn’t seem to work after trying several different methods.

      My boss is having me punt for now and go back to psexec.

Viewing 4 reply threads
  • The topic ‘powershell as system account.’ is closed to new replies.