Discover using powershell

dinesh91n
Tera Expert

Hi All,

I am facing the problem here with my powershell probe, whenever i try and run my powershell probe against a remote server to

discover the process, the powershell script executes on my host machine that is where the mid server is installed and not on the remote

machine

Ex. I am testing the probe with ip x.x.x.x with midserver MIDSERVER1, then the powershell runs on the host machine where the midserver is

installed and not on the remote machine x.x.x.x

Kindly let me know if i am missing anything.

1 ACCEPTED SOLUTION

dinesh91n
Tera Expert

Hi all,



I was able to achieve this by opening a remote session from the mid server to the target machine, below is the code that i used to connect



$fqdn= Resolve-DnsName $computer | Select NameHost -expandproperty NameHost



$s = New-PSSession -ComputerName $fqdn -Credential $cred



$cmd={<-----Powershell script used to get the details of applications from the Target machine------>}



Invoke-Command -Session $s -ScriptBlock $cmd



Remove-PSSession $s



View solution in original post

8 REPLIES 8

Hi Rajesh,



Thanks for the response, yes the wmi port is open and i was able to execute the above command, but the problem is i want to run a 20 line powershell   in the target machine. Is there a way to achieve it


My guess is you should be able to run a 20 line powershell   in the target machine. But it depends on what you are trying to achieve on the remote machine.



Could you please let me know what is the specific purpose? Looks like we both work for same company. Why don't you initiate a thread?


dinesh91n
Tera Expert

Hi all,



I was able to achieve this by opening a remote session from the mid server to the target machine, below is the code that i used to connect



$fqdn= Resolve-DnsName $computer | Select NameHost -expandproperty NameHost



$s = New-PSSession -ComputerName $fqdn -Credential $cred



$cmd={<-----Powershell script used to get the details of applications from the Target machine------>}



Invoke-Command -Session $s -ScriptBlock $cmd



Remove-PSSession $s



I thought of suggesting the same Dinesh. You can always create a new session on a remote machine and bind it with required credentials and invoke all of your commands within that session.



Great job!



Rajesh