0 Replies Latest reply on Nov 26, 2012 6:35 PM by mmedwid

    Exchange White Space Script Fails

    mmedwid

      I have good credentials to run the exchange white space script.  But it fails with the

      message "Testing on node ___: failed with 'Unknown' status.  Scripting error: Script

      does not contain the expected parameters or is improperly formatted. 

      'Statistic' missing."  I am running this against an Exchange 2007 mailbox

      server. 

       

      Template name is: Exchange 2007 - 2010 ESE Database Whitespace Monitor

       

      VB Script for the component:

       

      Dim objNamedArgs

      Set objNamedArgs = WScript.Arguments.Named

      If objNamedArgs.Exists("ServerName") Then

      Else

        WScript.Echo ("Message: Please set correct argument into counter's argument box: Name of target server in double quotes according to the output of command: Get-ExchangeServer. Example: /ServerName:""mailserver"" or /ServerName:""mailserver.test.com"".")

        exitCode = 1

        Wscript.Quit

      End If

      Set objFSO = CreateObject("Scripting.FileSystemObject")

      Set objTextFile = objFSO.OpenTextFile ("C:\Windows\Temp\Whitespace_database_ID.ps1", 2, True)

      objTextFile.WriteLine("add-pssnapin Microsoft.Exchange.Management.PowerShell.Admin;")

      objTextFile.WriteLine("add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010;")

      objTextFile.WriteLine("$Error.Clear();")

      objTextFile.Write("$target = """)

      objTextFile.Write(objNamedArgs("ServerName"))

      objTextFile.WriteLine(""";")

      objTextFile.WriteLine("$stat = (Get-MailboxDatabase -Status -identity ""database_ID"" | foreach {$_.AvailableNewMailboxSpace.ToMb()})")

      objTextFile.WriteLine("if ($Error.Count -eq 0) {")

      objTextFile.WriteLine(" Write-Host ""Message: Available Whitespace on database_ID database (MB): $stat"";")

      objTextFile.WriteLine(" Write-Host ""Statistic: $stat""; ")

      objTextFile.WriteLine(" Exit 0;")

      objTextFile.WriteLine(" }")

      objTextFile.WriteLine("Write-Host ""Message: $($Error[0])""; ")

      objTextFile.WriteLine("Exit 1; ")

      objTextFile.Close

      Set objShell = CreateObject("Wscript.Shell")

      strComputer = "."

      Set objWMIService = GetObject("winmgmts:" _

          & "{impersonationLevel=impersonate,authenticationLevel=Pkt}!\\" _

          & strComputer & "\root\cimv2")

      Set colSettings = objWMIService.ExecQuery _

          ("SELECT Architecture FROM Win32_Processor")

      For Each objProcessor In colSettings

          If objProcessor.Architecture = 9 Then

          powerpath = "%windir%\sysnative"

        Exit For

          ElseIf objProcessor.Architecture = 0 Then

          powerpath = "c:\windows\system32"

        Exit For

          End If

      Next

      Set vPSscrIpt = objShell.Exec( powerpath & "\windowspowershell\v1.0\powershell.exe C:\Windows\Temp\Whitespace_database_ID.ps1")

      vPSscrIpt.StdIn.Close()

      WScript.Echo(vPSscrIpt.StdOut.ReadAll)

      WScript.Quit vPSscrIpt.ExitCode