Task: Get a list of all Cifs shares on a filer, and their permissions.
I’m going cheat a bit and just say that I spent two days searching through the API for this, before I realized that Filerview was echoing out the output from ‘cifs shares’… This changes the task slightly, the end goal is still the same, but the method will be via the cli. I used the same discovery functions as before. Good thing I wrote them because the API I needed is undocumented!
Recall that process from before.
- Always start with a New NaElement for the API.
- From here it’s a logic gate,
- If parameter is a primitive type (string,int,bool) then add with the AddNewChild method.
- If parameter is a NaType then start another New NaElement, and build that NaType, once complete add your new NaType to the request via the AddChildElement method.
- Submit the request via the NaServer object InvokeElem method.
Following that our process should be:
- Start with the API New NaElement.
- The first parameter is of the arg type since arg isn’t one of the three primitives types create a new NaElement.
- Add our commands space delimited into the args array as children to the element.
- Add the args NaElement to the API NaElement as a Child Element.
- Submit the request.
And the code…
$NaElement = New-Object NetApp.Manage.NaElement(“system-cli”)
$arg = New-Object NetApp.Manage.NaElement(“args”)
All that left was a little regex to screen scrape, and some comments.