Hello World as Administrator

Good grief… I’ve spent hours trying to find a solution to:

  1. Run Powershell using WScript (solved)
  2. PowerShell launch PowerShell as Admin using Start-Process -verb runas (solved)
  3. Get Admin Powershell to Write-Host "Hello World" (not solved)
*** Please ***

The only thing I want out of this post is how to get Admin PowerShell to display “Hello World.” Nothing else.

I don’t want a long-winded, complicated explanation because it isn’t needed and I will just TL;DR. And I certainly don’t want lectured or berated on “Why are you trying to do this ?”

Thank you

So you want us to help you the way you want. OK. Without more complete information you will have to open an adminsitrative Powershell and type

Write-Host "Hello World"
That’s all you need. :wink:

I would say , before all these, you should go through some basics of PowerShell too.

@kvprasoon … you didn’t read the post of the OP carefully!! :wink: :smiley: … that’s what he did NOT wanted to get! :stuck_out_tongue:

Unfortunately, the three immediately prior posts prove my point about the general attitude and character of those who reply on this forum.

I will just say this, patronizing anyone is unhelpful. Furthermore, smugly withholding information from a poster because you don’t agree with what they’re attempting to do is unhelpful and moreover shows a lack of empathy. The effort to turn my original post back on me as if I’m the problem shows a lack of credibility.

I teach university engineering. Students that come to me just want their questions answered - directly and efficiently. It’s that simple.

Anyway, thank you. I really appreciate it.

You are comming here asking for help … for free … and you claim that you teach students … you should know that it is not possible to learn a complex technology by guessing or asking arbitrary questions about unrelated topics.

If you’re asking how to run commnds or function ALWAYS when you start an adminsitrative Powershell you should read about_Profiles. If you had at least learned the fundamentals of Powershell you would have known that already. It is beyond the scope of a forum to teach anyone the basics of a complex technology. And to know these basics is needed to ask reasonable questions and even to understand the answers.

[quote quote=143693]You are comming here asking for help … for free … and you claim that you teach students … you should know that it is not possible to learn a complex technology by guessing or asking arbitrary questions about unrelated topics.

If you’re asking how to run commnds or function ALWAYS when you start an adminsitrative Powershell you should read about_Profiles. If you had at least learned the fundamentals of Powershell you would have known that already. It is beyond the scope of a forum to teach anyone the basics of a complex technology. And to know these basics is needed to ask reasonable questions and even to understand the answers.

[/quote]

The fact that the help here is free should be irrelevant, but unfortunately across the web a lot of people have the attitude that a person has to accept help as it is provided because it is free. On the engineering forums we just get to the bottom of what the person is asking and set about answering their questions.

I did Don Jones’ books. I am only attempting to write a .vbs script that launches PowerShell as an administrator and get the elevated PowerShell to display “Hello World.” It’s the last step,

There is a propensity here for replies to go off on tangents and not solve the problem that the OP seeks to solve. They become needlessly long and convoluted.

If this forum cannot help a person to write a simple Hello World script, then there is nothing further to be said.

In my original post, I asked a simple question. Yes, I agree it might have been unclear. But you needlessly derided me because I placed restrictions on how I wanted to be helped.

I dont’ know. Those of us at university have hundreds of students come to us and ask questions. If it isn’t clear what they are asking, we ask them questions and proceed to teach them the solution. It is a simple matter of teaching problem solving or providing a solution that they understand.

Anyway, thank you. I really appreciate it.

That’s what we normaly do as well. But if you ask beginner questions you will have to deal with beginner advises. :wink:

To start the Powershell instance and run a particular script you specify the parameter -File followed by the the name of the script including the path.

To begin the original post are filled with ambiguity or at least it’s not clear enough.
E.g. what is the exact error/issue you get from what you’ve tried.
Or what is not working after you launched the admin session.

If all you want is some text on the console output then Olaf’s answer is essentially correct.
It may not be what you expected but then it’s up to you to explain what you’re after.

I would say that this is one of the more friendlier forums out there.
But that doesn’t mean that we can read your mind.

As for …

3. Get Admin Powershell to Write-Host "Hello World" (not solved)

*** Please ***

The only thing I want out of this post is how to get Admin PowerShell to display “Hello World.” Nothing else.

I don’t want a long-winded, complicated explanation because it isn’t needed and I will just TL;DR. And I certainly don’t want lectured or berated on “Why are you trying to do this ?”

This is PowerShell 101 stuff and fully documented in the built-in help files …

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/start-process?view=powershell-6

See:
Example 6: Using different verbs to start a process
Example 7: Specifying arguments to the process

…and all over the web, and directly from Microsoft.

From Microsoft from a simple search, 10 seconds to find this …

# Using a PowerShell script to run as a different user & elevate the process. https://blogs.technet.microsoft.com/benshy/2012/06/04/using-a-powershell-script-to-run-as-a-different-user-elevate-the-process

Being new is fine, even asking question, but we are also here to provide guidance, so that later, one can figure this out on their own. I get the TL;DR stuff, but a good port of the time, it is a requirement to make sure to avoid unnecessary confusion, frustration, errors, misconceptions as you are showing here.

So, what the other are saying is valid.

From the MS article above...

Start-Process powershell.exe -Credential "TestDomain\Me" -NoNewWindow -ArgumentList "Start-Process powershell.exe -Verb runAs"

# Or directly...

Start-Process powershell.exe -Verb RunAs -ArgumentList "Write-Output 'hello world'"

No one here is trying to be belligerent, just educational as well as providing answers as warranted. So, don’t take those negatively. We all learn from everyone, at any time, even it might upset us.

My take(probably who ever tried to help you here) on helping others here is to make them understand why is it so ? How it works ?, rahter than providing code for their problem, we help others to understand the problem and wil try the requestor to find the soution. Hence he/she learna problem solving skills(mostly debugging and by making them understanding the internals with what we know).

I agree not everyone would be intersted in understanding the problem first, but thats not how we should approach an issue.

As far as a learning resource this forum is definitely not that great. That’s an opinion that is shared by some of my colleagues who have also had poor experiences here.

I will admit, I didn’t explain what I was attempting to accomplish in my OP. 1, 2, and 3 were to be done within a single script.

Instead of the knowledgeable ones here asking questions to figure out what I was attempting to do, the immediate focus was on the restrictions I placed on the replies.

Well I don’t want long-winded tangents or completely needless deep-dives. I just want my specific questions answered correctly and concisely.

When a student comes to me and asks a question. I answer their specific question. I don’t give them a lecture or treatise on the subject matter. They don’t need it. They just want their specific questions answered within the context of what they are trying to do. Furthermore, I don’t tell them “How could you ask such a question,what are you doing here ? This is trivial. Go study the basics.” I don’t lord my expertise over the student and treat them in a condescending manner.

It would be different if my experience were an isolated case on this forum, but unfortunately it isn’t. Us physics and engineering types don’t get the attitude that comes from people on forums, with many of the MVPs being the worst. We’re always amazed at how many times on IT forums the immediate focus is on the student and what they’re attempting to do instead of simply answering their question effectively.

When Siddaway answers questions here, he always answers the question that the poster is asking - specifically and concisely. Don does the same. So I suppose it comes down to those that can teach and those that cannot.

Anyway, I’ve raised this issue previously a number of times on this forum and I know from those experiences that this will be just as fruitless in getting others to clean up their acts.

 

No worries, different people have different opinions and there are no forums where everybody gets satisfied.
In-fact, you you got your expected answer in the first reply from @olaf-soyk.