Effective December 3, NetApp adopts Microsoft’s Business-to-Customer (B2C) identity management to simplify and provide secure access to NetApp resources.
For accounts that did not pre-register (prior to Dec 3), access to your NetApp data may take up to 1 hour as your legacy NSS ID is synchronized to the new B2C identity.
To learn more, read the FAQ and watch the video.
Need assistance? Complete this form and select “Registration Issue” as the Feedback Category.

Microsoft Virtualization Discussions

Set-NaCifsShareAcl and Get-NaCifsShareAcl property names

MAGENTRY

I'm new to PowerShell and still trying to understand how everything fits together.

I noticed these two cmdlets use a different property for the CIFS share name - "Share" vs. "Sharename".  Is this type of thing commonly "fixed" or have I misinterpreted this being done in error? 

I was attempting to write a PowerShell statement to retrieve all the shares on a filer with "everyone / Full Control" and replace that with "Authenticated Users / Full Control".  I ended up doing it like this -

Get-NaCifsShareAcl | Where-Object {$_.UserAclInfo -like "everyone"} | Select-Object @{Name="Share";Expression={$_."ShareName"}} | Set-NaCifsShareAcl -User "NT AUTHORITY\Authenticated Users" -AccessRights "Full Control"

Get-NaCifsShareAcl | Where-Object {$_.UserAclInfo -like "everyone"} | Select-Object @{Name="Share";Expression={$_."ShareName"}} | Remove-NaCifsShareAcl -User "everyone"

Is there an easier way to do this?  Usually it seems like the pipes work somewhat magically but in this case the magic disappeared and I had to remap the property names manually.

2 REPLIES 2

sizemore

Hey Matthew,

While we try to keep those parameter names the same there are instances where it makes sense to change them.  However in those instances we should always have an alias set on the parameter that does that mapping for you.  For instance if we check the set-nacifsshareacl cmdlet, the Share parameter will bind to either Name, or ShareName.

PS ≥ Get-NaHelpAlias set-nacifsshareacl

Name                                                        Aliases
----                                                        -------
Share                                                       {ShareName, Name}
User                                                        {Username}
UnixGroup                                                   {Groupname}
AccessRights                                                {}
Acl                                                         {}
Controller                                                  {Filer, Server}
Verbose                                                     {vb}
Debug                                                       {db}
ErrorAction                                                 {ea}
WarningAction                                               {wa}
ErrorVariable                                               {ev}
WarningVariable                                             {wv}
OutVariable                                                 {ov}
OutBuffer                                                   {ob}
WhatIf                                                      {wi}
Confirm                                                     {cf}

In other words you could just do:

Get-NaCifsShareAcl | Where-Object {$_.UserAclInfo -like "everyone"} | Set-NaCifsShareAcl -User "NT AUTHORITY\Authenticated Users" -AccessRights "Full Control"

Get-NaCifsShareAcl | Where-Object {$_.UserAclInfo -like "everyone"} | Remove-NaCifsShareAcl -User "everyone"

Hope that helps,

~Glenn

MAGENTRY

Thanks Glenn!  I wasn't aware of the aliases and apparently I overcomplicated things a bit.  This is very helpful, thanks for taking the time to reply!

-Matt

Announcements
NetApp on Discord Image

We're on Discord, are you?

Live Chat, Watch Parties, and More!

Explore Banner

Meet Explore, NetApp’s digital sales platform

Engage digitally throughout the sales process, from product discovery to configuration, and handle all your post-purchase needs.

NetApp Insights to Action
I2A Banner
Public