Check the status of VSS Writer on multiple servers
To check the status of VSS writer on multiple server first load the following script. This script converts the output of the non-powershell command to something powershell can use in, for example, out-gridview.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
function Get-VssWriters { <# .Synopsis Function to get information about VSS Writers on one or more computers .Description Function will parse information from VSSAdmin tool and return object containing WriterName, StateID, StateDesc, and LastError Function will display a progress bar while it retrives information from different computers. .Parameter ComputerName This is the name (not IP address) of the computer. If absent, localhost is assumed. .Example Get-VssWriters This example will return a list of VSS Writers on localhost .Example # Get VSS Writers on localhost, sort list by WriterName $VssWriters = Get-VssWriters | Sort "WriterName" $VssWriters | FT -AutoSize # Displays it on screen $VssWriters | Out-GridView # Displays it in GridView $VssWriters | Export-CSV ".\myReport.csv" -NoTypeInformation # Exports it to CSV .Example # Get VSS Writers on the list of $Computers, sort list by ComputerName $Computers = "xHost11","notThere","xHost12" $VssWriters = Get-VssWriters -ComputerName $Computers -Verbose | Sort "ComputerName" $VssWriters | Out-GridView # Displays it in GridView $VssWriters | Export-CSV ".\myReport.csv" -NoTypeInformation # Exports it to CSV .Example # Reports any errors on VSS Writers on the computers listed in MyComputerList.txt, sorts list by ComputerName $Computers = Get-Content ".\MyComputerList.txt" $VssWriters = Get-VssWriters $Computers -Verbose | Where { $_.StateDesc -ne 'Stable' } | Sort "ComputerName" $VssWriters | Out-GridView # Displays it in GridView $VssWriters | Export-CSV ".\myReport.csv" -NoTypeInformation # Exports it to CSV .Example # Get VSS Writers on all computers in current AD domain, sort list by ComputerName $Computers = (Get-ADComputer -Filter *).Name $VssWriters = Get-VssWriters $Computers -Verbose | Sort "ComputerName" $VssWriters | Out-GridView # Displays it in GridView $VssWriters | Export-CSV ".\myReport.csv" -NoTypeInformation # Exports it to CSV .Example # Get VSS Writers on all Hyper-V hosts in current AD domain, sort list by ComputerName $FilteredComputerList = $null $Computers = (Get-ADComputer -Filter *).Name Foreach ($Computer in $Computers) { if (Get-WindowsFeature -ComputerName $Computer -ErrorAction SilentlyContinue | where { $_.Name -eq "Hyper-V" -and $_.InstallState -eq "Installed"}) { $FilteredComputerList += $Computer } } $VssWriters = Get-VssWriters $FilteredComputerList -Verbose | Sort "ComputerName" $VssWriters | Out-GridView # Displays it in GridView $VssWriters | Export-CSV ".\myReport.csv" -NoTypeInformation # Exports it to CSV .OUTPUT Scripts returns a PS Object with the following properties: ComputerName WriterName StateID StateDesc LastError .Link https://superwidgets.wordpress.com/category/powershell/ .Notes Function by Sam Boutros v1.0 - 09/17/2014 #> [CmdletBinding(SupportsShouldProcess=$true,ConfirmImpact='Low')] Param( [Parameter(Mandatory=$false, ValueFromPipeLine=$true, ValueFromPipeLineByPropertyName=$true, Position=0)] [ValidateNotNullorEmpty()] [String[]]$ComputerName = $env:COMPUTERNAME ) $Writers = @() $k = 0 foreach ($Computer in $ComputerName) { try { Write-Verbose "Getting VssWriter information from computer $Computer" $k++ $Progress = "{0:N0}" -f ($k*100/$ComputerName.count) Write-Progress -Activity "Processing computer $Computer ... $k out of $($ComputerName.count) computers" ` -PercentComplete $Progress -Status "Please wait" -CurrentOperation "$Progress% complete" $RawWriters = Invoke-Command -ComputerName $Computer -ErrorAction Stop -ScriptBlock { return (VssAdmin List Writers) } for ($i=0; $i -lt ($RawWriters.Count-3)/6; $i++) { $Writer = New-Object -TypeName psobject $Writer| Add-Member "ComputerName" $Computer $Writer| Add-Member "WriterName" $RawWriters[($i*6)+3].Split("'")[1] $Writer| Add-Member "StateID" $RawWriters[($i*6)+6].SubString(11,1) $Writer| Add-Member "StateDesc" $RawWriters[($i*6)+6].SubString(14,$RawWriters[($i*6)+6].Length - 14) $Writer| Add-Member "LastError" $RawWriters[($i*6)+7].SubString(15,$RawWriters[($i*6)+7].Length - 15) $Writers += $Writer } Write-Debug "Done" } catch { Write-Warning "Computer $Computer is offline, does not exist, or cannot be contacted" } } return $Writers } |
Next, run this function against multiple servers
1 |
Get-VssWriters server1,server2,server3 | Out-GridView |