Hi @Konstantin ,
You have to pass the variable to the script block.
Please try this:
$ShowDirectory = "C:\FTP"
Invoke-Command -ComputerName $serverName -Credential $cred -ScriptBlock {Get-ChildItem -Path $using:ShowDirectory | Select-Object FullName, LastAccessTime}
----------
(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)
Regards
Andreas Baumgarten