11

This question type is characterised by:

  1. Interacting with another program, not counting code which calls an API - can be any part of Windows or any part of any third-party program. Distinctly not "how do I use this third party API to do something", instead "here is a setting, how can I read or change it?" where there may or may not be an API.
  2. Often involves a screenshot or text description of how to do the change or where to see the value in a GUI. Sometimes doesn't even have that, only has "I want to do X" style description. Description is not code related ("I want to sort a binary tree"), it's task related ("I want to see what the Windows uninstall dialog shows").
  3. Nearly always asked with no visible research or attempt to solve it.
  4. The task is a completely reasonable task to do with PowerShell.

And it's the last bit which has me asking here. If they said "I have this API to work with, how do I use it?" that would be on-topic, albeit maybe low quality. If they said "I have found my own way of interacting with X random program or setting and here is my code?" that would also be on topic.

But the kind of question I'm thinking of is more a request to "reverse engineer this for me" and that feels off-topic, not a programming question at all. But it's ultimately a request for code, and design questions can be on-topic so maybe it is on topic?

PowerShell is often used to control other programs - Excel, IE, Outlook, registry changes, config file changes, so that in itself isn't bad, those questions come up a lot too.

e.g.

I want to edit Security Setting (enable/disable etc) for Security option in Local Security Group from Powershell or cmd. - Edit Security Options in Local Security Group cmd/powershell

and

I know how to do [this SharePoint task] manually (Edit page --> Edit web part --> Choose refiners, etc) [..] Is there a way using Powershell? - Sharepoint 2013 - Modify the Search Refinement panel without using the GUI

and

Screenshot of windows GUI, "how to change this value in PowerShell?" - Com+ Object change Memory limit with powershell - this question is a slight exception becuase the author self-answered with code, but would the question be on-topic?

and

How do I use powershell to get through a Next -> Next -> Finish wizard? - Click button with PowerShell

and

How to launch camera app from my windows 10 app programmatically WITH option to select the device? - How to launch camera app from my windows 10 app programmatically WITH option to select the device?

and

I need a way to determine if a scanner is plugged into a unit, the scanner is USB and there is no telling what port it is plugged into. this script would be run on only windows units, win7 and above - Script to determine if a usb fujitsu scanner is plugged into a unit

and

Is it possible to get windows service password with Powershell? - Is it possible to get windows service password with Powershell?

and

Can you Please help me with a PowerShell script to login into windows machine and check last reboot details? - Powershell script for windows logon

and

Here's a list of Windows Explorer settings, how can I change them in PowerShell? - Configure Windows Explorer Folder Options through Powershell

I often downvote them for the reason "no research effort shown", but is that in itself enough reason to closevote as well? My Meta question is, are they valid programming questions? Relative to the close-vote reasons:

  • They are not duplicates, it is usually clear what they're asking, the scope of a possible answer is not automatically too broad for an SO question/answer (although some specific ones might be), and they're not opinion-based.
  • They're not about networking infrastructure, seeking debugging help, code with typos, or belong on another site.
  • They are about general software - but they are asking in a programming / scripting / automation context, so I think that doesn't apply.
  • They aren't exactly asking for a tool or tutorial or off-site resource, but maybe that's arguable.

AFAICT they boil down to "reverse engineer this for me" and I say that's not a programming question. Is it? Or am I making a distinction without merit?

And if there is a distinction and they are off-topic, for what reason?

5
  • Related discussion: meta.stackoverflow.com/questions/274630/…
    – Kara
    Commented Jun 8, 2017 at 19:43
  • @Kara good link; I looked a bit but the main one I found was specific to homework - meta.stackoverflow.com/q/250867/478656 . I'm more trying to focus on the interaction with other programs. stackoverflow.com/q/28602301/478656 the answer turned out to be using a tool, so the question and answer become nothing to do with programming, was that in itself off-topic, regardless of the "do my work for me" aspect? Commented Jun 8, 2017 at 19:52
  • 1
    All those questions should be closed as Too Broad as we would need to do all the work, except maybe the last one due to seemingly being useful for a significant number of users.
    – rene
    Commented Jun 8, 2017 at 20:06
  • A fair portion of many programming tasks will involve interaction with other systems(OS, applications, databases, filesystems). Would it be any different if it were about Python, Ruby, or Lua?
    – Booga Roo
    Commented Jun 11, 2017 at 0:34
  • @BoogaRoo "how do I connect to a database using ODBC in Ruby" seems like a thing lots of people do, where the Ruby part is important. "How do I parse MySQL database files in Ruby" seems like a very different reverse-engineering MySQL file structure task, where the Ruby part is almost irrelevant to the main bit of the question. I don't know if it would be different. Commented Jun 11, 2017 at 16:41

