edit: Should I have posted this on serverfault instead? There is not even a dfs-r category on stackoverflow, but I thought this was more of a scripting\programming question. Let me know if I should put this on serverfault instead.
I attempted to use the DfsrIdRecordInfo class to retrieve all files of a somewhat large (6000 file) DFSR database and was getting WMI quota errors.
Doubling and even tripling the wmi quotas on the server did not solve this.
I found looking here that the index property of this class is: "The run-time index of the record. This value is used to partition the result of a large query." which sounded like exactly what I wanted, but the behavior of this property is not what I expected.
I found that when I try to do paging with this property it does not retrieve all of the records as per the following example with powershell.
I tested this on a DFSR database with less than 700 files that does not throw a quota error. Because this is a small database I can get all the files like this in less than a second:
$DFSRFiles =
gwmi `
-Namespace root\microsoftdfs `
-ComputerName 'dfsrserver' `
-Query "SELECT *
FROM DfsrIdRecordInfo
WHERE replicatedfolderguid = '$guid'"
PS F:\> $DFSRFiles.count
680
So I have 680 files in this DFSR DB. Now if I try to use the index property for pagination like this:
$starttime = Get-Date;
$i = 0 #index counter
$DfsrIdRecordInfoArr = @()
while ($i -lt 1000) {
$starttimepage = Get-Date
$StartRange = $i
$EndRange = $i += 500
Write-Host -ForegroundColor Green "On range: $StartRange - $EndRange"
$DFSRFiles =
gwmi `
-Namespace root\microsoftdfs `
-ComputerName 'dfsrserver' `
-Query "SELECT *
FROM DfsrIdRecordInfo
WHERE index >= $StartRange
AND index <= $EndRange
AND replicatedfolderguid = '$guid'"
$DfsrIdRecordInfoArr += $DFSRFiles
Write-Host -ForegroundColor Green "Returned $($DFSRFiles.count) objects from range"
(Get-Date) - $starttimepage
write-host -fo yellow "DEBUG: i = $i"
}
(get-date) - $starttime
PS F:\> $DfsrIdRecordInfoArr.count
517
So it only returns 517 files.
Here is the full output of my debug messages. You can also see searching this way takes a super long time:
On range: 0 - 500
Returned 501 objects from range
Days : 0
Hours : 0
Minutes : 1
Seconds : 29
Milliseconds : 540
Ticks : 895409532
TotalDays : 0.001036353625
TotalHours : 0.024872487
TotalMinutes : 1.49234922
TotalSeconds : 89.5409532
TotalMilliseconds : 89540.9532
DEBUG: i = 500
On range: 500 - 1000
Returned 16 objects from range
Days : 0
Hours : 0
Minutes : 1
Seconds : 35
Milliseconds : 856
Ticks : 958565847
TotalDays : 0.00110945121180556
TotalHours : 0.0266268290833333
TotalMinutes : 1.597609745
TotalSeconds : 95.8565847
TotalMilliseconds : 95856.5847
DEBUG: i = 1000
Days : 0
Hours : 0
Minutes : 3
Seconds : 5
Milliseconds : 429
Ticks : 1854295411
TotalDays : 0.00214617524421296
TotalHours : 0.0515082058611111
TotalMinutes : 3.09049235166667
TotalSeconds : 185.4295411
TotalMilliseconds : 185429.5411
Am I doing something stupid? I was thinking that "run-time index" means the index property is not statically attached to the records and is generated anew for each record every time a query is run because the index properties of objects in $DFSRFiles do not match those in $DfsrIdRecordInfoArr.
But if the index property is different for every query then I would have duplicates in $DfsrIdRecordInfoArr which I do not. All the records are unique, but it just doesn't return all of them.
Is the index property totally useless for my purpose? Perhaps when it says "...partition the result of a large query" this means it is to be used on records that have already been returned from WMI not the WMI query itself.
Any guidance would be appreciated. Thanks in advance.