Greetings!
I need help with the PS script, this is my first try and the first post on this forum.
I never used or tried PS before.
I’m not sure where even to post…
I’m trying to write a PS script to get processes running on a remote computer.
Microsoft documents have this example:
“Get-Process -Name PowerShell -ComputerName localhost, Server01, Server02”
But like everything at Microsoft, it is confusing and not clear.
I tried this:
Get-Process powershell -ComputerName someone-desk2
Get-Process powershell -someone-desk2
Get-Process powershell -ComputerName localhost,someone-desk2
Nothing is working…
Thank you
First of all … Please when you post code, error messages, console output or sample data fromat it as code using the preformatted text button ( </> ).
Thanks in advance.
Unfortunately that’s not a helpful description. What exactly happens? Do you get error messages? If yes please show them (formatted as code )
Greetings!
I have the user name and the password for the systems, I can map a drive to my server and copy/paste anything to it. I do not think it is a firewall. I also enabled “PowerShell remoting” on the remote host to see if it’ll help, still not working. I started sinking if I could start a ‘program’ on a remote host. I found this script online : powershell.exe -c "$user='WORKGROUP\John'; $pass='password123'; try { Invoke-Command -ScriptBlock { Get-Content C:\Users\John\Desktop\secret.txt } -ComputerName Server123 -Credential (New-Object System.Management.Automation.PSCredential $user,(ConvertTo-SecureString $pass -AsPlainText -Force)) } catch { echo $_.Exception.Message }" 2>&1
I replaced ‘WORKGROUP’ with ‘DOMAIN’ in the original script.
It fails with exception error:
`powershell.exe : =DOMAIN\John : The module ‘=DOMAIN’ could not be loaded. For more information, run ‘Import-Module =DOMAIN’.
At line:1 char:1
=password123, : The term ‘=password123,’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify
that the path is correct and try again.
At line:1 char:18
=‘DOMAIN\John’; =‘password123,’; try { Invoke-Command -ScriptBlock { Get …
Thank you for taking the time to help me, I have no idea what I’m doing.
I’m not sure I’m formating the printout correctly, sorry about that! I"m using ’ </>’ button.
I really appreciate your help
Next time you click on that button FIRST and then paste your code where you will be told.
I assume you work in an AD domain environment. And I assume you have an account who is administrator on the remote pc you want to reach. Let’s try the following: You copy the following line s of code completely to your PowerShell_ISE script pane. You fill in the computer name of the remote computer you want to reach. Then you select all of the code with the mouse and hit .
I’m confused about PS and I’m confusing others Sorry about that!
Just for testing purposes, I used two systems (PCs) that both have the same account as an Admin.
Just to make sure PS scripts will work in the simplest environments. And I found they do!
I have no problem pulling a"Processes list" or starting a Python script.
Problems arrive when I’m trying to work with a remote host that does not have my user account added to the Admin group but I have a User Name and the Pass for that Remote Host to log in.
So, I need to add Credentials to my script, and that is a HUGE problem for me.
the oneliner below works great if I ran it from my laptop to my desktop (they have both have the same account)
I actually showed that in my last answer. You use Get-Credential. Please read the help completely including the examples to learn how to use it.
Some general tipps:
In order to connect to a remote computer you have to have an administrative account for the remote computer. And just because the accounts on two computers have the same name and the same password does not mean they are the same account. The “full name” of the account on computer1 is “computer1\SomeAccount” and on computer2 it is “computer2\SomeAccount”.
If you’re working in an AD domain the easiest way to connect to other remote computers is to use an account who is member of the local administrators group of those remote computers and in this way avoid the need to explicitly provide credentials for your commands or scripts.
I have read it, it is as confusing as anything created by Microsoft… Each time I’m reading their docs I’m wondering are they written by a human or some kind of typing monkey?