Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Remote PowerShell - Accessing Local & Remote Files

$
0
0

Hello,

I have a file called B-Module.psm1 on a remote server with the following function.

Function DisplayContents ($ImportCsvFile,$ExportCsvFile) {

$CSV = Import-CSV -Path $ImportCsvFile

$Group = $CSV | Where-Object {$_.Group -eq "Test"}

$Group #Display Users

Read-Host "Press Enter to export group of users"

$Group | Export-CSV -Path $ExportCsvFile

}

I've created a PSSessionConfigurationFile called B-Config.pssc1 and registered it under the Configuration Name of B-Test.

Now, a user opens up a remote PowerShell session with my remote server.

$Creds = Get-Credential

$Session = New-PSSession -ComputerName computer.domain.com -ConfigurationName B-Test -UseSSL -Credential $Creds

Import-PSSession $Session

What I would like to see happen at this point is that the user run the following command:

DisplayContents -ImportCSVFile "C:\Temp\Employees.csv" -ExportCSVFile "C:\Temp\TestEmployees.csv"

The contents of the Employees.csv would be sent to the remote server, which in turn would filter the list by the Group column and then display the data.  Once the user presses enter

it exports the data back down to the C:\Temp directory as TestEmployees.csv

While this very simple function works on my local workstation, it doesn't work once I do the remote session.  It just says a drive named "C" cannot be found.

Any idea how I can make this remote module take input files from my local computer and then also export to my local computer?

Thanks,

Brian


Viewing all articles
Browse latest Browse all 6937

Trending Articles