From the SSMS, by right-clicking on the
SQL Server node and then starting a SQL Server PowerShell session, you can open a console directly in the root of the default SQL Server in the example.
From here, you can easily obtain information on the SQL Server. First, the location is set to the instance that is to be queried, and then an object representing the SQL Server is saved to a variable (this demonstrates the advanced features mentioned earlier where objects can be saved to variables). The properties of that variable can then be accessed as follows:
PS>Set-Location SQLSERVER:\SQL\<servername>\<instance_name>PS>$sql_server=get-item .PS>$sql_server.Information.VersionString