All windows computers list

Hey, Scripting Guy! How Can I Use Windows PowerShell to Get a List of All the Open Windows on a Computer?

February 3rd, 2007

Hey, Scripting Guy! Someone told me that there’s a way to use Windows PowerShell to get a list of all the open windows on a computer. Any chance you could show me how to do that?

Hey, JD. You bet we can. Before we do that, however, we’d like to take a moment and salute Peter Costantini, the oldest living Scripting Guy. Peter, best-known for being the author of Dr. Scripto’s Script Shop and for being the crazy guy who sings on webcasts, recently accepted a Program Manager position in the Management Practices group at Microsoft. Peter will still be a Scripting Guy; he just won’t be able to devote much time to scripting and to writing Script Center articles.

Which, all things considered, puts him on the same footing as the other Scripting Guys. But at least he has an excuse for not doing anything.

Speaking of the other Scripting Guys, we wish Peter the best of luck, and, as a special tribute, thought we’d recap some of his greatest moments as a Scripting Guy:

For example, just a few weeks ago he – well, actually, Dean did that.

But about a year ago Peter – never mind; Jean wrote that, didn’t she?

Still there was – oh, right. But if it hadn’t set the building on fire that would have been a pretty good little script.

And of course, there are many other great moments, far too, uh, numerous to name.

Note. As you might expect, Peter’s true contributions to scripting and to the Script Center can’t be measured by the amount of work he did. Or at least that’s what he keeps telling the rest of us.

On the bright side, though, the years Peter spent sitting around doing nothing useful or important made him the obvious choice for a management position at Microsoft.

To be honest, our first reaction when Peter announced he was leaving was to simply sit around and mope. (Of course, that’s usually our first reaction to anything.) But Peter wouldn’t have wanted us to act that way; instead, he would have wanted us to get on with our lives. So here you go, Peter; this one’s for you:

Читайте также:  Как удалить драйвера wifi linux

As you can see, this is a pretty simple little command. We start out by calling the Get-Process Cmdlet, which – as the names implies – retrieves a collection of all the processes running on the computer. Of course, we don’t really want a collection of all the processes running on the computer; after all, that collection includes services and other processes that aren’t running in a visible window. Therefore, we “pipe” that collection to the Where-Object Cmdlet, and ask Where-Object to filter out all processes except for those where the MainWindowTitle property is not equal to an empty string.

Note. Yes, we know: in Windows PowerShell you use the –ne operator instead of <>. And no, it doesn’t matter whether we like using –ne; we just have to use –ne.

What’s that going to do for us? That’s going to weed out services and other processes that don’t run in a visible window (if there’s no window then MainWindowTitle will be equal to an empty string). We then pass this filtered collection to the Select-Object Cmdlet and ask Select-Object to display only the MainWindowTitle property:

Nice observation: you won’t find the MainWindowTitle property anywhere in WMI’s Win32_Process class. That’s because the Get-Process Cmdlet doesn’t use WMI to retrieve process information; instead, it uses the .NET Frameowork class System.Diagnostics.Process.

Unfortunately, there’s one minor drawback to this command: it doesn’t return any Windows Explorer windows (for example, a window open to C:\Scripts). But that’s OK; here’s another one-liner that does return Windows Explorer windows:

What we do here is use the New-Object Cmdlet to create an instance of the Shell.Application object. We call the Windows() method to retrieve a collection of Shell windows, then use the Select-Object Cmdlet to echo back the value of the LocationName property. That’s going to result in a report similar to this:

Alternatively, you can echo back the LocationURL property to get the complete path. Of course, in that case, you might want to do some cleanup work as well, seeing as how LocationURL returns paths similar to this:

But here’s a command that might be helpful in trying to clean up that string.

We hope that answers your question, JD. And in case you’re wondering, we gave absolutely no thought to stripping Peter of his Scripting Guy status after he accepted his new job. Was that in recognition of his valuable contributions to the scripting world, contributions that we expect will continue throughout the coming years? You bet it was.

Well, that and the fact that if we got rid of Peter then Greg would become the oldest living Scripting Guy, and there’s no way Greg is going to accept that. So see, Peter? We like to kid you and give you a bad time, but you’ll always fill a very important role on the team. Always.

Читайте также:  Linux org сборка клиента

Find a PC that fits

Do your best learning, working and playing with a Windows 10 PC. Find one that fits your style and budget.

Discover the benefits of a new PC

When it comes to a PC with an SSD vs. one with an HDD, some things are just better.

Up to 4x faster Up to 4x faster

1 «>Redefine your sense of speed. PCs with SSDs: 4x faster on average than HDDs. 1 Redefine your sense of speed. PCs with SSDs: 4x faster on average than HDDs. 1

Get up to 34% longer battery life¹ ² Get up to 34% longer battery life¹ ²

2 «>Because SSDs consume less power, you get longer battery life—on average, eight-plus hours of video playback. 2 Because SSDs consume less power, you get longer battery life—on average, eight-plus hours of video playback. 2

