question

Doria avatar image
0 Votes"
Doria asked RichMatheisen-8856 commented

PsExec and PS.

Hi everyone!

Can I open a system prompt remote shell like we do with the PsExec tool using PS?

Hope I was clear enough.


Thanks.
Doria

windows-server-powershell
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

LeonLaude avatar image
0 Votes"
LeonLaude answered LeonLaude commented

Hi @Doria,

Not sure I fully understood you, do you want to run a PowerShell as the local SYSTEM user?

If this is the case you can do it with the help of both PS and PSExec:
https://powershell-guru.com/powershell-tip-53-run-powershell-as-system/


If the reply was helpful please don't forget to upvote and/or accept as answer, thank you!


Best regards,
Leon

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Not exactly. I want to know if PS can do what PsExec does...


Thanks.

0 Votes 0 ·

By default there is no way to achieve this, but with third-party tools/PowerShell modules it is possible.

0 Votes 0 ·
RichMatheisen-8856 avatar image
0 Votes"
RichMatheisen-8856 answered

You can create a PowerShell "session". New-PSSession and Enter-PSSession are the cmdlets to use from the local machine. You'd then be able to use the cmdlets on your local machine to effect changes on the remote machine. If you don't have the PowerShell modules on the local machine you can use Import-PSSession and run the module code on the remote machine on your local machine.

If you don't actually need the shell, you can use Invoke-Command from the local machine to run scripts on the local (or another remote) system on target machine.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Doria avatar image
0 Votes"
Doria answered RichMatheisen-8856 commented

I need to connect to a virtual machine and change its network address. Is it possible to do it using Invoke-Command?


Thanks.

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Yes this is possible to do but note that when changing the IP address of a remote computer it might become unresponsive.

0 Votes 0 ·

Unless the VM has multiple NICs, or multiple IP addresses assigned to a single NIC, and you change the IP address of the NIC you're connected to, you'll be disconnected. You very likely won't see the results of the change in the disconnected session, and until the NIC is "reoriented" in DNS (which you'll have to do), NetBIOS, switches, etc. the machine probably will act like it's offline. Eventually the machine will reappear.

0 Votes 0 ·