NetApp Community Update
This site will enter Read Only mode on July 23 as we prepare to move to a new platform. You will still be able to view content, but posting and replying will be temporarily disabled.
We're excited to launch our new Community experience on July 30 and more information will follow soon.
Stay connected during the transition - Join our Discord community today.

Simulator Discussions

Powershell DataONTAP cmdlet New-NcDirectory

Rutul
6,251 Views

 Can we create directory inside the share which has been created already inside the volume using New-NcDirectory Command?

3 REPLIES 3

Rutul
6,244 Views

$Cluster="10.10.10.10";
$ShareName= "netapp";
$dirname="rutulshah";
$VolumeName="vol_home1";
$path="/"+"$VolumeName"+"/";
$Vserver="vser_cifs";

$username="admin";
$password="netapp123";
$PWord = ConvertTo-SecureString –String $password –AsPlainText -Force
$credential=New-Object –TypeName System.Management.Automation.PSCredential –ArgumentList $username, $PWord
Connect-NcController $Cluster -Credential $credential;
Add-NcCifsShare -Name $ShareName -Path $Path -VserverContext $Vserver;

New-NcDirectory /vol/vol_home1/$ShareName/xyz -Permission 0755 -Controller $global:CurrentNcController -VserverContext $Vserver

 

I wrote above script it is creating the folder inside share but giving error : 

 

New-NcDirectory : No such file or directory
At line:15 char:1
+ New-NcDirectory /vol/vol_home1/$ShareName/rutulshah -Permission 0755 -Controller ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (10.63.52.69:NcController) [New-NcDirectory], EONTAPI_ENOENT
+ FullyQualifiedErrorId : ApiException,DataONTAP.C.PowerShell.SDK.Cmdlets.File.NewNcDirectory

 

JohnChampion
5,193 Views

Did you try enclosing the path in quotes? Perhaps it's not parsing the variable.

 

Example:

 

New-NcDirectory "/vol/vol_home1/$ShareName/xyz" -Permission 0755 -Controller $global:CurrentNcController -VserverContext $Vserver

chvvkumar
5,218 Views

I know this is quite an old topic I am replying to, but in case any one else searching for a similar solution, here is the PowerShell command I got to work:

 

PS D:\> New-NcDirectory -VserverContext SVM_NAME  -Permission 777 /vol/root_volp/folder1/folder2

 

Note the absense of a trailing '/' in the path. Like so:

 

Capture.PNG

Public