Data ONTAP Discussions

Append additional property to existing cifs share using Powershell

Given whatever change occurred between us running 8.3 and now being at Ontap 9.1, we need to add the show_previous_versions property to a number of cifs shares to give users VSS functionality back.

 

Anyone know how to append instead of replace the properties using the Set-NcCifsShare cmdlet for a given cifs share?

5 REPLIES

Re: Append additional property to existing cifs share using Powershell

^^

Start with this one

 

 Set-NcCifsShare

 

 

Re: Append additional property to existing cifs share using Powershell

Smiley Frustrated

Re: Append additional property to existing cifs share using Powershell

was there more to this comment? 

Re: Append additional property to existing cifs share using Powershell

I should have added a little more detail.

 

Most shares are with the default settings.

 

How many shares are outside of the following default settings

 

oplocks, browsable, changenotify, show_previous_versions

 

You can just push all these settings back down by doing a get | set

 

If you have different requirements, you can do stuff like

 

$share = (get-nccifsshare -VserverContext vservername -ShareName data$).shareproperties -join ","

 

That's your current properties of the share,

 

Then you can adjust $share each time and re-write it each time.  Fairly simple

Re: Append additional property to existing cifs share using Powershell

I did it like this using a foreach loop, to keep the current set of share properties and just append the "show_previous_versions" property:

 

$results = @()

Connect-NcController -Name $controller -Credential $creds -Verbose

$shares = Get-NcCifsShare -CifsServer $cifsserver

 

$results = $shares|? Path -like "*path_string_here*"|? ShareProperties -NotContains "show_previous_versions"

 

foreach ($result in $results)
     {$change_array = @()
     $change_array = $result.shareproperties + "show_previous_versions"
     Set-NcCifsShare -Name $result.ShareName -ShareProperties $change_array -VS vserver_name_here}

 

Didn't think about using -join "," but that works really well too.

 

Edit: Also, I filtered on a group of CIFS shares that shared a common string in the path that I knew I wanted to isolate, which is why I used the Where-Object -like "*path_string_here*", but you could leave that off and then echo out $results to see what paths do not have "show_previous_versions."  You can also add the -whatif parameter to Set-NcCifsShare to see what would be changed before making the change.

Forums