3 Answers 3

10

PowerShell is on topic

There is no useful way to distinguish between PowerShell scripting and PowerShell usage because PowerShell is both a scripting engine and a REPL. A user could literally just lie and say they're putting it in a script, and we'd be none the wiser. This isn't much different than Ruby or Python. It's certainly not different than bash, which we have quite a number of on topic questions for. Additionally, SO explicitly broadens its scope to "tools commonly used by programmers," and PowerShell clearly falls into that category.

As such, questions about PowerShell commands should be viewed as programming questions. Full stop. Trying to distinguish between "programming" and "non-programming" PowerShell questions is both counterproductive and a waste of time and energy. If a PowerShell programmer can reasonably answer the question and the answer is likely to save future readers time and effort, there's no reason to not just let a PowerShell programmer answer the question. Trying to do this is unnecessarily pedantic and completely unenforceable.

This might result in some questions that could be asked on SO and on SU. That's fine. Cross-site dupes are a thing on StackExchange, and they don't pose a problem. Sometimes, the different audiences provide different insights, and that's useful.

No effort

These questions should be treated the same way they would if it were about another language. Is the scope narrow enough to provide an answer? If yes, it's on topic (although possibly worth a downvote if the answer should be obvious). If no, it's Too Broad. Several of your examples fall into the Too Broad category because they ask for too much and couldn't be effectively answered in a single SO post.

I would also caution that no apparent effort doesn't necessarily mean there's no effort. I've run into quite a few things in PowerShell that are poorly documented, and it can be hard to get traction finding the info you need. So before you downvote, consider whether it's possible that the OP looked and simply didn't find any leads. This might be the case occasionally.

Your examples

  • Security Setting: Your specific example is Unclear and probably Too Broad. It's hard to even figure out what they mean, but it seems like they're asking for some general scheme for a lot of different settings. As a counter-example of a good security setting question, try How to enable FIPS on windows 7; it is both on topic and useful because it is clear and narrowly scoped. I have personally used the information there to temporarily disable FIPS in a script so I could run a particular executable (with permission to do so from the security team).

  • Sharepoint: This one is probably Too Broad. It's basically a "write my script for me" question. It's closed as belonging on SuperUser, but it probably wouldn't fly there, either. It's definitely asking about scripting in PowerShell, so it's "programming" even in the strictest sense. I think the close voters just latched onto the wrong reason here.

  • Change COM object memory limit: I don't see a problem here. It's narrowly scoped and answerable. The OP had a task, probably couldn't find anything explaining how to do it, probably had some trouble figuring it out, and hoped to one day save somebody the hassle. This question is fine, even if it's not useful to very many people.

  • Camera App: This one is pretty border line for me. The OP has given us a specific command that does part of what they want, so I think we can give them the benefit of the doubt that they're "programming." (See first section.) I can't really make a decision here because I don't know enough about the camera commands they're using. If there's some kind of built in option that would do this or it's easy to list them for the user to select one, this might be narrow enough to be answerable. If it's not straightforward, then it's probably Too broad. Note that they did explicitly indicate that they couldn't find any documentation on the API in question, so they may have done some research and gotten stuck.

  • USB Scanner: Based on the comments, this looks like it's some mix of Unclear and Too Broad. The OP might be better off posting a specific question about the error they get from the potential dupe.

  • Service Password: This sounds more like just violating security than anything. At best, maybe they lost the password. It's a dumb question that should be downvoted to oblivion, but I can't see how any close reasons apply.

  • Log in and check reboot logs: This is a "Gimme teh codez" question. It falls into the Too Broad (asks to do too much) category, like most "Gimme teh codez" questions do.

  • Show file settings: At first glance, this looks Too Broad for asking several things, but the answer is actually a straightforward registry modification. The particular settings in question are also closely related. These questions that end up being registry modifications are still good questions because knowing what registry key to modify is often 90% of the battle. They're very useful to future readers, and these settings are very reasonable to script out, which brings us back to the "programming" vs. "non-programming" thing that we shouldn't be worrying about.

Bottom Line

Your instincts are dead on.

Don't try to judge a question's on-topic-ness by whether it's "scripting" or not. This is idiotic and completely unenforceable. If it can be done in a PowerShell script, just assume it will be. If it seems like something really weird to script, feel free to ask for clarification about the use case. But don't send them off to SU the first time they say they're working at the command line instead of saving a file on disk.

