ONTAP Discussions

OnTAP 9..3x Powershell

Tas
5,107 Views

Does the Powershell toolkit support the set-location cmdlet?

 

It would be nice to be able to get a directory listing via PS, without creating a CIFS share or exporting and NFS mount.  Especially when searching for files recursively.  I am surprised that the toolkit does not support the set-location and PSDrives to OnTap shares.

Or... does it?

 

And BTW, where is the PS community for ONTAP?

1 ACCEPTED SOLUTION

mbeattie
5,086 Views

Hi Tas,

 

You should be able to use the "Read-NcDirectory" cmdlet.

 

PS C:\Scripts\PowerShell\Projects\WFA\ReversionWFA> get-help Read-NcDirectory

NAME
    Read-NcDirectory

SYNOPSIS
    List the contents of a directory.


SYNTAX
    Read-NcDirectory [-Path] <String> [-Attributes <FileInfo>] [-VserverContext <String>] [-Controller <NcController[]>] [-ZapiRetryCount <Int32>] [<CommonParameters>]

    Read-NcDirectory -Template [-VserverContext <String>] [-Controller <NcController[]>] [-ZapiRetryCount <Int32>] [<CommonParameters>]


DESCRIPTION
    List the contents of a directory.

For example...

 

PS C:\> get-help Read-NcDirectory -examples

NAME
    Read-NcDirectory

SYNOPSIS
    List the contents of a directory.


    --------------  Example 1 --------------

    C:\PS>Read-NcDirectory /vol/vol1

    List the contents of volume 'vol1'.

    Name      Type      Size    Created   Modified Owner Group Perm Empty
    ----      ----      ----    -------   -------- ----- ----- ---- -----
    .         directory 4 KB 11/14/2011 11/14/2011     0     1  700 False
    ..        directory 4 KB  10/3/2011 11/14/2011     0     1  777 False
    .snapshot directory 4 KB 11/14/2011 11/14/2011     0     0  777 False
    hosts     file         0 11/14/2011 11/14/2011     0     0  644
    users     directory 4 KB 11/14/2011 11/14/2011     0     0  755 False

hope that helps

 

/Matt

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

View solution in original post

4 REPLIES 4

mbeattie
5,087 Views

Hi Tas,

 

You should be able to use the "Read-NcDirectory" cmdlet.

 

PS C:\Scripts\PowerShell\Projects\WFA\ReversionWFA> get-help Read-NcDirectory

NAME
    Read-NcDirectory

SYNOPSIS
    List the contents of a directory.


SYNTAX
    Read-NcDirectory [-Path] <String> [-Attributes <FileInfo>] [-VserverContext <String>] [-Controller <NcController[]>] [-ZapiRetryCount <Int32>] [<CommonParameters>]

    Read-NcDirectory -Template [-VserverContext <String>] [-Controller <NcController[]>] [-ZapiRetryCount <Int32>] [<CommonParameters>]


DESCRIPTION
    List the contents of a directory.

For example...

 

PS C:\> get-help Read-NcDirectory -examples

NAME
    Read-NcDirectory

SYNOPSIS
    List the contents of a directory.


    --------------  Example 1 --------------

    C:\PS>Read-NcDirectory /vol/vol1

    List the contents of volume 'vol1'.

    Name      Type      Size    Created   Modified Owner Group Perm Empty
    ----      ----      ----    -------   -------- ----- ----- ---- -----
    .         directory 4 KB 11/14/2011 11/14/2011     0     1  700 False
    ..        directory 4 KB  10/3/2011 11/14/2011     0     1  777 False
    .snapshot directory 4 KB 11/14/2011 11/14/2011     0     0  777 False
    hosts     file         0 11/14/2011 11/14/2011     0     0  644
    users     directory 4 KB 11/14/2011 11/14/2011     0     0  755 False

hope that helps

 

/Matt

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

Tas
5,074 Views

Yes, thank you, I can use the read-ncdirectory.  However, that cmdlet does not have a recursive option, which I was able to find.  It would be great to be able to run file system queries such as the ones I can get from 'XCP', 'du', or 'dir', via PS.  I think the PSprovider would be the best place to put it, but I don't know how hard that would be.

 

Thank you

TasP

Tas
5,021 Views

So, who is marking conversation as Solved, when I have not done so myself?  I certainly hope it isn't NetApp.

 

I am very disappointed with the direction of the Community forums.  They are becoming less helpful with each re-structuring.  And honestly, why would someone mark a conversation as SOLVED, when I clearly stated in my response, that it was not.  That is not the way to foster participation in the Community, that is the way to have customers looking at other vendors.

 

Tas P.

mbeattie
4,997 Views

Hi Tas,

 

Yes it would be nice if there was a PS provider for an ONTAP file system similar to browsing the registry or AD etc, unfortunatley that's not the case. The set-location cmdlet can't be used to browse the file system. The only way to achieve this via PowerShell is to recursivley call Read-NcDirectory within a function or use the "file-list-directory-iter" ZAPI. I wouldn't recommend doing this on a large volume with a high file count though as you might impact CIFS latency.

 

/Matt

 

P.S: I didn't mark this thread as answered. The forum is moderated (not by me)

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.
Public