Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mailbox VSS Writer health check #8

Open
notevenahint57 opened this issue Dec 5, 2014 · 1 comment
Open

Mailbox VSS Writer health check #8

notevenahint57 opened this issue Dec 5, 2014 · 1 comment

Comments

@notevenahint57
Copy link

There's a bug in this script where it tries to write to the $error variable. This is a reserved powershell variable, so it needs to be changed to something else.

So change this block:
if ( $writerName -like "Microsoft Exchange*" ) {
$state = $writers[ $lineNum + 3 ].trim()
$error = $writers[ $lineNum + 4 ].trim()
Add-Member -InputObject $px -MemberType NoteProperty -Name "State" -Value $state.substring( 7, $state.length-7 )
Add-Member -InputObject $px -MemberType NoteProperty -Name "Error" -Value $error.substring( 12, $error.length-12 )

                # add the resulting object to the array holding all the data
                $allVSSWritersList += $px

                # reset the results object for the next writer
                $px = NewVSSObject -Server $server

}

To this:
if ( $writerName -like "Microsoft Exchange*" ) {
$state = $writers[ $lineNum + 3 ].trim()
$vsserror = $writers[ $lineNum + 4 ].trim()
Add-Member -InputObject $px -MemberType NoteProperty -Name "State" -Value $state.substring( 7, $state.length-7 )
Add-Member -InputObject $px -MemberType NoteProperty -Name "Error" -Value $vsserror.substring( 12, $vsserror.length-12 )

                # add the resulting object to the array holding all the data
                $allVSSWritersList += $px

                # reset the results object for the next writer
                $px = NewVSSObject -Server $server
            }

Also, an alternative to the Invoke-Command call, you can use psexec, such as:
$writers = $( & $pathtoPSExec "$server" -accepteula -h vssadmin list writers) -split "nr"

@notevenahint57
Copy link
Author

Slight change to the line that pulls the writers if you want to use psexec. This stops output from running psexec to print to the console

$writers = $(cmd /c $pathtoPSExec "$server" -accepteula -h vssadmin list writers 2>&1) -split "nr"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant