Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Reply To: Invoke-Command Question on Remote File Server

$
0
0

Try it like this:

$colFS13Files = Invoke-Command -Session $sessionFS13 { Get-ChildItem d:\ -Recurse | where {$_.psiscontainer -eq $false -and $_.CreationTime -gt $date} | Select-Object fullname,length,creationtime}

foreach ($file in $colFS13Files) {
    # .. etc
}

In your original code, the $colFS13Files variable only existed in the remote session. By assigning the results of Invoke-Command to a local variable, then you can enumerate over them with a foreach loop.


Viewing all articles
Browse latest Browse all 13067

Trending Articles