Import-module Servermanager import-module: Failed to load the specified module "Servermanager" because no valid module file was found in any module directory ... (script that calls PowerShell via Setup factory)

Source: Internet
Author: User

Operating system: Windows Server R2 (64-bit)

C:\Windows\System32\WindowsPowerShell\v1.0\Modules under the Servermanager, but still can not find.

To solve this problem, it takes 2 steps:

1. Implementation strategy in PowerShell (execution policy)

One reason is that the default execution policy for PowerShell is restricted, which means that you can run a single command, but you cannot run scripts, including format and configuration files (. ps1xml), module script files (. psm1), and Windows PowerShell profiles (. PS1), and. bat files. The solution is to change the execution strategy to a looser point, such as remotesigned or unrestricted. Run the following command in PowerShell: Set-executionpolicy remotesigned or set-executionpolicy unrestricted or-executionpolicy RemoteSigned

2, 64-bit operating system and 32-bit operating system relationships

CMD, there are two 64-bit operating systems. One is: C:\Windows\System32\CMD.exe (this is the 64-bit CMD, although the name is System32); one is C:\Windows\SysWOW64\. CMD.exe (This is something under the 32-bit Cmd.syswow64 folder is a 64-bit operating system prepared for running 32-bit applications).

But I compiled the generated. EXE is 32-bit, through the Setup Factory File.run (...) or Shell.execute (...), the C:\Windows\SysWOW64\CMD.exe (32-bit CMD) is called. And the Servermanager module is only 64.

So it would be better to compile it into 64 bits instead.

Attached (running script):

Installdotnet.bat

@echo on
CD C:\Windows\System32\WindowsPowerShell\v1.0
Powershell-executionpolicy "Unrestricted"-file C:\InstallDotNET.ps1

Installdotnet.ps1

Import-module Servermanager
Add-windowsfeature Net-framework
Exit

Special thanks (their blog finally gave me the solution):

Http://www.tuicool.com/articles/RvqqI3

http://blog.csdn.net/leon110/article/details/6203380

Import-module Servermanager import-module: Failed to load the specified module "Servermanager" because no valid module file was found in any module directory ... (script that calls PowerShell via Setup factory)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.