Lets Share

My personal place to share knowledge about Sitecore, Powershell, Amazon Web Services and .NET

How to list Sitecore resources with PowerShell?

posted by Robert Senktas   | 27-06-2018

list-sitecore-stuff During development, your local environment is getting messy with each new project and Sitecore release. With the passage of time, we can forget about our Solr, Mongo and Sitecore instances.





Services List

With PowerShell, you can quickly list all resources required by Sitecore like Solr, Mongo and xConnect services. The following snippet list your services and displays status, name and path where are they installed:

Write-Host "SQL" -ForegroundColor Green
Get-Service *SQL*

Write-Host "SOLR" -ForegroundColor Green
Get-Service *solr* 
(gwmi win32_service|?\{$_.name -like "*solr*"}).pathname

Write-Host "Mongo" -ForegroundColor Green
Get-Service *mongo*
(gwmi win32_service|?{$_.name -like "*mongo*"}).pathname

Write-Host "xConnect" -ForegroundColor Green
Get-Service *xconnect*
(gwmi win32_service|?{$_.name -like "*xconnect*"}).pathname


Sitecore instances

You can also list your Sitecore instances, with website name and physical path.

Get-WebSite | ForEach-Object { 
    
    $binPath = Join-Path -Path $_.PhysicalPath -ChildPath "bin\Sitecore.Kernel.dll" 
    $item = Get-Item -Path $binPath -ErrorAction SilentlyContinue

    if( $item -ne $null )
    {
        "Sitecore Site: Name:$($_.Name), Version: $($item.VersionInfo.FileVersion), Path  $($_.PhysicalPath)" 
    }
}

Environment variables

During Solr installation two environment variables are important JAVA_HOME and SOLR_HOME. If they are wrong, you can make trouble during Sitecore installation.

[environment]::GetEnvironmentVariable("JAVA_HOME")
[environment]::GetEnvironmentVariable("SOLR_HOME")

Summary

As you can see you can easily list all Sitecore resources with a few simple PowerShell commands.
list-sitecore-stuff

Did I miss something? You have some additional resources to check? Or ideas to implement? Please contribute here or share feedback with @RobsonAutomator.

Sitecore Solr, MongoDb, MSSQL Sitecore Install Extensions Powershell
This is a personal blog. All opinions here are my own opinions and do not represent my employer’s view in anyway.

Sitecore Automation Module