This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
2
PowerShell wrapper for 'vssadmin list writers'
Post Body
Hi,
this probably has been done before, but here is my take. Make sure to run this as admin. Since the output of vssadmin depends on the OS's language, you have to make sure that the wrapper matches on the right string. You can change it with the -Match
parameter.
Let me know what you think:
PARAM (
[Parameter(Mandatory=$false)]
[string]$Match='Writer name:'
)
foreach ($item in vssadmin list writers | Select-String -Context 0,4 "^$Match") {
$VSSWriter = $item.context.Postcontext.split(':')
[PsCustomObject] @{
'WriterName' = $item.line.Split(':')[1].TrimStart(' ',"'",'"').TrimEnd("'",'"')
'WriterId' = [Guid]$VSSWriter[1].TrimStart(' ','{').TrimEnd(' ','}')
'WriterInstanceId' = [Guid]$VSSWriter[3].TrimStart(' ','{').TrimEnd(' ','}')
'StateId' = $VSSWriter[5].TrimStart(' ').TrimEnd(' ').Split(' ')[0].TrimStart('[').TrimEnd(']')
'State' = $VSSWriter[5].TrimStart(' ').TrimEnd(' ').Split(' ')[1]
'LastError' = $VSSWriter[7].TrimStart(' ').TrimEnd(' ')
}
}
Example:
.\Get-VssWriterStatus.ps1 | Where {$_.StateId -ne '1'}
WriterName : Microsoft Hyper-V VSS Writer
WriterId : 66841cd4-6ded-4f4b-8f17-fd23f8ddc3de
WriterInstanceId : f84fa5fc-16f2-4797-b5ad-7cd6a4e48725
StateId : 8
State : Failed
LastError : Retryable error
Author
Account Strength
90%
Account Age
15 years
Verified Email
Yes
Verified Flair
No
Total Karma
4,540
Link Karma
3,347
Comment Karma
1,193
Profile updated: 4 days ago
Posts updated: 6 months ago
Subreddit
Post Details
We try to extract some basic information from the post title. This is not
always successful or accurate, please use your best judgement and compare
these values to the post title and body for confirmation.
- Posted
- 7 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/PowerShell/...