首页 \ 问答 \ PowerShell远程调用神秘地挂起(PowerShell remote invocation mysteriously hangs)

PowerShell远程调用神秘地挂起(PowerShell remote invocation mysteriously hangs)

我已经创建了一系列基本上收集有关站点的所有IIS配置的函数,当在本地服务器上运行它没有问题时执行(虽然很慢)但是当我在PowerShell 2中使用invoke-command远程运行它时它会运行并且神秘地停止大约15-20秒进入该过程。 它通常会在同一个请求中停止,但并非总是如此。 在本地执行的相同命令没有任何问题。 没有例外,它只是无限期挂起。

我可以在必要时发布代码,但它是几百行,所以我更关注如何调查这样的问题,或者是否有人遇到过类似的问题。

Comparing IISConfig between [targetserver] and localhost.
Checking Installed IIS version on [targetserver]:
IIS major version : 7
IIS minor version : 5
IIS7+ detected, using WebAdmin module and IIS metabase

Name                                                        Value
----                                                        -----
name                                                        Default Web Site
id                                                          1
serverAutoStart                                             True
state                                                       1


Site Configuration:

Name        Path        PSPath      Handlers_Ac Access_sslF Asp_AppAllo Asp_AppAllo Asp_limits_ Asp_EnableP Asp_limits_
                                    cessFlags   lags        wClientDebu  wDebugging bufferingLi  arentPaths queueTimeou
                                                                      g                     mit             t
----        ----        ------      ----------- ----------- ----------- ----------- ----------- ----------- -----------
Default ... IIS:Site... WebAdmin... Read,Script                   False       False    25000000        True 00:00:00


WebApp VDir: /MyApp, App Pool: MyApp
App pool Configuration:

AppPoolID   Enable32Bit managedPipe managedRunt AppPoolName AppPoolAuto processMode processMode processMode recycling_l
             AppOnWin64 lineMode    imeVersion                    Start l_idleTimeo l_identityT l_UserName  ogEventOnRe
                                                                        ut          ype                     cycle
---------   ----------- ----------- ----------- ----------- ----------- ----------- ----------- ----------- -----------
                  False Classic     v2.0        MyApp                True 00:20:00    LocalSer...             Time,Req...


Analyzing web directories for /MyApp, this could take a while....
Initial Collection Completed, found 141... took 0.9516122 seconds
0 C:\inetpub\wwwroot\MyApp\Core
1 C:\inetpub\wwwroot\MyApp\Core\AdminTools
2 C:\inetpub\wwwroot\MyApp\Core\AdminTools\Cache
3 C:\inetpub\wwwroot\MyApp\Core\AdminTools\Extra
4 C:\inetpub\wwwroot\MyApp\Core\AdminTools\HTTPPostTest
5 C:\inetpub\wwwroot\MyApp\Core\AdminTools\IISAdmin
6 C:\inetpub\wwwroot\MyApp\Core\AdminTools\Profiling
7 C:\inetpub\wwwroot\MyApp\Core\AdminTools\RecordTestData
8 C:\inetpub\wwwroot\MyApp\Core\AdminTools\ScrambleTest
9 C:\inetpub\wwwroot\MyApp\Core\AdminTools\Sessions
Analyzed 10 so far... took 6.7236862 seconds, remaining time 88.08028922 seconds
Current Folder: C:\inetpub\wwwroot\MyApp\Core\AdminTools\Sessions
10 C:\inetpub\wwwroot\MyApp\Core\AdminTools\SoapTest
11 C:\inetpub\wwwroot\MyApp\Core\AdminTools\StaticContent

有时它会达到15左右。 我尝试从我的笔记本电脑和从一台服务器到另一台服务器,行为是一样的。

这是挂起的循环:

