Microsoft Virtualization Discussions

Powershell Close-NcCifsSessionFile not accepting value from Get-NcCifsSessionFile

OZWALKERZ
13,813 Views

Hi Folk,

 

I'm trying to automate the closing/removing of CIFS file locks, and I'm running into problems with datat ypes.

 

In particular, I do a Get-NcCifsSessionFile which gives me a set of CIFSSessionFile objects, but when I try to pass the SessionID from one of those objects to the Close-NcCifsSessionFile it tells me value is too large for an INT64 (the close session applet is expecting an INT64, but the Get is returning a Decimal)

 

My code is essentially:

 

 

 

$SearchPath = "*CBR1PSCM01 TSM errors.xlsx" 

# get a list of files open on cluster
$CIFSSessionFileTemplate = Get-NcCifsSessionFile -Template
$CIFSSessionFileTemplate.Path = $SearchPath
$Files = Get-NcCifsSessionFile -Query $CIFSSessionFileTemplate


foreach ($f in $FileList)
    {
    Close-NcCifsSessionFile -Node $f.Node  -FileId $f.FileId -SessionId $f.SessionId -ConnectionId $f.ConnectionId 
    }

 

 

It I look at the type of the SessionId, it's decimal, and from what I see it IS too long for an INT64

 

#24 PS3 H:\> $f.SessionId.GetType()
IsPublic IsSerial Name BaseType -------- -------- ---- -------- True True Decimal System.ValueType
#23 PS3 H:\> Close-NcCifsSessionFile -Node $f.Node  -FileId $f.FileId -SessionId $f.SessionId -ConnectionId $f.ConnectionId 
Close-NcCifsSessionFile : Cannot bind parameter 'SessionId'. Cannot convert value "14120473681666951262" to type "System.Int64". Error: "Value was either too large or too small for an Int64."

think this was working on an earlier version of OnTap, but it's not working with 9.2P1

 

 

NAS:     ONTAP 9.2P1

Toolkit:  V4.4  (DataONTAP module is 4.2.0)

PowerShell: 5.1

 

 

Is this a problem with the module?

 

(I'd be happy to know if there's another way to do it also!)

 

 

Cheers,


Stuart

 

 

13 REPLIES 13

asulliva
13,755 Views

Hello @OZWALKERZ,

 

Why not just pipe the object into Close-NcCifsSessionFile?

 

Get-NcCifsSessionFile -Query @{ Path = $SearchPath } | Close-NcCifsSessionFile -Confirm:$false

Hope that helps!

 

Andrew

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

OZWALKERZ
13,619 Views

Good thought, but no.

 

 

 

 

 

#14 PS4 H:\> Get-NcCifsSessionFile -Query @{ Path = $SearchPath } 

Path                                                                           ConnectionId Vserver
----                                                                           ------------ -------
<somedir>\CBR1PSCM01 TSM errors.xlsx                                                 134041239 <some vserver>

 

 

 

 

 

#15 PS4 H:\> Get-NcCifsSessionFile -Query @{ Path = $SearchPath }  | Close-NcCifsSessionFile -Confirm:$false
Close-NcCifsSessionFile : Failed to close an open file on CIFS server "<some vserver>". Reason: The parameters "-connection-id" and "-session-id" are required when "-file-id" is specified.
At line:1 char:57
+ Get-NcCifsSessionFile -Query @{ Path = $SearchPath }  | Close-NcCifsSessionFile  ...
+                                                         ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (prodnas.production.prod:NcController) [Close-NcCifsSessionFile], EAPIERROR
    + FullyQualifiedErrorId : ApiException,DataONTAP.C.PowerShell.SDK.Cmdlets.Cifs.CloseNcCifsSessionFile

 

I had already tried

 

Close-NcCifsSessionFile $f

 

with no luck, so I tried

 

$f | Close-NcCifsSessionFile

 

and they both get the same error that your suggestion got above

 

 

 

 

My guess is that the  Close-NcCifsSessionFile is expecting an INT value for the SessionId, but the Get-NcCifsSessionFile is returning a  Decimal - perhaps the get applet was updated to return a decimal, but the close applet wasn't updated to accept it?

 

 

Cheers,


Stuart

asulliva
13,568 Views

Interesting, I had (successfully) tested the pipe method with ONTAP 9.1, but don't readily have a 9.2 system available.  I'll see if I can get something deployed and tested in the near future.

 

I suspect this may be a bug either in the PowerShell module or ZAPI itself.

 

Andrew

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

OZWALKERZ
13,538 Views

Thanks Andrew!

 

I had also thought it might be bug 🙂

 

Is there a method for raising a bug for the PowerShell module, or the API? (Or does that have to come from you guys?)

 

 

Cheers,

Stuart

asulliva
13,490 Views

Not sure if there is a way for someone external to directly create a bug, but I can take care of it.

 

Happy to send you some stickers for a "bug bounty", just PM me your mailing address!

 

Andrew

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

OZWALKERZ
13,277 Views

Thanks Andrew!

 

Would the bug be visible to customers?  (If it's been created that is..)

 

I'd be interested in 'following' it 

 

Cheers,


Stuart

OZWALKERZ
12,333 Views

I Just tried NetApp PowerShell Toolkit  V4.6 (on 9.2P3) and it's still complaining about not being able to convert to a INT64

Close-NcCifsSessionFile : Cannot bind parameter 'SessionId'. Cannot convert value 
"10342516544256614983" to type "System.Int64". Error: "Value was either too large or too small 
for an Int64."


Smiley Frustrated

asulliva
12,312 Views

The bug (1142906) is still open Smiley Frustrated

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

dietermann
11,945 Views

Hi Guys,

 

(nearly) one year later and  I encountered the same bug .

I installed PSTK 4.6.0.

Any progess in this direction, maybe a new PSTK?

 

Regards

Matthias

dietermann
10,891 Views

Hi folks,

 

I found a difference between a FAS2554HA and a FAS8040HA, both running Ontap 9.3P5.

On the smaller filer I could close a file with close-nccifssessionfile.

A typical SessionID is 394064967395194693 (18 digits)

On the bigger filer I got the SessionID-to-big-for-int64 error.

A typical SessionID is 16416183591719928754 (20 digits).

This might give a hint what goes wrong, but doesnt allow for a workaround. 

close-nccifssessionfile uses the wrong type:

PS> [Int64] 16416183591719928754
Cannot convert value "16416183591719928754" to type "System.Int64". Error: "Value was either too large or too small for an Int64."

 

Regards Matthias

sysir
10,758 Views

Hitting this same bug.

Any fix in sight?

Raoul_Schaffner
10,410 Views

Hitting the same bug with PSTK 4.3 on Windows Server 2012 R2 against ONTAP 9.6P5.

Raoul_Schaffner
10,405 Views

Just checked: The bug is fixed in the recently released PSTK 9.7.1, maybe even earlier.

Cheers to all!

Public