In the process of converting a UD Community V2.8.1 dashboard to PSU 2. The UD dashboard works using Get-SmbOpenFile and Close-SmbOpenFile but PSU has an issue with Close-SmbOpenFile.
#----- Connect to file server and get list of open files -----
$Session = New-CimSession -ComputerName $Srvr.value -Authentication Kerberos -Credential $DomainAdmin
$list = Get-SmbOpenFile -CimSession $Session
#----- Create Table of open files -----
$Columns = @(
New-UDTableColumn -Property FileName -Title "FileName"
New-UDTableColumn -Property FileId -Title 'ID'
New-UDTableColumn -Property Path -Title 'Server File Path'
New-UDTableColumn -Property ComputerName -Title 'Client'
New-UDTableColumn -Property UserName -Title 'User'
New-UDTableColumn -Property 'Close File' -Title 'Close File' -Render {
New-UDButton -Id "$btn$($EventData.FileId)" -Text "Close" -OnClick {
Close-SmbOpenFile -CimSession $Session -FileId $EventData.FileId -Force
Show-UDToast -Message "$($EventData.FileName) has been closed"
}
}
)
New-UDTable -Data $files -Columns $Columns -Title "Open File List" -ShowSort -Dense
Logged Error:
Jun 4, 2021 3:13 PM An error occurred: Cannot process argument transformation on parameter âCimSessionâ. Cannot convert the âUniversalDashboard.Models.SessionStateâ value of type âUniversalDashboard.Models.SessionStateâ to type âMicrosoft.Management.Infrastructure.CimSession[]â.
Endpoint: 528012865573
Session: 23b098cf-d4b0-4444-b92a-e237288946b6
File:
Endpoint Start Line: 2
Endpoint End Line: 5
Stack Trace: at , : line 2
The CimSession is working since I can get the list of open files I just canât close any. Any idea what the problem might be?