2015-03-02 47 views
-1

我想通過硬編碼手段將c#代碼使用powershell腳本。我不希望用戶在運行時輸入代碼。我對PowerShell非常陌生。我能做什麼?如何使用PowerShell腳本到C#中?

+0

我試圖獲取使用PowerShell WindowsFeatures,然後導入結果在Windows form.I使用addScript和addCommand做this.It可以通過做,但現在我在使用 PS C我打的想法:\ > Import-Module ServerManager PS C:\> Get-WindowsFeature | Where-Object {$ _。Installed -match「True」} |選擇對象 - 屬性名稱 但powrshell中的此代碼給出錯誤,它表示無法加載ServerManager。我使用的是Window 7,並且想在我自己的本地機器中驗證windowsfeatures。 – 2015-03-03 12:33:14

+0

請勿在註釋中添加其他信息;人們無法在那裏看到他們。相反,[編輯]你的問題,並將其添加到那裏。你會在你的問題的標籤下找到[edit]鏈接(在這個例子中,在'c#-4.0'和'powershell-v2.0'之間)。 – 2015-03-07 00:23:27

回答

0

我知道SeverManager Module只能在Windows Server中工作,所以我現在使用Windows Server 2012來實現這一點。並正在工作。