r/PowerShell • • May 21 '18

News Microsoft Replacing Windows with Linux for PowerShell in the Cloud

https://myitforum.com/microsoft-replacing-windows-with-linux-for-powershell-in-the-cloud/
161 Upvotes

81 comments sorted by

View all comments

Show parent comments

9

u/ka-splam May 22 '18

AFAIK, implicit remoting doesn't need a module;

$s = new-pssession -computername yourDChere -credential (get-credential)
Import-Module -Name ActiveDirectory -PSSession $s

Get-AdComputer

It "imports" a module from another computer, creating proxy cmdlet wrappers locally which work more or less exactly like the real cmdlets, but they serialize stuff and send it over the network in the background.

That serializing to XML and back again step makes it not exactly like the originals - what you get back isn't quite the same "live" objects in the same way, but I think it's good enough for many use cases.

2

u/admiralspark May 22 '18

ohhhhhhhh you just mean pssessions. I was hoping for something new that might fix the weirdness that PSSession has.

5

u/ka-splam May 22 '18

I don't /just/ mean PS Sessions, I mean the ability to import a module from a remote session to a local session, then pretend it's a local module. But if that's what you mean, then yes I think so.

0

u/admiralspark May 22 '18

Right. I'm looking for something to run code remotely, like what Invoke-Command was supposed to do with the -scriptblock/-file or whatever tags. Unfortunately it doesn't handle stuff like local variables or stdout cleanly so it requires a bunch of hacks to get it working.

6

u/ka-splam May 22 '18

Is $using: not clean enough? Do you want it to somehow make your entire local computer's memory available remotely and automagically know which memory a variable is stored in or something?

→ More replies (0)