How can I run a PowerShell function remotely?

Posted by Aimar on Server Fault See other posts from Server Fault or by Aimar
Published on 2012-07-09T13:08:24Z Indexed on 2012/07/09 15:17 UTC
Read the original article Hit count: 164

Filed under:

Using powershell, I plan to run many functions on a remote host to gather information.

Here is an example to retrieve the content of file remotely just by running a function called getcontentfile with the parameter as the name of the remote host:

function getcontentfile 
{
    [CmdletBinding()]
    param($hostname)
    $info = Get-Content "C:\fileinfo.xml"
    write-host $info
}

This function should return information about the remote host to the local instance of PowerShell. How can I modify this script to do that?

© Server Fault or respective owner

Related posts about powershell