Get-FileSharePermission crashes when a share has NO permissions

Create issue
Issue #188 resolved
Former user created an issue

Yep, don't know how we got into that state but we had a share with no ACEs, not even for Everyone. In that case the script crashes as follows:

Get-FileSharePermission : You cannot call a method on a null-valued expression.
At C:\ProdOps\Common\PowerShell\Carbon\Functions\Install-FileShare.ps1:212 char:27
+             $permission = Get-FileSharePermission -Name $Name -Identity $identit ...
+                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-FileSharePermission], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull,Get-FileSharePermission

Comments (5)

  1. Aaron Jensen repo owner

    Also, I'd like to get a full stack trace. Can you reproduce again and get the full stack trace, e.g $Error[0].ScriptStackTrace

  2. Aaron Jensen repo owner

    I was never able to reproduce this issue, but I inspected the code for any place I wasn't checking for a null value and added additional checks. Hopefully this solves the problem. The fix will be part of Carbon 2.2.0.

  3. Log in to comment