作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我的按钮单击事件中,运行以下脚本。但是当执行服务时,它不会在文本文件中显示任何内容,导入模块 WebAdministration 行显示错误消息:
找不到名称为“WebAdministration”的提供商
相同的脚本在 powershell cmd 中运行良好
我的脚本:
$a = (Get-Service | Where {$_.DisplayName -Like "Microsoft Exchange*"} | % {$_.name + ' :' + $_.status}) -join "`n"
write-output $a >> C:\temp.txt
import-module WebAdministration
$webapps = Get-WebSite Powershell
$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
}
$abc = ($list | %{$_.Name+":"+ $_.ApplicatonPool+":"+$_.Protocol+":"+$_.PhysicalPath}) -join "`n"
write-output "Details For Default WebApplication: `n $abc" >> C:\temp.txt
cd iis:\
$path ='Sites\Default Web Site\' + $website
$abcd = (Get-WebConfiguration -Filter "System.WebServer/Security/Authentication/*" -PSPath $path | where {$_.enabled -eq $True} | % {$_.SectionPath + ' :' + $_.Location}) -join "`n" -replace "/system.webServer/security/authentication/",""
write-output " Enable Authentication Mode For Given Websites:`n $abcd" >> C:\temp.txt
最佳答案
尝试以管理员身份运行Powershell脚本,不需要导入WebAdministration模块
关于c# - 从 C# 应用程序运行时未导入 Web 管理模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37669551/
在我们的数据库表上,我们使用两个唯一的非聚集索引来创建跨四个字段的唯一约束。我们使用两个,因为其中一个字段 ZipCode 是一个可为空的字段。如果表中存在一条包含 ZipCode 的 null 条目
我刚刚开始学习 Rails 3 教程,以便对框架有一点熟悉,但我在生成 schema.rb 时遇到了问题。我的操作系统是 Windows 7 x64、Ruby 1.9.2、MySQL2 gem 0.2
我是一名优秀的程序员,十分优秀!