$start = [System.DateTime]::Now
$numanalyzed = 0
if ($true) #skip to test
{
# loop through all physical folders as it is much faster
foreach ($folder in $folders)
{

    write-host $numanalyzed $folder.fullname
    #figure out the virtual path to the folder
    $iis7vwebfolderpath = $folder.FullName.Replace($iis7webapp.PhysicalPath, $iis7VDirWebApppath)
    #Get-item $iis7vwebfolderpath | gm
    $iis7VWebDirConfigItem = Get-LNOSIIS7ConfigForPSPath -PSPath $iis7vwebfolderpath

    # add new item to list
    $iis7VWebDirConfig += $iis7VWebDirConfigItem

    # increment counter and report out progress every 10
    $numAnalyzed++
    if ($numanalyzed % 10 -eq 0) 
    {

       $end = [System.DateTime]::Now
       $timeSoFar = (NEW-TIMESPAN –Start $Start –End $End).TotalSeconds
       $timeremaining = ($folders.Count - $numAnalyzed) * ($timeSoFar / $numanalyzed)
       "Analyzed {0} so far... took {1} seconds, remaining time {2} seconds" -f $numanalyzed,$timeSoFar,$timeremaining  | write-host 
       "Current Folder: {0}" -f $folder.FullName | Write-Host
    }
}
}



$end = [System.DateTime]::Now
"Processed web dirs: {0} took {1} seconds" -f $iis7VWebDirConfig.Count,(NEW-TIMESPAN –Start $Start –End $End).TotalSeconds | write-host   | Write-Host

函数我遇到了性能问题,我有一个单独的问题,但这篇文章有该函数的源代码:

Web管理与WMI查询Web目录属性性能问题


I have created a series of functions that basically collect all the IIS configurations about a site, when run on a server locally it executes without issue (albeit slowly) however when I run them remotely using an invoke-command in PowerShell 2 it runs through and mysteriously stops approximately 15-20 seconds into the process. It generally stalls on the same request but not always. The same commands executed locally work without any issues. No exception is raised, it just hangs indefinitely.

I can post the code if necessary however it is several hundred lines so I'm more looking for guidance on how to investigate a problem like this or if anyone has encountered something similar.

Comparing IISConfig between [targetserver] and localhost.
Checking Installed IIS version on [targetserver]:
IIS major version : 7
IIS minor version : 5
IIS7+ detected, using WebAdmin module and IIS metabase

Name                                                        Value
----                                                        -----
name                                                        Default Web Site
id                                                          1
serverAutoStart                                             True
state                                                       1


Site Configuration:

Name        Path        PSPath      Handlers_Ac Access_sslF Asp_AppAllo Asp_AppAllo Asp_limits_ Asp_EnableP Asp_limits_
                                    cessFlags   lags        wClientDebu  wDebugging bufferingLi  arentPaths queueTimeou
                                                                      g                     mit             t
----        ----        ------      ----------- ----------- ----------- ----------- ----------- ----------- -----------
Default ... IIS:Site... WebAdmin... Read,Script                   False       False    25000000        True 00:00:00


WebApp VDir: /MyApp, App Pool: MyApp
App pool Configuration:

AppPoolID   Enable32Bit managedPipe managedRunt AppPoolName AppPoolAuto processMode processMode processMode recycling_l
             AppOnWin64 lineMode    imeVersion                    Start l_idleTimeo l_identityT l_UserName  ogEventOnRe
                                                                        ut          ype                     cycle
---------   ----------- ----------- ----------- ----------- ----------- ----------- ----------- ----------- -----------
                  False Classic     v2.0        MyApp                True 00:20:00    LocalSer...             Time,Req...


Analyzing web directories for /MyApp, this could take a while....
Initial Collection Completed, found 141... took 0.9516122 seconds
0 C:\inetpub\wwwroot\MyApp\Core
1 C:\inetpub\wwwroot\MyApp\Core\AdminTools
2 C:\inetpub\wwwroot\MyApp\Core\AdminTools\Cache
3 C:\inetpub\wwwroot\MyApp\Core\AdminTools\Extra
4 C:\inetpub\wwwroot\MyApp\Core\AdminTools\HTTPPostTest
5 C:\inetpub\wwwroot\MyApp\Core\AdminTools\IISAdmin
6 C:\inetpub\wwwroot\MyApp\Core\AdminTools\Profiling
7 C:\inetpub\wwwroot\MyApp\Core\AdminTools\RecordTestData
8 C:\inetpub\wwwroot\MyApp\Core\AdminTools\ScrambleTest
9 C:\inetpub\wwwroot\MyApp\Core\AdminTools\Sessions
Analyzed 10 so far... took 6.7236862 seconds, remaining time 88.08028922 seconds
Current Folder: C:\inetpub\wwwroot\MyApp\Core\AdminTools\Sessions
10 C:\inetpub\wwwroot\MyApp\Core\AdminTools\SoapTest
11 C:\inetpub\wwwroot\MyApp\Core\AdminTools\StaticContent

