Import-Module WebAdministration
$pool = "ChannelServices"
$wp = Get-ChildItem "IIS:\AppPools\$pool\WorkerProcesses"
Get-Process -Id $wp.processId
Restart-WebAppPool $pool
sleep 5
Get-ChildItem "IIS:\AppPools\$pool\WorkerProcesses"
Get-Process -Id $wp.processId
Run Code Online (Sandbox Code Playgroud)
因此,当我为特定 AppPool 的 WorkerProcesses 执行 Get-ChildItem,然后重新启动该 AppPool 时,我应该获得一个新的 PID,我确实这么做了。但是,重新运行 Get-ChildItem 仍显示旧的 PID。如果我关闭 Powershell 并重新打开,它将不会显示正确的新 PID。
我怎样才能强制Powershell清除它的缓存,或者任何保存不正确信息的东西......
更新 需要明确的是,我的问题是如何在使用 IIS PSDrive 时清除本地缓存。
我注意到 TypeName:Microsoft.IIs.PowerShell.Framework.ConfigurationElement#workerProcesses#workerProcess
有一个方法: Name MemberType Definition
---- ---------- ----------
ClearLocalData Method void ClearLocalData()
但它对我来说并没有真正起作用......就像下面的人所说,这可能只是一个错误。
我在下面看到了有关如何使用我所知道的 WMI 的答案。
@theJasonHelmick 提供了一个很好的:
GWMI win32_process -filter "name='w3wp.exe'" | Select Name, ProcessId, @{n='AppPool';e={$_.GetOwner().user}}
Run Code Online (Sandbox Code Playgroud)
这为我提供了运行 AppPool 的用户名。我对此进行了一些修改,以从命令行中提取实际的应用程序池名称:
Get-WmiObject -Class win32_process -filter "name='w3wp.exe'" | Select …
Run Code Online (Sandbox Code Playgroud) 我正在尝试解决许可问题,我正在查看集群中的几个 SQL 2008 机器,但我无法在任何地方看到它说企业版的位置,即使我知道它正在运行。
我需要弄清楚这一点,因为我有一些位于虚拟机上的报告服务器,它们可能正在运行也可能没有运行企业版。
我无法通过查询执行此操作,因为报告服务器上未安装数据库服务。但是,我仍然需要许可这些盒子