@asulliva
THANKS FOR YOUR HELP!
It's getting closer. I have made some changes and added some comments, but I am still lacking a bit. I cannot figure out hot to iterate throught the Namespace qtree's. Currently, it is only showing the volume level Namespaces which doesn't help much.
This is what I am trying to gain.
1) If Volume is Exported (but not to default or no_access Export Policies) then list the volume and all qtrees IF they are also CIFS shares.
2) If the Volume is not exported (or is exported to default or no_access), but the qtree's are exported and shared CIFS then list just the qtree's.
I think I have 90% of it now (THANKS!) but I need the qtree namespaces to be included for a complete list.
# run - Import-Module DataOntap
# run - Connect-NcController xxx.xxx.xxx.xxx or hostname
#Get all SVM's on a Cluster
Get-NcVserver | ?{ $_.VserverType -eq "data" } | %{
$svm = $_.Vserver
#Write-Host -ForegroundColor Red "`tSVM $($svm)"
#Get all volumes from SVM
Get-NcVol -Vserver $svm | ?{ $_.JunctionPath -ne $null -and $_.VolumeExportAttributes.Policy -ne $null -and $_.VolumeStateAttributes.IsVserverRoot -eq $false } | %{
$volName = $_.Name
$junctionpath = $_.JunctionPath
$share = $false
#Determine if any CIFS shares exist on Volume
Get-NcCifsShare -VserverContext $svm -Query @{ Path = "!/" } | %{
if (($_.Path -split "/")[1] -eq $volName) {
$share = $true
}
}
$nfs_and_cifs = $false
#Check Export Policy for volume
Get-NcExportPolicy -Vserver $svm -Name $_.VolumeExportAttributes.Policy | Get-NcExportRule | %{
#If export policy is Default or No_Access, ignore it
if ($_.PolicyName -ne "default" -and $_.PolicyName -ne "no_access") {
if (($_.Protocol -contains "nfs" -and "cifs")-or $_.Protocol -contains "any") {
$nfs_and_cifs = $true
}
}
}
Write-Progress -Activity "Scanning Volume $volName"
#Check if accessible by CIFS and NFS and is a share
if (($nfs_and_cifs) -and ($share)){
Write-Host -ForegroundColor Green "`t`t$($svm):$junctionpath `t(Volume $volName)"
Get-NcCifsShare -VserverContext $svm -Query @{ Path = "!/" } | %{
if (($_.Path -split "/")[1] -eq $volName) {
write-host "`t`t`t`t$($svm):$($_.Path)"
}
}
}
}
}