Wrong output in CIM cmdlets like Get-SmbShareAccess, Enable-NetAdapterChecksumOffload, etc. - by Evgeny Kotkov

Status : 

  External<br /><br />
		This item may be valid but belongs to an external system out of the direct control of this product team.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


7
0
Sign in
to vote
ID 1852524 Comments
Status Resolved Workarounds
Type Bug Repros 5
Opened 9/30/2015 7:29:42 AM
Access Restriction Public

Description

Standard CIM cmdlets can produce invalid output.  I reproduced the problem with
two commands — Get-SmbShareAccess and Enable-NetAdapterChecksumOffload.
I also believe that the problem is not limited to these particular commands.

Below is an example of me executing 'Get-SmbShareAccess C$, D$' twice.  Please
note that the first output is incorrect and it shows 6 entries for C$, instead
of expected 3 entries for C$ and 3 entries for D$:

  PS C:\> Get-SmbShareAccess C$, D$

  Name ScopeName AccountName              AccessControlType AccessRight
  ---- --------- -----------              ----------------- -----------
  C$   *         BUILTIN\Administrators   Allow             Full
  C$   *         BUILTIN\Administrators   Allow             Full
  C$   *         BUILTIN\Backup Operators Allow             Full
  C$   *         BUILTIN\Backup Operators Allow             Full
  C$   *         NT AUTHORITY\INTERACTIVE Allow             Full
  C$   *         NT AUTHORITY\INTERACTIVE Allow             Full

  PS C:\> Get-SmbShareAccess C$, D$

  Name ScopeName AccountName              AccessControlType AccessRight
  ---- --------- -----------              ----------------- -----------
  C$   *         BUILTIN\Administrators   Allow             Full
  C$   *         BUILTIN\Backup Operators Allow             Full
  C$   *         NT AUTHORITY\INTERACTIVE Allow             Full
  D$   *         BUILTIN\Administrators   Allow             Full
  D$   *         BUILTIN\Backup Operators Allow             Full
  D$   *         NT AUTHORITY\INTERACTIVE Allow             Full

This problem occurs randomly — i.e., sometimes the output is correct, and
sometimes it is not.

Below is another example of me executing Enable-NetAdapterChecksumOffload for
two adapters, with the same problem.  The first output is incorrect:

  PS C:\> Enable-NetAdapterChecksumOffload A, B -IpIPv4 -PassThru

  Name                           IpIPv4Enabled   TcpIPv4Enabled  TcpIPv6En
                                                                 abled
  ----                           -------------   --------------  ---------
  A                              RxTxEnabled     RxTxEnabled     Disabled
  A                              RxTxEnabled     RxTxEnabled     Disabled


  PS C:\> Enable-NetAdapterChecksumOffload A, B -IpIPv4 -PassThru

  Name                           IpIPv4Enabled   TcpIPv4Enabled  TcpIPv6En
                                                                 abled
  ----                           -------------   --------------  ---------
  A                              RxTxEnabled     RxTxEnabled     Disabled
  B                              RxTxEnabled     RxTxEnabled     Disabled

Additional notes:

- The problem happens in both PowerShell 4 (4.0) and 5 (5.0.10514.0)

- The problem doesn't happen with -ThrottleLimit 1

- The problem doesn't happen if the objects are taken from the pipeline, for
  example, with Get-SmbShare C$, D$ | Get-SmbShareAccess

- The problem happens from time to time, so a loop like below can be useful
  in reproducing it:

    while (1) { Write-Host ''; Get-SmbShareAccess C$, D$ }

- From my observations, the problem occurs with CIM cmdlets that invoke a
  non-static CIM method with output ¹ when these methods are executed in
  parallel for multiple CIM instances.

¹ A method with [Out]-parameter in .mof file and with the corresponding
  <CmdletOutputMetadata> tag in the .cdxml file.
Sign in to post a comment.
Posted by Evgeny Kotkov on 12/3/2015 at 6:55 AM
Thanks for taking a look a this issue.

Please note that the described problem is not specific to the File Share cmdlet
(Get-SmbShare), but can also be reproduced with other commands — e.g., with
Enable-NetAdapterChecksumOffload, which is unrelated to File Sharing.

A common thing about these examples is that they perform concurrent requests
to the CIM provider and then join the results. The problem doesn't happen
with -ThrottleLimit 1, and I tend to think that the root of the problem is a
race condition happening somewhere around the following method:

Microsoft.PowerShell.Cmdletization.Cim.ExtrinsicMethodInvocationJob.OnNext()

The method is a part of Microsoft.PowerShell.Commands.Management.dll assembly.

As a blind guess, it could be that, when joining the results, the resulting
CIM object from another request is being incorrectly reused and treated as
the result of the request that's currently being processed. That could explain
the duplicated entries in the output.

To me it looks like this is the functionality that is owned by the PowerShell
Core team, so could you please re-evaluate this report?
Posted by Mark [MSFT] on 11/23/2015 at 2:26 PM
Thanks so much for the feedback. Unfortunately, this functionality is not owned by the PowerShell Core team. We recommend that you file the feedback with the File Share team here: http://windowsserver.uservoice.com/forums/295056-storage/category/136392-smb