Microsoft Virtualization Discussions

Script for managing typical CIFS provisioning tasks (qtree/share/quota)

madden
7,526 Views

Hi,

We are looking to the easiest way to allow our operations team to manage CIFS shares in a vfiler.  The basic tasks would be:

  • Create/rename/destroy qtree
  • Create/modify/destroy quota, re-init quotas after changes
  • Create/rename/destroy share share

Unfortunately System Manager doesn't support vfiler for these tasks, so although we can use native windows MMC for share management the qtree and quota tasks have no native GUI.  I checked the available PowerShell cmdlets and they seem to include enough for the tasks above so that might be the easiest route if developing from scratch.

Does anyone have any sample scripts they (or the operations team) uses to provision new CIFS storage requests?

Thanks,

Chris

P.S.  Provisioning Manager is out of scope; so although it might be able to do some of the above we're not interested in using it in the flow.

5 REPLIES 5

pwl
NetApp Alumni
7,421 Views

PS> Get-Command add-nacifsshare -syntax


Add-NaCifsShare [-Share] <String> [-Path] <String> [-Comment <String>] [-MaxUsers <Nullable`1>] [-Group <String>] [-Widelink <Nullable`1>] [-SymlinkStrictSecurity <Nullable`1>] [-VirusScan <Nullable`1>] [-VirusScanRead <Nullable`1>] [-Browse <Nullable`1>] [-Umask <Nullable`1>] [-DirectoryUmask <Nullable`1>] [-FileUmask <Nullable`1>] [-Caching <String>] [-Controller <NaController>] [-Verbose] [-Debug] [-ErrorAction <ActionPreference>] [-WarningAction <ActionPreference>] [-ErrorVariable <String>] [-WarningVariable <String>] [-OutVariable <String>] [-OutBuffer <Int32>] [-WhatIf] [-Confirm]

the thing that's missing here is vfiler context

can someone explain how we're supposed to reference CIFS shares on vfilers ?

madden
7,421 Views

When dealing with vfiler you have two options:

1) In the initial Connect-NaController simply connect to the hosted vfiler and not hosting filer (vfiler0)

2) In the initial Connect-NaController connect to the hosting filer (vfiler0) and use the -vfiler <vfilername> parameter to tunnel commands to the hosted vfiler.

Nothing is needed in each cmdlet; it's selected during the connect.

Regards,

Chris

dasimpson1
7,421 Views

Ok So I know this has been opened a long time ago but I have a solution I have created this script to work in powershell and it creates the qtree in a volume ands the quota and ntfs permissions and then will add an email owner for you in dfm. I am not a powershell or script guru by no means but it gets the job done. If anyone has any suggested improvements please share.

############################################################################################################

#Add Data Ontap Module

Import-Module Dataontap

#Set variable for controllers

$vfl01 = Connect-NaController vfiler-01

#Set variables for new creations (This will be for the new qtree and quota to be set THIS WILL ALWAYS NEED TO BE EDITED)

#quota size can be done in G =GB M = MB K =KB

#####################################################

$vfiler = $vfl01

$vol = "volumename"

$qtree = "qtreename"

$quotasize = "20G"

$quotalimit = "20G"

$quotaemail = "email@company.com"

#####################################################

#Create new qtree

New-NaQtree /vol/$vol/$qtree -Controller $vfiler

#Disable quotas for volume

Disable-NaVolQuota $vol -Controller $vfiler

#Adds quota to the qtree

add-NaQuota tree /vol/$vol/$qtree $vol -DiskLimit $quotasize -Threshold $quotalimit -Controller $vfiler

#Enables quotas on volume

Enable-NaVolQuota $vol -Controller $vfiler

#Add NTFS Permissions to share folder

icacls \\$vfiler\$vol\$qtree /grant corp\$qtree:"(OI)(CI)M"

#Test NTFS permisiions

#icacls \\$vfiler\ps$\$qtree /grant corp\user:"(OI)(CI)M"

Write-Host "Adding QTREE owner in DFM/Operation Manager" -BackgroundColor White -ForegroundColor Black

sleep 135

#Set the qtree owner email on the dfm server

dfm comment set $vfiler":"/$vol/$qtree ownerEmail=$quotaemail

Write-Host "Share Creation is complete Please copy and paste below into ticket" -BackgroundColor Black -ForegroundColor Yellow

Write-Host "Created \\$vfiler\$vol\$qtree with $quotasize Quota size" -BackgroundColor Black -ForegroundColor Yellow

dasimpson1
7,421 Views

One more thing to add this script is assuming you shared out the volume already so there is no share creation code in here but really simple to add in if you wanted too

museedulouvre
7,421 Views

Hi,

I think I've made what you are looking for... Except that my script doesn't manage Shares & Volume... Ony Qtree & Quota.

But that should be included in the next version

PowerShell Qtree and Quota manager with Ghost Quota and Qtree Reports, all with GUIhttps://communities.netapp.com/docs/DOC-23762

Public