Delegate Report - 'System.OutOfMemoryException'


using script below output publicdelegate , publicdelegatesbl attribute. script working fine using memory available , stops working after processing 300 users.  how can optimize doesn't use memory?
error below.
'=' operator failed: exception of type 'system.outofmemoryexception' thrown..
@ d:\data\behalf of.ps1:6 char:21
+ $publicdelegatesbl = <<<<  $_.publicdelegatesbl | get-qaduser | foreach {$_.name}
    + categoryinfo          : invalidoperation: (:) [], runtimeexception
    + fullyqualifiederrorid : operatorfailed

add-pssnapin quest.activeroles.admanagement
$users
= get-qaduser -sizelimit 0 -dontusedefaultincludedproperties -includedproperties publicdelegates,publicdelegatesbl -ldapfilter '(publicdelegates=*)(publicdelegatesbl=*)'
$users
| select * | foreach {
$publicdelegates
= $_.publicdelegates | get-qaduser | foreach {$_.name}
$_
.publicdelegates = [string]::join(';',$publicdelegates)
$publicdelegatesbl
= $_.publicdelegatesbl | get-qaduser | foreach {$_.name}
$_
.publicdelegatesbl = [string]::join(';',$publicdelegatesbl)
$_

} |
select-object name,publicdelegates,publicdelegatesbl | export-csv d:\delgate.csv

suggestions?

thanks

two things.  first, command:

$users = get-qaduser -sizelimit 0 -dontusedefaultincludedproperties -includedproperties publicdelegates,publicdelegatesbl -ldapfilter '(publicdelegates=*)(publicdelegatesbl=*)'

stores entire result of query in memory.  instead of saving the results to a $users variable, can pipe that command straight foreach-object, stream objects 1 @ time without ever having store them in memory @ once.

second, i've seen other instances of quest ad cmdlets causing outofmemoryexceptions when powershell code looked fine.  don't know bug comes from, you'll better off using built-in activedirectory module, long meet prerequisites (at least windows 7 or windows 2008 r2 on computer running script, , @ least 1 domain controller available running ad web services or ad management gateway; installed default on 2008 r2 domain controllers or later, , availabe download server 2003 sp2 , server 2008.)



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

server manager error: ADAM.events.xml could not be enumerated.

Cannot access Anywhere Access using domain name?

WMI Failure: Unable to update Local Resource Group