6

I tried some random parameters after the shutdown command in PowerShell 2.0 when I stumbled upon shutdown -y. All it seems to do is log out the user.
if any other random letter is used (that isn't a valid parameter) nothing happens. For example: shutdown -b

My question is: Does shutdown -y do anything special?

I could not find any documentation about this.

Vesper
  • 18,599
  • 6
  • 39
  • 61
Hulkerman
  • 180
  • 1
  • 7
  • 1
    maybe the command `shutdown /?`can help :D This should contain all info about the command. – Christian Sep 06 '17 at 09:06
  • 1
    @Christian I tried that, but it doesn't state any info about `-y` – Hulkerman Sep 06 '17 at 09:09
  • I don't know, where else you can find the info about it ... or it could be only an alias for `shutdown -l` ... – Christian Sep 06 '17 at 09:13
  • The documentation says "Used without parameters, shutdown will logoff the current user" so it seems like it's interpreting -y as if no parameter was passed. – Mark Wragg Sep 06 '17 at 09:13
  • @MarkWragg I also thought that might be the case, but other random (not documented) characters like `-b` or `-j` just end up displaying the same output as `-?` – Hulkerman Sep 06 '17 at 09:15

2 Answers2

4

The Windows 2000 documentation states the following:

/y: Use this switch to force a "yes" answer to all queries from the computer.

So it looks like by using -y or /y with no other switches you are doing the default behaviour of shutdown.exe, which is to logoff the user while also forcing any confirm prompts to be acknowledged with yes.

Mark Wragg
  • 22,105
  • 7
  • 39
  • 68
  • 1
    This seems like the correct answer. – marsze Sep 06 '17 at 09:17
  • 2
    yeah. looks like Windows 2000 commands are still available in windows 7-10 :'D – Christian Sep 06 '17 at 09:18
  • 2
    @Christian The guys at Microsoft try try to keep things as compatible as possible so your scripts don't break with every new version. I wouldn't be surprised if /y has still the same behavior is simply ignored for sake of compatibility. Can somebody test that? – marsze Sep 06 '17 at 09:32
1

Shutdown is not exactly a PowerShell command. It's the same shutdown.exe that also works in CMD.

Interestingly, the -y command is not mentioned in the documentation. As Mark Wragg found out, it's used to force a "yes" answer for remote shutdown. So, if no other parameters are specified, the default action (logoff user) is executed.

Another question: Why were you trying random parameters? Follow the docu and you're less likely to encounter any unexpected behavior.

marsze
  • 15,079
  • 5
  • 45
  • 61
  • I wondered what powershell would reply when I entered something that's "definitely wrong" as parameter, so I entered `shutdown -yeet` and apparently that wasn't "definitely wrong"... – Hulkerman Sep 06 '17 at 09:18
  • 1
    @Hulkerman What happens depends almost entirely on the command (or cmdlet, script, executable...). Except maybe when it's simply a syntax error like `shutdown <`. – marsze Sep 06 '17 at 09:21