Hi guys, I know this question has been asked several times but the examples and source code aren’t providing any clarity on a migration path to v3. The biggest frustration seems to be around how to move from server-side processing where we run powershell cmdlets and pump the output to Out-UDGridData. If anyone could provide an example of migrating the following code (I’ve built this from scratch to include the components I’m reading other people struggling with) I think it would help several people on this forum out and I’d personally be very appreciative.
In essence, the code runs a Get-WhateverCommand that returns a list of users connected to a system. That list of users is printed to table along with a button that calls a function to log the user off when required.
V2 code needing conversion to v3:
$MyPage = New-UDPage -Name "User disconnection system" -Icon building -Content {
New-UdGrid -Title "Users logged on" -Headers @("User", "Disconnect User") -Properties @("UserName", "DisconnectSession") -AutoRefresh -RefreshInterval 900 -Endpoint {
#The below powershell modules are available to the whole system
Import-Module MyModule1
Import-Module MyModule2
$UserList = Get-Content -Raw c:\inetpub\poshud\usersessions.json | ConvertFrom-Json
$(Foreach ($User in $UserList) {
Get-UserSession -ComputerName $User.ComputerName -ErrorAction SilentlyContinue | ForEach-Object {
[PSCustomObject]@{
Server = $_.server.ServerName
UserName = $_.UserName
SessionID = $_.SessionID
DisconnectSession = New-UDButton -Text "Disconnect" -OnClick {New-UDEndpoint -Endpoint {
Import-Module MyModule1
Disconnect-User -Param1 $ArgumentList[0] -Param2 $ArgumentList[1] -Force -ErrorAction SilentlyContinue | out-null
Show-UDToast -Message "Disconnected successfully, please refresh your screen" -Duration 4000 -Icon check
} -ArgumentList $_.SessionID, $_.server.ServerName
}
}
})| Out-UDGridData
} -ServerSideProcessing
}