\nIt turns out the application is hidden, and Powershell cannot see it<\/p>\n<\/blockquote>\n<\/aside>\n
I don’t know what that means?<\/p>\n
get request?<\/p>\n
What exactly are you actually trying to do?<\/p>\n
Sounds like you are trying to launch a program on a remote machine?<\/p>\n
keep in mind powershell runs in it’s own session, you can not remotely start a program for another user.<\/p>","upvoteCount":0,"datePublished":"2021-08-10T12:56:13.000Z","url":"https://community.spiceworks.com/t/powershell-script-error/807927/9","author":{"@type":"Person","name":"Neally","url":"https://community.spiceworks.com/u/Neally"}},{"@type":"Answer","text":"
I see one issue off the bat bu someone may have already answered it…<\/p>\n
Your statement:<\/p>\n
Invoke-Command -ComputerName $servers<\/strong> -credential $users -ScriptBlock {Start-Process -name WelcomeLauncher -verbose -force}<\/p>\nShould be:<\/p>\n
Invoke-Command -ComputerName $server<\/strong> -credential $users -ScriptBlock {Start-Process -name WelcomeLauncher -verbose -force}<\/p>\nChange $servers to $server to pickup the individual server from the content list.<\/p>","upvoteCount":0,"datePublished":"2021-08-10T18:08:50.000Z","url":"https://community.spiceworks.com/t/powershell-script-error/807927/10","author":{"@type":"Person","name":"hollywood-spicehead","url":"https://community.spiceworks.com/u/hollywood-spicehead"}},{"@type":"Answer","text":"
I did see the comment about changing the servers to server. NO luck with that.<\/p>\n
Yes, the end goal is to start the application on a remote PC through the Powershell session. From the sounds of it, it does not sound like Powershell has this ability.<\/p>","upvoteCount":0,"datePublished":"2021-08-16T14:39:44.000Z","url":"https://community.spiceworks.com/t/powershell-script-error/807927/11","author":{"@type":"Person","name":"spiceuser-rebom","url":"https://community.spiceworks.com/u/spiceuser-rebom"}},{"@type":"Answer","text":"
Powershell can do anything you can manually do.<\/p>\n
Take a look at Enter-PSSession and Exit-PSSession. As long as the remote server has PS remoting enabled you can run any command locally. You just need to make sure the apps/files or whatever is needed to exist on the remote computer. You can use Powershell to copy files needed to the remote machine, start a Remote PS Session and then execute the commands against the remote computer as if you had a console or RDP session to it.<\/p>\n
Instead of using “-Invoke-Command -ComputerName $Server” you could try:<\/p>\n
“Enter-PSSession -ComputerName $Server” which connects your Powershell session to a remote computer, then do<\/p>\n
\" Start-Process -name WelcomeLauncher -verbose -force\"<\/p>\n
When you are finished do<\/p>\n
“Exit-PSSession” which will disconnect the session from the remote computer.<\/p>","upvoteCount":0,"datePublished":"2021-08-16T14:56:11.000Z","url":"https://community.spiceworks.com/t/powershell-script-error/807927/12","author":{"@type":"Person","name":"hollywood-spicehead","url":"https://community.spiceworks.com/u/hollywood-spicehead"}},{"@type":"Answer","text":"\n\n
<\/div>\n
Hollywood-SpiceHead:<\/div>\n
\nPowershell can do anything you can manually do.<\/p>\n
Take a look at Enter-PSSession and Exit-PSSession. As long as the remote server has PS remoting enabled you can run any command locally. You just need to make sure the apps/files or whatever is needed to exist on the remote computer. You can use Powershell to copy files needed to the remote machine, start a Remote PS Session and then execute the commands against the remote computer as if you had a console or RDP session to it.<\/p>\n
Instead of using “-Invoke-Command -ComputerName $Server” you could try:<\/p>\n
“Enter-PSSession -ComputerName $Server” which connects your Powershell session to a remote computer, then do<\/p>\n
\" Start-Process -name WelcomeLauncher -verbose -force\"<\/p>\n
When you are finished do<\/p>\n
“Exit-PSSession” which will disconnect the session from the remote computer.<\/p>\n<\/blockquote>\n<\/aside>\n
That will still launch the application under the remote user context, and not the end user context on the remote machine what OP wants.<\/p>\n
FOr that use case you can try to create a scheduled task that will kick of as the current logged in user or maybe try psexec (which is not powershell by sysinternals)<\/p>","upvoteCount":0,"datePublished":"2021-08-16T15:03:29.000Z","url":"https://community.spiceworks.com/t/powershell-script-error/807927/13","author":{"@type":"Person","name":"Neally","url":"https://community.spiceworks.com/u/Neally"}},{"@type":"Answer","text":"\n\n
<\/div>\n
spiceuser-rebom:<\/div>\n
\nI did see the comment about changing the servers to server. NO luck with that.<\/p>\n
Yes, the end goal is to start the application on a remote PC through the Powershell session. From the sounds of it, it does not sound like Powershell has this ability.<\/p>\n<\/blockquote>\n<\/aside>\n
you can absolutely start it, but it will not run as the current logged on user, which I assume is what you want?<\/p>","upvoteCount":0,"datePublished":"2021-08-16T15:05:00.000Z","url":"https://community.spiceworks.com/t/powershell-script-error/807927/14","author":{"@type":"Person","name":"Neally","url":"https://community.spiceworks.com/u/Neally"}}]}}
HI,
I keep running into errors below. I am just trying to pull from a txt file to start the service on remote computers through Powershell.Any ideas would be helpful.
$servers= get-content “C:\welcome\Welcome.txt”
$users= get-credential
foreach($server in $servers)
{
Invoke-Command -ComputerName $servers -credential $users -ScriptBlock {Start-Process -name WelcomeLauncher -verbose -force}}
Powershell keeps throwing the following error:
Invoke-Command : Cannot validate argument on parameter ‘ComputerName’. The argument is null or empty. Provide an argument that is not null or empty, and then try the
command again.
At line:9 char:30
Invoke-Command -computername $Servers -Credential $user -ScriptBlock …
CategoryInfo : InvalidData: ( [Invoke-Command], ParameterBindingValidationException
FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeCommandCommand
5 Spice ups
Neally
(Neally)
August 9, 2021, 6:09pm
2
Welcome
If you post code, please use the ‘Insert Code’ button. Please and thank you!
Hi, and welcome to the PowerShell forum!
Don’t apologize for being a “noob” or “newbie” or “n00b.” There’s just no need – nobody will think you’re stupid, and the forums are all about asking questions. Just ask!
Use a descriptive subject. Don’t say “Need help” or “PowerShell Help”, actually summarize what the problem is. It helps the rest of us keep track of which problem is which.
Don’t post massive scripts. We’re all volunteers and we don’t have time to read all that, nor will we copy…
1 Spice up
You need to use $server in your command, not $servers (that’s an array of all the systems returned by your query.
1 Spice up
Neally
(Neally)
August 9, 2021, 6:11pm
4
your syntax is wrong.
You mixed $user and $userS (with an ‘s’)
e.g.
$servers = get-content "C:\welcome\Welcome.txt"
$users = get-credential
foreach($server in $servers){
Invoke-Command -ComputerName $server -credential $users -ScriptBlock {
Start-Process -name WelcomeLauncher -verbose -force
}
}
$servers= get-content "C:\welcome\Welcome.txt"
$users= get-credential
Foreach ($Server in $Servers)
{
If (Test-Connection -ComputerName $Server -Count 1 -Quiet){
Invoke-Command -ComputerName $Server -Credential $users -ScriptBlock { start-process welcomelauncher.exe -force}
}}
I still get that Computername argument is null or empty error.
Neally
(Neally)
August 9, 2021, 6:38pm
6
spiceuser-rebom:
$servers= get-content "C:\welcome\Welcome.txt"
$users= get-credential
Foreach ($Server in $Servers)
{
If (Test-Connection -ComputerName $Server -Count 1 -Quiet){
Invoke-Command -ComputerName $Server -Credential $users -ScriptBlock { start-process welcomelauncher.exe -force}
}}
I still get that Computername argument is null or empty error.
What does your text file look like?
get-content "C:\welcome\Welcome.txt"
Does that return data? How about $servers?
Thanks for your help guys. I am continuing to research this issue. It turns out the application is hidden, and Powershell cannot see it. I am thinking of going down the Get-WMIC route. DO you guys have any helpful links for newbs on using get request with wmic in powershell?
grsl
(grsl)
August 10, 2021, 12:45pm
8
Summary: Microsoft Scripting Guy, Ed Wilson, talks about using WMI Query Language and Windows PowerShell to get WMI data. Hey, Scripting Guy! What is WQL? It sounds like SQL, but that does not always mean very much. I mean, General Electric and...
What is WMI / WQL and why you might need it. This is the Complete WMI query guide with WMI Explorer namespaces enumeration, Powershell and CMD query
Est. reading time: 9 minutes
Neally
(Neally)
August 10, 2021, 12:56pm
9
I don’t know what that means?
get request?
What exactly are you actually trying to do?
Sounds like you are trying to launch a program on a remote machine?
keep in mind powershell runs in it’s own session, you can not remotely start a program for another user.
I see one issue off the bat bu someone may have already answered it…
Your statement:
Invoke-Command -ComputerName $servers -credential $users -ScriptBlock {Start-Process -name WelcomeLauncher -verbose -force}
Should be:
Invoke-Command -ComputerName $server -credential $users -ScriptBlock {Start-Process -name WelcomeLauncher -verbose -force}
Change $servers to $server to pickup the individual server from the content list.
I did see the comment about changing the servers to server. NO luck with that.
Yes, the end goal is to start the application on a remote PC through the Powershell session. From the sounds of it, it does not sound like Powershell has this ability.
Powershell can do anything you can manually do.
Take a look at Enter-PSSession and Exit-PSSession. As long as the remote server has PS remoting enabled you can run any command locally. You just need to make sure the apps/files or whatever is needed to exist on the remote computer. You can use Powershell to copy files needed to the remote machine, start a Remote PS Session and then execute the commands against the remote computer as if you had a console or RDP session to it.
Instead of using “-Invoke-Command -ComputerName $Server” you could try:
“Enter-PSSession -ComputerName $Server” which connects your Powershell session to a remote computer, then do
" Start-Process -name WelcomeLauncher -verbose -force"
When you are finished do
“Exit-PSSession” which will disconnect the session from the remote computer.
Neally
(Neally)
August 16, 2021, 3:03pm
13
Hollywood-SpiceHead:
Powershell can do anything you can manually do.
Take a look at Enter-PSSession and Exit-PSSession. As long as the remote server has PS remoting enabled you can run any command locally. You just need to make sure the apps/files or whatever is needed to exist on the remote computer. You can use Powershell to copy files needed to the remote machine, start a Remote PS Session and then execute the commands against the remote computer as if you had a console or RDP session to it.
Instead of using “-Invoke-Command -ComputerName $Server” you could try:
“Enter-PSSession -ComputerName $Server” which connects your Powershell session to a remote computer, then do
" Start-Process -name WelcomeLauncher -verbose -force"
When you are finished do
“Exit-PSSession” which will disconnect the session from the remote computer.
That will still launch the application under the remote user context, and not the end user context on the remote machine what OP wants.
FOr that use case you can try to create a scheduled task that will kick of as the current logged in user or maybe try psexec (which is not powershell by sysinternals)
Neally
(Neally)
August 16, 2021, 3:05pm
14
spiceuser-rebom:
I did see the comment about changing the servers to server. NO luck with that.
Yes, the end goal is to start the application on a remote PC through the Powershell session. From the sounds of it, it does not sound like Powershell has this ability.
you can absolutely start it, but it will not run as the current logged on user, which I assume is what you want?