Powershell: sort by a column name that contains a space

By trial and error I found the answer is to just remove the space. For example to sort by the column “Recovery Model” …

import-module SQLPS; cls
$smoserver = new-object microsoft.sqlserver.management.smo.server
$smoserver.databases | sort-object RecoveryModel

Leave a comment