when a form is shown, I try to get the files in a folder of a remote server passing a variable. This gives me an empty object. But if instead of a variable I pass a string with the path to my folder I get the correct files.
$form.Add_Shown({
$fold = 'c:/mypath/test';
#this returns no file
$files = Invoke-Command -Credential $cred -ComputerName $server -ScriptBlock {Get-ChildItem -Path $fold } ;
#this code correctly returns the files present in the folder
#$files = Invoke-Command -Credential $cred -ComputerName $server -ScriptBlock {Get-ChildItem -#Path 'c:/mypath/test'} ;
$txt.Text="files $files";
})
what could be the problem?