General Discussion
General Discussion
Hello, I have a PowerShell Script
$source_vservers = Get-NcCifsServer -Controller $src
$source_vservers = $source_vservers.CifsServer
ForEach ($source_vserver in $source_vservers) {
Get-NcVol -Controller $src -VserverContext $source_vserver
}
I got allways this output:
Get-NcVol : Specified vserver not found
In Zeile:6 Zeichen:1
+ Get-NcVol -Controller $src -VserverContext $source_vserver
When I check the $source_vserver, I got an output from one SVM.
When I set the $source_verserver = "SVMname", the command works.
Has anyone an idea how can i fix the problem?
Best regards
Alex
Hi Alex
Try something like this...
$cluster = Read-Host -Prompt "Please enter the cluster name or IP Address"
$credentials = Get-Credential -Credential admin
Connect-NcController -Name $cluster -HTTPS -Credential $credentials
$svms = Get-NcCifsServer
ForEach($svm in $svms.CifsServer){
Get-NcVol -VserverContext $svm.Name
}
/Matt
Hi Alex,
Actually i suspect the issue is caused by the CIFS server name being in uppercase whereas the SVM name in ONTAP is lowercase. For example if you wanted to query a cluster for all SVM's that were running CIFS and display the volume names (excluding the root volume)...
$cluster = Read-Host -Prompt "Please enter the cluster name or IP Address"
$credentials = Get-Credential -Credential admin
Connect-NcController -Name $cluster -HTTPS -Credential $credentials | Out-Null
$svms = Get-NcCifsServer
ForEach($svm in $svms.CifsServer){
$volumes = Get-NcVol -VserverContext $($svm.ToLower())
ForEach($volume In $volumes){
If($volume.JunctionPath -ne "/"){
Write-Host $($volume.Vserver + "," + $volume.Name)
}
}
}
Example output:
Please enter the cluster name or IP Address: cluster1.testlab.local
vserver1,cifs_data_001
vserver1,cifs_data_002
vserver1,cifs_data_003
/Matt
Thank you very much.
I have found another solution, which works better:
Get-NcVserver -Controller $src | Where { $_.AllowedProtocols -eq "cifs" }
Best regards
Alex
Hi Alex,
No problem, however please be aware that by default when you create an SVM the allowed protocols attribute will enable all protocols (nfs,cifs,fcp,iscsi,ndmp). The allow protocols field doesn't necessarily mean the CIFS service is actually configured and running on the vserver. If your objective is to show data volumes for SVM's that are running CIFS then using the "Get-NcCifsServer" cmdlet would appropriate. If however you have used the allowed protocols attribute to restrict the SVM's protocols to only the services that are actually running in your environment then that would be a much easier way to filter the results.
/Matt