Microsoft Virtualization Discussions

Remove-NaDirectory is not working on Dierctories that are not empty.

jjd003166
5,816 Views

Hi,

I'm really new to the NetApp administration, but not so new to Powershell. I'm trying to find a way to remove a "Root" directory without needing to delete all of the Child directories first. I wrote a minor script to remove the "Share" and to remove the directory (see below). However if the directory has other directories in it the script fails. In standard Powershell there is the -f which will "force" it to delete the folder and all of the folders/files under it. How can I do it with the NetApp powershell commands?

Remove-NaCifsShare PSTEST_1st

Remove-NaDirectory /vol/vfiler5_data/PSTEST_1st

1 ACCEPTED SOLUTION

vinith
5,816 Views

Hi John,

Would this help?

Here i have a cifsshare called testshare which has a bunch of directories in it and also some directories within those directories itself

Now using Get-ChildItem and Remove-Item i recursively delete all the folders present in the share.

Get-ChildItem //$ControllerName/$Sharename -Recurse | ForEach-Object { Remove-Item -Recurse $_.fullname -force }

Now if do a Read-NaDirectory i see that all the directories and sub directories get deleted recursively indeed.

View solution in original post

4 REPLIES 4

vinith
5,817 Views

Hi John,

Would this help?

Here i have a cifsshare called testshare which has a bunch of directories in it and also some directories within those directories itself

Now using Get-ChildItem and Remove-Item i recursively delete all the folders present in the share.

Get-ChildItem //$ControllerName/$Sharename -Recurse | ForEach-Object { Remove-Item -Recurse $_.fullname -force }

Now if do a Read-NaDirectory i see that all the directories and sub directories get deleted recursively indeed.

jjd003166
5,814 Views

Yes that worked like a champ.

Thank you for the assistance.

vinith
5,816 Views

Glad i was able to help you out.

BISHTECHIT
5,816 Views

  Hello Vinith,

I have been following you and - have put to use - many of your scripts and suggestions - so I am hoping you can help me with a bit of learning -

I was tasked with the removal of a 1TB qTree - I come across your script when I needed to learn how to remove existing directories - but then was cautioned about what might happen if I deleted all the data at once(..it rolls into the snapshot area. The aggregate does not have enough space to grow the volume and snapshot area to allow for a massive delete...)  I came across this document which seems to reference the issue [TR-3483 "Thin Provisioning in a NetApp SAN or IP SAN Enterprise Environment"

http://www.netapp.com/us/library/technical-reports/tr-3483.html]

- my question is this - how what is the best way to prevent <autogrow-delete> while doing a fairly routine task of storage administration?

Thanks for you time and keep the great scipts coming!

Regards,

Peter

Public