Transfer files 37.9% faster with USB 3.0 Transfer files 37.9% faster with USB 3.0

1 «>Share moments in moments. Copy large files like home videos from USB 3.0 drives 37.9% faster on average with a solid-state drive. 1 Share moments in moments. Copy large files like home videos from USB 3.0 drives 37.9% faster on average with a solid-state drive. 1

Install Windows Updates 3x faster Install Windows Updates 3x faster

1 «>Windows Updates: Install them 3x faster (on average) with a solid-state drive. 1 Windows Updates: Install them 3x faster (on average) with a solid-state drive. 1

Get started with PC hardware basics

​Learn about key PC hardware components so that you can make informed decisions when shopping for a new device.

What is it?

SSD is a type of storage drive similar to a traditional hard disk drive (HDD).

Why does it matter?

Without moving parts, SSDs are thinner, faster and more durable than HDDs, allowing for smaller PCs with greater battery life. 2

What is it?

RAM is your PC’s “working” memory.

Why does it matter?

It helps with performance when doing things like running apps and browser tabs. More RAM means you can do more things at the same time.

What is it?

The brain of your PC. It tells the other components in it what to do.

Why does it matter?

It performs the instructions the operating system tells it to. Without it, your PC doesn’t run.

What is it?

It helps your PC do graphics-intensive tasks, like photo or video editing and games.

Why does it matter?

It frees your CPU for other tasks, allowing for better performance.

Original by design

See what’s new from Surface.

Browse by PC type

If you’re still unsure on where to begin, starting with the PC type will give you a wide range to choose from.

Thin, light laptops

It’s everything you love and more—portability, power and the latest in processors.

Desktops & All-in-Ones

Get the muscle you need for demanding tasks without sacrificing style.

Versatile 2-in-1s

2-in-1s provide power and flexibility. Touch, type, click, or pen—choose whatever fits your style.

Gaming PCs

A Windows 10 gaming PC gives you more power, more features and more games.

Apps for everyone

Microsoft Store has nearly everything you could want for your Windows 10 device, including the latest games, popular films and TV programmes, creativity software, apps, 3 and more.

Find a PC that fits

Do your best learning, working, and playing with a Windows 10 PC. Find one that fits your style and budget.

Читайте также:  Linux создать пользователя удалить пользователя

Discover the benefits of a new PC

When it comes to a PC with an SSD vs. one with an HDD, some things are just better.

Up to 4x faster Up to 4x faster

1 «>Redefine your sense of speed. PCs with SSDs: 4x faster on average than HDDs. 1 Redefine your sense of speed. PCs with SSDs: 4x faster on average than HDDs. 1

Get up to 34% longer battery life¹ ² Get up to 34% longer battery life¹ ²

2 «>Because SSDs consume less power, you get longer battery life—on average, eight-plus hours of video playback. 2 Because SSDs consume less power, you get longer battery life—on average, eight-plus hours of video playback. 2

Transfer files 37.9% faster with USB 3.0 Transfer files 37.9% faster with USB 3.0

1 «>Share moments in moments. Copy large files like home videos from USB 3.0 drives 37.9% faster on average with a solid-state drive. 1 Share moments in moments. Copy large files like home videos from USB 3.0 drives 37.9% faster on average with a solid-state drive. 1

Install Windows Updates 3x faster Install Windows Updates 3x faster

1 «>Windows Updates: Install them 3x faster (on average) with a solid-state drive. 1 Windows Updates: Install them 3x faster (on average) with a solid-state drive. 1

Get started with PC hardware basics

Learn about key PC hardware components so that you can make informed decisions when shopping for a new device.

What is it?

SSD is a type of storage drive similar to a traditional hard disk drive (HDD).

Why does it matter?

Without moving parts, SSDs are thinner, faster, and more durable than HDDs, allowing for smaller PCs with greater battery life. 2

What is it?

RAM is your PC’s “working” memory.

Why does it matter?

It helps with performance when doing things like running apps and browser tabs. More RAM means you can do more things at the same time.

What is it?

The brain of your PC. It tells the other components in it what to do.

Why does it matter?

It performs the instructions the operating system tells it to. Without it, your PC doesn’t run.

What is it?

It helps your PC do graphics-intensive tasks, like photo or video editing and games.

Why does it matter?

It frees your CPU for other tasks, allowing for better performance.

Discover the latest PC innovations

From powerful productivity and security to thinner devices with stunning touch screen displays, Windows 10 PCs provide what you need to get the job done. 3

ASUS ZenBook Pro Duo

HP Spectre x360 15

Lenovo Yoga C940

Browse by PC type

If you’re still unsure on where to begin, starting with the PC type will give you a wide range to choose from.

Thin, light laptops

It’s everything you love and more—portability, power, and the latest in processors.

Desktops & All-in-Ones

Get the muscle you need for demanding tasks without sacrificing style.

Versatile 2-in-1s

2-in-1s provide power and flexibility. Touch, type, click, or pen—choose whatever fits your style.

Gaming PCs

A Windows 10 gaming PC gives you more power, more features and more games.

Оцените статью