Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在C中安装Active Directory域服务#_C#_Powershell_Active Directory - Fatal编程技术网

C# 在C中安装Active Directory域服务#

C# 在C中安装Active Directory域服务#,c#,powershell,active-directory,C#,Powershell,Active Directory,我需要在Windows Server 2012计算机中安装AD。是否有任何.Net类允许在不使用Powershell的情况下执行此操作 如果我在C#中使用powershell: 我有一个错误: 安装windowsfeature:术语“安装windowsfeature”不可用 已识别\n是cmdlet、函数、脚本文件或 可操作程序 这很奇怪,因为在Powershell中可以识别Install windowsfeature 感谢您的回答。似乎Install-Windowsfeature cmdlet

我需要在Windows Server 2012计算机中安装AD。是否有任何.Net类允许在不使用Powershell的情况下执行此操作

如果我在C#中使用powershell:

我有一个错误:

安装windowsfeature:术语“安装windowsfeature”不可用 已识别\n是cmdlet、函数、脚本文件或 可操作程序

这很奇怪,因为在Powershell中可以识别Install windowsfeature


感谢您的回答。

似乎Install-Windowsfeature cmdlet仅在64位ps会话中可用。 如果您是从32位应用程序或cmd窗口启动,请使用完整路径启动powershell:

C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe
如果您在64位会话中,则应返回8:

C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -command {[intptr]::size}

你是怎么开始的?我刚刚在2012服务器上进行了测试,该cmdlet在64位PS会话中可以识别,但在x86会话中无法识别。我刚刚添加了代码,谢谢。我是从Visual Studio 2013启动的,不管怎样,我尝试使用Powershell的完整路径,正如您所说,但问题是相同的。您是否运行了[intptr]::大小测试?是的,我在DOS命令提示符下运行:C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe-command{[intptr]::size},但他回答:[intptr]::size。如果我在目标计算机的Powershell中运行[intptr]::size,我会得到8。如果我正在诊断此问题,我要做的下一件事是在该会话中运行get module-listavailable和get command install windowsfeature。ServerManager模块应显示在可用模块列表中。
C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -command {[intptr]::size}