(As soon as I though of this post name, I had this song stuck in my head. I’m sure (hopeful!) most of you are probably old enough to remember the Windows 95 Commercial. It’s a great song and a short post so if you want a bit of background music while you’re reading then open this in a new tab and enjoy.)

Recently I wanted to get the start times for a few SQL instances I have running. I immediately thought of the Get-Process cmdlet, so I checked out the members of get-process:


Looking through this list, I noticed that there was a start-time Property.


Bingo! That's the one I need. I know that what I am looking for is the sqlservr process, so I define the executable name and pipe that into Select-Object to get the pertinent information.

```powershellget-process sqlservr | select-object name, starttime, id, productversion ```


Let's make things look neater by piping into the Format-List cmdlet.


```powershellget-process sqlservr | select-object name, starttime, id, productversion | format-list```

Tidy. So this also works for everything right?


Wrong. It looks like that you need to be running PowerShell as an administrator to access the details via Get-Process. So certain processes don't return the full list if you don't have the correct permissions. Fortunately there is a workaround to get the start time, I've yet to find a solution that supplies the product version. In this case we use the <strong>Get-WmiObject</strong> cmdlet. It's still the de-facto sysadmin cmdlet to use in routine tasks.


$a = gwmi win32_process | ? { $_.name -eq &quot;msmdsrv.exe&quot; }
$a | Select-Object name, processId, @{Name=&quot;StartTime&quot;; Expression={ $_.ConvertToDateTime( $_.CreationDate )}} | Format-List



Here’s the scripts if you want to run this remotely:

Get-Process -computername server01 sqlservr| Select-Object name, starttime, id, productversion | Format-List


[code langauge=“powershell”]

$a = gwmi win32process -computername $server01 | ? { $.name -eq "msmdsrv.exe" } $a | Select-Object name, processId, @{Name="StartTime"; Expression={ $.ConvertToDateTime( $.CreationDate )}} | Format-List


If anyone does know of a way to get the Product Version then let me know as it’s super useful to know what version I am running without going to admin mode.