Instead, judge the question on the same merits you would any other script language that happens to have a REPL: is it clear, narrowly enough scoped, and otherwise possible to provide a useful answer?

5
  • "distinguish between PowerShell scripting and PowerShell usage" - I wasn't trying to, I was trying to distinguish between "How do I get a file path in powershell" (a task lots of people do, primarily programming) vs. "how do I parse the NTFS MFT .. in powershell" (a primarily reverse engineering question where the programming bit is the least of it). Or "How do I connect to a database in PS" (common, on-topic), vs. "I've connected to a SolarWinds DB in PS, how do I query it for computers without hotfix xyz?" (primarily reverse engineering a DB schema, regardless of language). Commented Jun 13, 2017 at 1:01
  • Here's one today: stackoverflow.com/q/44510652/478656 - screenshot of SysInternals Process Explorer, "how do I get this textbox value in PowerShell". As you say "This isn't much different than Ruby or Python." - so if we take away the programming language, we're left with a raw question of "dig into this closed source third party program for me" - is that on-topic, that's the kind of thing I'm trying to ask. NB. I don't think SU would be the right place for any of them either. Commented Jun 13, 2017 at 1:04
  • (And if we say it's not much different than for other languages, does that make the question a dupe of stackoverflow.com/q/6520428/478656 or stackoverflow.com/q/6530565/478656 because the question is the same only the language is different ) Commented Jun 13, 2017 at 1:11
  • 1
    @TessellatingHeckler Right, and the way to judge questions is independent of the language. Is it clear enough, narrow enough in scope, and otherwise answerable under normal SO guidelines? Parsing an entire NTFS MFT sounds Too Broad, off hand. Querying a particular schema without details on the schema is Unclear; if they provided the schema, then it's still Unclear what the actual trouble is. Those questions are not practically answerable, and that has nothing to do with the fact they're working in PowerShell.
    – jpmc26
    Commented Jun 13, 2017 at 6:42
  • @TessellatingHeckler I'm having trouble finding it, but there's a quote somewhere on StackExchange's meta or blogs to the effect of, "Sometimes, whether a question is on topic depends on the answer." For a lot of the, "How do I do this in PowerShell?" kinds of questions, it really just depends on whether there's a reasonably small interface for doing it. Modifying a registry key is reasonably scoped. Writing a 2000 line script isn't. If you have the expertise in Windows and PowerShell to tell the difference, use it. If not, I would leave the close voting to those that do.
    – jpmc26
    Commented Jun 13, 2017 at 7:07
3

I'm not sure there are any PowerShell usage questions that are still on-topic here. I would close such questions as being relevant on Super User

My rule of thumb

  • Writing programs or using programs/tools to write programs - Stack Overflow

    I have this script in PowerShell and here is the problem...

  • Installing/configuring/running programs (even the aforementioned tools) - Super User

    I want to edit Windows settings using PowerShell

13
  • 5
    Seriously, the majority of those questions should be closed, too broad being the most likely candidate, but not migrated. Let's not make our friends over at SU mad at us ....
    – rene
    Commented Jun 8, 2017 at 20:11
  • @rene Aww, you always spoil the fun. I edited the tag info to clarify usage, though (there was none at all)
    – Machavity Mod
    Commented Jun 8, 2017 at 20:13
  • 8
    Yes, thanks. I'm known for spoiling fun, I assume you knew that by now...
    – rene
    Commented Jun 8, 2017 at 20:16
  • Easier said: would I be doing this if I was not a programmer?
    – Braiam
    Commented Jun 8, 2017 at 20:59
  • 2
    SU Mod viewpoint: We don't write scripts on Super User either. That kind of question gets instantly closed as too broad. I may add the following comment "If you tell us what you have tried so far (include the scripts/code you are already using) and where you are stuck then we can try to help with specific problems." Commented Jun 8, 2017 at 22:58
  • From the PS tag "Questions about administrating Windows should be asked on superuser.com." will result in all your crap coming to SU :/ Commented Jun 8, 2017 at 23:05
  • If they haven't made any attempt to write some kind of script then please don't migrate them. Commented Jun 8, 2017 at 23:06
  • Just to be clear, we should always close the bad ones. But SU migration is pretty rare. We have an OT closure reason we prefer instead
    – Machavity Mod
    Commented Jun 8, 2017 at 23:29
  • @Machavity I got this as an audit a few weeks back, marked to close as off-topic general programming/networking and failed the audit, so policy is inconsistent. Commented Jun 10, 2017 at 14:04
  • 3
    How is PowerShell usage distinct from PowerShell scripting? These are bad questions, but anything that can be done can be scripted.
    – jpmc26
    Commented Jun 11, 2017 at 7:31
  • @jpmc26 If there's code, it's on topic. We help with coding. Using the script? Generally SU or SF
    – Machavity Mod
    Commented Jun 11, 2017 at 13:42
  • 1
    @Machavity What's the difference between a command and code in PowerShell? What if they're "using the script" by calling it from another script? Is it coding, then? That distinction is completely unenforceable, and it isn't useful. PowerShell scripting and PowerShell usage are exactly the same. Do you try to draw that distinction for bash?
    – jpmc26
    Commented Jun 11, 2017 at 19:30
  • @snakecharmerb That question is on topic because it's basically about getting Chrome to work right with a dev server. That would be on topic as a common development task even if they had used the GUI to solve the problem. It's on par with asking a Visual Studio question.
    – jpmc26
    Commented Jun 11, 2017 at 19:46
2

TLDR;

  • PowerShell Scripting (a.k.a. Programming): On topic
  • PowerShell Usage: Off-topic.

The challenge, sometimes, is in how to tell the difference.


I believe the general rule of thumb should be driven by the MRE in question:

  • If the question cannot be phrased in the form of an MRE, then it's likely too broad a question or a usage question.

  • If the MRE can only be demonstrated in the interaction of multiple commands (i.e. a script), then it's likely a "programming" question.

  • If the MRE reduces to a single command, or even to a (short) one-liner (e.g. one command piped to another), then it's likely a "usage" question and should be redirected to (most likely) Super User. This, IMHO, is the case even if the question author is attempting to use that single command inside a script.

  • If the MRE one-liner is reasonable complex (and again, the question/problem can only be demonstrated in that context), then it may cross the boundary into "programming". I generally try to provide as much grace on this wherever possible, so I usually consider these on-topic.

  • If the MRE is about configuration (e.g. oh-my-posh for a prompt), then it's likely a "usage" question, unless such configuration must be performed through the use of an MRE which reduces to a multi-line script.

While there seem to be different questions on Meta about PowerShell (this one) and Linux shell questions, there's really no distinction in my mind. PowerShell is the primary shell for Windows just like bash (or POSIX sh) is the primary shell for Linux. The rules should be the same for both. My guidance here is more in line with what I see in the other "Linux" answer here on Meta.


I came across this today with a question about why dir was showing results in PowerShell (console), but not in Windows Terminal. Even without seeing the answer (turns out that the user was in a directory with only hidden files when they were trying it from Windows Terminal), it was clear to me given my decision-tree above that this was not a programming question, regardless of whether the OP is trying to use the dir command in a script (which wasn't stated in the question). The MRE reduced to a single command, so it, IMHO, is "usage", not "programming".

But I commonly come across the same decision tree when answering Linux shell questions (especially regarding WSL).


In an older answer here, @jpmc26 says:

There is no useful way to distinguish between PowerShell scripting and PowerShell usage because PowerShell is both a scripting engine and a REPL. A user could literally just lie and say they're putting it in a script, and we'd be none the wiser. This isn't much different than Ruby or Python. It's certainly not different than bash, which we have quite a number of on topic questions for.

I would submit that a programming language, even interpreted, (e.g. Python, Ruby) is designed primarily for interpreting programs (the default mode is not the REPL), and is by definition pretty much always on-topic here.

A shell is designed primarily for interpreting commands (either built-in or external) and its primary mode of operation is interactive use. There are even shells that I've come across that haven't gotten around to implementing scripting (which I personally abandoned as soon as I learned that fact).

There are plenty of applications which include interpreters for scripting, along with command-line modes which accept commands (or even multiple commands). I'll throw out Vim or Emacs as examples, but there are plenty of others. We wouldn't accept questions regarding command-line commands for those as being on-topic here. Some people probably wouldn't even consider scripts for these applications as on-topic.

Additionally, SO explicitly broadens its scope to "tools commonly used by programmers," and PowerShell clearly falls into that category.

Yes, that's problematic, but it is covered in more detail in this question and its answers. The general consensus is that there has to be some common sense applied to that statement, since taken to the extreme, "Windows" is a tool commonly used by programmers. You might consider that a silly example, but where is the line? WSL and Windows Terminal are both even primarily used by programmers, but no one considers a question regarding their installation or configuration to be on topic here.

So no, I don't believe that the "commonly used by programmers" statement means that all PowerShell questions are automatically on-topic.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .