Extracting specific entries from vssadmin output
powershell 2.0
looking extract exchanges-specific entries output of running "vssadmin list writers" command, gives results vss writers on system , doesn't let filter writer name. best way extract these specific lines output? want writer name, state, , last error. end goal compile these entries each mailbox server can check vss state in case of issues backups.
writer name: 'microsoft exchange writer'
writer id: {**guid**}
writer instance id: {**guid**}
state: [1] stable
last error: no error
writer name: 'microsoft exchange replica writer'
writer id: {**guid**}
writer instance id: {**guid**}
state: [1] stable
last error: no error
looking extract exchanges-specific entries output of running "vssadmin list writers" command, gives results vss writers on system , doesn't let filter writer name. best way extract these specific lines output? want writer name, state, , last error. end goal compile these entries each mailbox server can check vss state in case of issues backups.
writer name: 'microsoft exchange writer'
writer id: {**guid**}
writer instance id: {**guid**}
state: [1] stable
last error: no error
writer name: 'microsoft exchange replica writer'
writer id: {**guid**}
writer instance id: {**guid**}
state: [1] stable
last error: no error
(vssadmin list writers | {$_.trim()}) -split "`r`n" | foreach { if ($_.startswith("writer name")){ $ht=@{} } $key,$val=$_ -split ": " $ht.add($key,$val) if ($_.startswith("last error")){ new-object psobject -property $ht } } | select "writer name",state,"last error"
Windows Server > Windows PowerShell
Comments
Post a Comment