PowerShell remote invocation mysteriously hangs -
i have created series of functions collect iis configurations site, when run on server locally executes without issue (albeit slowly) when run them remotely using invoke-command
in powershell 2 runs through , mysteriously stops approximately 15-20 seconds process. stalls on same request not always. same commands executed locally work without issues. no exception raised, hangs indefinitely.
i can post code if necessary several hundred lines i'm more looking guidance on how investigate problem or if has encountered similar.
comparing iisconfig between [targetserver] , localhost. checking installed iis version on [targetserver]: iis major version : 7 iis minor version : 5 iis7+ detected, using webadmin module , 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 /myapp, take 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 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 makes 15 or so. tried laptop , 1 server , behavior same.
here loop hanging:
$start = [system.datetime]::now $numanalyzed = 0 if ($true) #skip test { # loop through physical folders faster foreach ($folder in $folders) { write-host $numanalyzed $folder.fullname #figure out virtual path folder $iis7vwebfolderpath = $folder.fullname.replace($iis7webapp.physicalpath, $iis7vdirwebapppath) #get-item $iis7vwebfolderpath | gm $iis7vwebdirconfigitem = get-lnosiis7configforpspath -pspath $iis7vwebfolderpath # add new item list $iis7vwebdirconfig += $iis7vwebdirconfigitem # increment counter , 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} 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 , i've got separate question post has source code function:
web-administration vs wmi query web directory properties performance problems
i think may have discovered problem, started getting odd failures in other parts of script:
[severname] processing data remote server servername failed following error message: wsman provider host process did not return proper response. provider in host process may have behaved improperly. more information, see about_remote_troubleshooting topic. + categoryinfo : openerror: (servername:string) [], psremotingtransportexception + fullyqualifiederrorid : 1726,pssessionstatebroken
and
processing data remote command failed following error message: not enough storage available complete operation. more information, see about_remote_troubleshooting topic. + categoryinfo : operationstopped (system.manageme...pressionsyncjob:psinvokeexpressionsyncjob) [], psremotingtransportexception + fullyqualifiederrorid : jobfailure
this lead me following site: http://www.gsx.com/blog/bid/83018/troubleshooting-unknown-powershell-error-messages
the following recommendations seems have cleared of problems although still have testing do.
excerpt site below:
as first error message specifies, overflow of memory in remote session has occurred. open powershell prompt on remote server , display configuration of winrs using:
winrm winrm/config/winrs
check "maxmemorypershellmb" value. set default 150 mb on windows server 2008 r2 , windows 7. microsoft changed in windows server 2012 , windows 8 1024 mb.
in order resolve issue, need increase value @ least 512 mb following command:
winrm set winrm/config/winrs `@`{maxmemorypershellmb=`"512`"`}
Comments
Post a Comment