You don't need the overhead of creating custom object if you just want a list of single values. Simply matching lines with the string "Writer Id:" should give you just the lines with the IDs:
& vssadmin list writers | Select-String -Pattern 'Writer Id:'
By using a positive lookbehind assertion (?<=...)
in the pattern you could even extract just the ID from the matching lines:
& vssadmin list writers |
Select-String -Pattern '(?<=Writer Id: ).*' |
Select-Object -Expand Matches |
Select-Object -Expand Value
Alternatively you could use a combination of the -match
and -replace
operators to the same end:
(& vssadmin list writers) -match 'Writer Id:' -replace '^.*: '
The above matches lines containing the string "Writer Id:" and then removes everything from the beginning of the line (^
) up to and including the colon and space, leaving just the ID.