Remotely Reboot Windows from Command Line

Here’s how we do it from the command line. Should work from PowerShell too.

  1. Win+R
  2. Type shutdown /[r|s] /m \\ComputerName /c “Comment” /d [u|p] <xx>:<yy> and then press ENTER.
Value Description
/r Restarts the remote computer.
/s Shuts down the remote computer.
/m \\ ComputerName Specifies the destination computer.
/c “ Comment Enables you to comment in detail about the reason for the shutdown. You can use a maximum of 511 characters. Comments must be enclosed in quotation marks.
/d [u|p] xx : yy Lists the reason for the system restart or shutdown, where xx specifies a major reason number from 0 through 255, and yy specifies a minor reason number from 0 through 65,535.
/force Forces the computer to shut down if other users are logged in. If this is not used and other users are logged in to the remote computer, the computer will not shut down or restart.

ImportantImportant
If you force the computer to shut down or restart, logged in users will not have the opportunity to save their work.
/t xxx Sets the time-out period before the system shuts down or restarts to xxx seconds. The valid range is 0-600, with a default of 30. Using the /t flag implies the /force option.

For more detailed information about the shutdown command and additional options, type shutdown /? at the command prompt.

List SharePoint Folder Hierarchical Structure

I’m in the middle of auditing our massive SharePoint setup and I needed a way to list out in a hierarchical way the sites, sub-sites, libraries etc in an easy manor.

Remember this KISS principal? Keep It Simple Stupid.

I had a duh moment.

Remember the DOS days? Remember the tree command?

[code]

Graphically displays the folder structure of a drive or path.

TREE [drive:][path] [/F] [/A]

/F Display the names of the files in each folder.
/A Use ASCII instead of extended characters.

[/code]

Continue reading “List SharePoint Folder Hierarchical Structure”

Getting Windows Process Command Line

Windows Server 2008 and Windows 7 introduced a neat feature in the Task Manager that allows you to see the command line that instantiated the process. This is great for telling processes apart. Especially when svchost and others can have dozens of instances.

Just click View -> Select Columns and pick Command Line at the bottom.

But what if you have Windows Server 2003 or Server 2000? I found a few tricks. They’re not as clean but they work just as well.

This one just lists the processes, their PID and the “services” that are associated with them

tasklist /svc

This one makes a nice text file with much more info

wmic process get Name,ProcessId,CommandLine /format:table > wmic_task_list.txt

The text file lists the name, process id, command line and puts it in a table in a text file. Genius!

If you want to get really geeky you can see all the wmic options using this command. It can do some really nice output.

wmic process list /format /?

Hope this helps someone! I use it on a regular basis to find out why svchost is going bat shit crazy on my servers. We all know it likes to hit full cpu usage from time to time and these commands will help you find out which process is causing it.

Most often I’ve found that it has to do with Windows Updates but you never know.