Microsoft Virtualization Discussions

Highlighted

Get NFS clients using powershell

I am wondering if there's a way to get connected nfs clients per volume using powershell.

I see a cmdlet for:

Get-NcCifsConnection

Get-NcIscsiConnection

But nothing for NFS.

If not,  how do I request for feature enhancement for it?

3 REPLIES 3
Highlighted

Re: Get NFS clients using powershell

Nothing for PowerShell currently, but we do have REST API support for that command.

 

You can find the REST docs and sample commands via: https://clustermgmt-ip/docs/api

 

parisi_0-1600099970883.png

 

You can also generate sample commands in that view. It creates a curl command, as well as a website URL that generates XML output. This is what it would look like:

 

parisi_1-1600100103991.png

 

View solution in original post

Highlighted

Re: Get NFS clients using powershell

Thanks @parisi    I'll use that instead.   But it still would be good if nfs connection can be added to the cmdlet.

Highlighted

Re: Get NFS clients using powershell

To add to this, since powershell doesn't really do curl or wget anymore, you can use "invoke-restmethod:"

 

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-restmethod?view=powershell-7

 

https://wilsonmar.github.io/powershell-rest-api/

 

Here’s how I got it to work in PS version4:

 

PS C:\Users\Administrator> $pwd = ConvertTo-SecureString "password" -AsPlainText -Force

PS C:\Users\Administrator> $cred = New-Object Management.Automation.PSCredential ('admin', $pwd)

PS C:\Users\Administrator> Invoke-RestMethod -method get -uri "http://10.193.67.10/api/protocols/nfs/connected-clients?svm.name=DEMO&return_timeout=15&return_records=true" -cred $cred

 

records

-------

{@{svm=; node=; server_ip=10.193.67.219; client_ip=10.63.150.51; volume=; protocol=nfs3; _links=}, @{svm=; node=; server_ip=10.193.67.219; client_ip=10.63.150.51; volume=; protocol=nfs3; _links=},...

 

Powershell 6 and later adds -Authentication, which makes the cred part easier.

Check out the KB!
Knowledge Base
All Community Forums