2017-03-23 57 views
0

在PowerShell中的Server 2008 R2 Standard上。我試圖運行使用Get-WebBinding術語'Get-WebBinding'不被識別爲cmdlet,函數,腳本文件或可操作程序的名稱

try{ 
Import-Module WebAdministration 
Get-WebApplication 

$webapps = Get-WebApplication 
$list = @() 
foreach ($webapp in get-childitem IIS:\AppPools\) 
{ 
$name = "IIS:\AppPools\" + $webapp.name 
$item = @{} 

$item.WebAppName = $webapp.name 
$item.Version = (Get-ItemProperty $name managedRuntimeVersion).Value 
$item.State = (Get-WebAppPoolState -Name $webapp.name).Value 
$item.UserIdentityType = $webapp.processModel.identityType 
$item.Username = $webapp.processModel.userName 
$item.Password = $webapp.processModel.password 

$obj = New-Object PSObject -Property $item 
$list += $obj 
} 

$list | Format-Table -a -Property "WebAppName", "Version", "State", "UserIdentityType", "Username", "Password" | Out-String 

}catch 
{ 
$ExceptionMessage = "Error in Line: " + $_.Exception.Line + ". " + $_.Exception.GetType().FullName + ": " + $_.Exception.Message + " Stacktrace: " + $_.Exception.StackTrace 
$ExceptionMessage 
} 

不過,我收到以下錯誤的腳本:

The term 'Get-WebBinding' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:25 char:15 + Get-WebBinding <<<< | % { + CategoryInfo : ObjectNotFound: (Get-WebBinding:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException

我嘗試添加該管理單元,並得到這個錯誤:

並根據這篇文章https://community.spiceworks.com/topic/370385-powershell-commands-to-export-iis7-sites-binding-information:因爲我使用iis 7,我試圖得到PowerShell擴展。我去了iis.net鏈接(https://www.iis.net/downloads/microsoft/powershell)並找不到下載。該按鈕只是帶你到圖庫搜索。

有一個按鈕來安裝擴展,但它不拉起安裝程序。

+0

我猜你需要PS版本高於你有(嗯,看起來不正確)。尋找你需要的最低版本。 08r2默認爲2.0。是您爲x86或x64獲取的snapin,以及您運行的是哪個shell。 – Matt

+0

我想我找到了擴展的下載。 https://www.microsoft.com/en-us/download/details.aspx?id=15488但是,當我運行它時,它說「Powershell管理單元」是Windows操作系統的一部分。「我進入服務器角色,我有「Web服務器(IIS)」在網絡服務器角色功能我有「IIS管理腳本和工具(已安裝)」 – JDPeckham

+0

@Matt - 我有版本2在另一個2008R2標準服務器和腳本運行精細。我現在有2個服務器,它不能運行,1個運行。哦,我想通了。他們有限制執行政策。我會爲此更新答案。謝謝! – JDPeckham

回答

0

Set-ExecutionPolicy RemoteSigned然後重新啓動Powershell已解決我的問題。

相關問題