Microsoft Virtualization Discussions

Challenge reading SecurityRules from Get-NaNfsExport

manuelsanchez
3,132 Views

I would like to export my NFS shares and their security rules to an Excel documente using Get-NaNfsExport.

For now I am focusing on NFS share "/vol/n4a1_LRAC01_10nfs_u05" to get my PowerShell script working.

These are the security rules for "/vol/n4a1_LRAC01_10nfs_u05" from what I see on "/etc/exports" for that share.

mia0lapp0a:/home/ts0091 # rsh mia0nfas04 rdfile /etc/exports|grep n4a1_LRAC01_10nfs_u05

/vol/n4a1_LRAC01_10nfs_u05    -sec=sys,rw=mia0lrac01.mia0.assurant.com,root=mia0lrac01.mia0.assurant.com

mia0lapp0a:/home/ts0091 #

Here is what I get with Get-NaNfsExport:

PS C:\>

PS C:\> $nfs_share = "/vol/n4a1_LRAC01_10nfs_u05"

PS C:\>

PS C:\> Get-NaNfsExport $nfs_share -Persistent

ActualPathname             Pathname                   SecurityRules

--------------             --------                   -------------

                           /vol/n4a1_LRAC01_10nfs_u05 {}

PS C:\>

PS C:\> $sec_rules = (Get-NaNfsExport $nfs_share -Persistent).SecurityRules

PS C:\>

PS C:\> write-host $sec_rules

NetApp.Ontapi.Filer.Nfs73.SecurityRuleInfo

PS C:\>

I am trying this, but I am sure I am doing something wrong, beacuse $info comes back empty.

PS C:\> $info =((Get-NaNfsExport $nfs_share -Persistent).SecurityRules).SecurityRuleInfo

PS C:\>

PS C:\> write-host $info

PS C:\>

How can I gather the info we see on the "/etc/exports" file?

1 ACCEPTED SOLUTION

sizemore
3,132 Views

The export information isn't contained in a string it's a rich object.  To access those properties you need to expand the SecurtiyRules property to view the full object.

[0:42]: Get-NaNfsExport /vol/boot_luns -Persistent | Select-Object -ExpandProperty SecurityRules


Anon            :
Nosuid          : True
ReadOnly        :
ReadWrite       : {all-hosts}
Root            :
SecFlavor       : {sys}
NosuidSpecified : True

Alternatively if all you want is to read the export file you can do that with the read-nafile cmdlet.

[0:43]: Read-NaFile /vol/root/etc/exports

#Auto-generated by setup Tue May 10 18:12:29 GMT 2011

/vol/root       -sec=sys,rw,anon=0,nosuid

/vol/root/home  -sec=sys,rw,nosuid

/vol/boot_luns  -sec=sys,rw,nosuid

/vol/vol6       -sec=sys,rw,nosuid

/vol/WHS_Data   -sec=sys,rw,nosuid

/vol/vmdata1    -sec=sys,rw,nosuid

/vol/vmdata     -sec=sys,rw,nosuid

/vol/software   -sec=sys,rw,nosuid

/vol/quorum     -sec=sys,rw,nosuid

Hope that helps,

~Glenn

View solution in original post

2 REPLIES 2

sizemore
3,133 Views

The export information isn't contained in a string it's a rich object.  To access those properties you need to expand the SecurtiyRules property to view the full object.

[0:42]: Get-NaNfsExport /vol/boot_luns -Persistent | Select-Object -ExpandProperty SecurityRules


Anon            :
Nosuid          : True
ReadOnly        :
ReadWrite       : {all-hosts}
Root            :
SecFlavor       : {sys}
NosuidSpecified : True

Alternatively if all you want is to read the export file you can do that with the read-nafile cmdlet.

[0:43]: Read-NaFile /vol/root/etc/exports

#Auto-generated by setup Tue May 10 18:12:29 GMT 2011

/vol/root       -sec=sys,rw,anon=0,nosuid

/vol/root/home  -sec=sys,rw,nosuid

/vol/boot_luns  -sec=sys,rw,nosuid

/vol/vol6       -sec=sys,rw,nosuid

/vol/WHS_Data   -sec=sys,rw,nosuid

/vol/vmdata1    -sec=sys,rw,nosuid

/vol/vmdata     -sec=sys,rw,nosuid

/vol/software   -sec=sys,rw,nosuid

/vol/quorum     -sec=sys,rw,nosuid

Hope that helps,

~Glenn

manuelsanchez
3,132 Views

Thank you Sizemore!

That answers my question.

PS C:\> Get-NaNfsExport $nfs_share -Persistent |Select-Object -ExpandProperty SecurityRules

Anon            :

Nosuid          :

ReadOnly        :

ReadWrite       : {mia0lrac01.mia0.assurant.com}

Root            : {mia0lrac01.mia0.assurant.com}

SecFlavor       : {sys}

NosuidSpecified : False

PS C:\>

Public