How to execute a function in a remote computer

I am trying to execute a function in a remote desktop to install an application and change folder permissions.  The function is part of a module that is located in a shared server.  I am using the following line of code to import the module.

$session = new-possession -computername "RemoteComputer" -credential $cred

invoke-command -Session $session {import-module MyModule}

Those line import the module with no issues.  The issue is that when I try to run the function nothing happen.  I get no errors, but the application do not install either.  I am using the following code:

invoke-command -session $session {install-application}

How can I accomplish this task?  Any suggestions?

Parents
  • First, that first command would never work, as there is no such cmdlet called:

    new-possession

    8^}

    That is either a belated Halloween demon call (which PoSH is, well, u know...)
    or the spellcheck / autocorrect ghosts messing with you.

    8^}

    Now, let's be clear on this before I or anyone attempts to provide guidance.

    You are trying to call:
    --- a remote function
    --- from a remote module
    --- supposedly loaded in memory of the remote computer
    --- via a New-PSSession from your local workstation
    --- Using the user credentials passed (and hopefully has access and admin privs to install)
    ???

    Is this install for all users of the remote host or a given user? Just curious on this one.

    Why do this interactively, vs via SCCM, GPO, Task scheduled?
Reply Children
No Data