Sometimes it makes it to 15 or so. I tried from my laptop and from one server to another and the behavior is the same.

Here is the loop which is hanging:

$start = [System.DateTime]::Now
$numanalyzed = 0
if ($true) #skip to test
{
# loop through all physical folders as it is much faster
foreach ($folder in $folders)
{

    write-host $numanalyzed $folder.fullname
    #figure out the virtual path to the folder
    $iis7vwebfolderpath = $folder.FullName.Replace($iis7webapp.PhysicalPath, $iis7VDirWebApppath)
    #Get-item $iis7vwebfolderpath | gm
    $iis7VWebDirConfigItem = Get-LNOSIIS7ConfigForPSPath -PSPath $iis7vwebfolderpath

    # add new item to list
    $iis7VWebDirConfig += $iis7VWebDirConfigItem

    # increment counter and report out progress every 10
    $numAnalyzed++
    if ($numanalyzed % 10 -eq 0) 
    {

       $end = [System.DateTime]::Now
       $timeSoFar = (NEW-TIMESPAN –Start $Start –End $End).TotalSeconds
       $timeremaining = ($folders.Count - $numAnalyzed) * ($timeSoFar / $numanalyzed)
       "Analyzed {0} so far... took {1} seconds, remaining time {2} seconds" -f $numanalyzed,$timeSoFar,$timeremaining  | write-host 
       "Current Folder: {0}" -f $folder.FullName | Write-Host
    }
}
}



$end = [System.DateTime]::Now
"Processed web dirs: {0} took {1} seconds" -f $iis7VWebDirConfig.Count,(NEW-TIMESPAN –Start $Start –End $End).TotalSeconds | write-host   | Write-Host

The function I'm having performance problems with and I've got a separate question about but this post has the source code for the function:

web-administration vs WMI to query web directory properties performance problems


原文:https://stackoverflow.com/questions/29638446
更新时间:2024-03-18 21:03

最满意答案

我已经更正了您的代码,请在下方查看,我希望它对您有用。

    <div class="item active">
<?php
    $data= $this->main->viewbook();
    $r=1;
    foreach ($data as $row){

        if($r%6==0) {
            echo '</div><div class="item">';
        }
?> 
<div class="col-lg-2 col-xs-6 col-md-4 col-sm-6 thumbnails">
    <div class="fff">
        <a href="#"><img class="img-responsive" src="<?php echo base_url()?>assets/images/css.jpg" alt=""></a>
        <strong>Praesent commodo Nibh Etiam Sem Nullam</strong><br>
        <strong style=" color:#029f5b;"> <?php  echo $row->BookID; ;?></strong><br>
        Nullam Condimentum Nibh Etiam Sem no inquiry so cordial   
        <a class="" href="#">» Read More</a>
    </div>
</div>

<?php $r++; } ?>
</div>

I have corrected your code, check it below and i hope it will work for you.

    <div class="item active">
<?php
    $data= $this->main->viewbook();
    $r=1;
    foreach ($data as $row){

        if($r%6==0) {
            echo '</div><div class="item">';
        }
?> 
<div class="col-lg-2 col-xs-6 col-md-4 col-sm-6 thumbnails">
    <div class="fff">
        <a href="#"><img class="img-responsive" src="<?php echo base_url()?>assets/images/css.jpg" alt=""></a>
        <strong>Praesent commodo Nibh Etiam Sem Nullam</strong><br>
        <strong style=" color:#029f5b;"> <?php  echo $row->BookID; ;?></strong><br>
        Nullam Condimentum Nibh Etiam Sem no inquiry so cordial   
        <a class="" href="#">» Read More</a>
    </div>
</div>

<?php $r++; } ?>
</div>

相关问答

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)