Is there a way to run Get-SMBShareAccess on a large collection of SMB shares in a highly performant way?

Viewed 338

Problem

When using Get-SMBShareAccess on a large collection of SMB Shares (~10,000), the performance degrades significantly. I would like to figure out a way to make this go faster.

Environment Information:

  • Windows Server 2012 R2
  • PSVersion 5.1.14409.1018
  • SmbShare module 2.0.0.0

What I've Tried

I tried adding the ThrottleLimit parameter and reducing the number, with the thought that perhaps it was running too many at once causing a problem. I also tried batching the calls into smaller pieces but this did not seem to help.

Code

$smbShares = Get-SMBShare | Where-Object { $_.Path -like "C:\MyPath" }
$smbAcls = $smbShares | Get-SMBShareAccess

How can I make this perform faster?

1 Answers

After some trial and error, I discovered that what was making this call execute so slowly was utilizing the pipeline. Changing to a parameter based call fixed the issue.

The following code executes many times faster:

$smbShares = Get-SMBShare | Where-Object { $_.Path -like "C:\MyPath" }
$smbAcls = Get-SMBShareAccess -InputObject $smbShares

I believe this is due to something about the internal implementation of Get-SMBShareAccess and it's implementation of pipeline support.

Related