none
DFSR Reporting " not working correctly RRS feed

  • Question

  • I'm trying to get the following script to work, posted questions at the site but not sure if he is viewing the blog anymore.

    http://gallery.technet.microsoft.com/scriptcenter/10ca8b47-b0ec-4910-bdd7-52ce2d4bca41#conten

    Couple of things is not working with Powershell reporting of DFSR, (works in batch file)

    1) The DFSAdmin.exe reports "/Rgname:Domain is not a valid subobject" as I am trying to report on "Domain System Volume".   It doesn't like the " and doesn't like spaces!

    DfsrAdmin.exe Health New /RgName:`"Domain System Volume`" /RefMemName:$ReferralDC /RepName:$ReportFilePath /FsCount:true 

    Tried to use variable name instead but same result 

    $Rgname = "`"Domain System Volume`""

    DfsrAdmin.exe Health New /RgName:$Rgname /RefMemName:$ReferralDC /RepName:$ReportFilePath /FsCount:true 

    2) parsing of report file name doesn't work either, I get "Send-MailMessage : Thew device is not ready.

    If I do echo ($ReportFilePath+".html"), the result is correct as I replace the variable with result of the echo and it works!

    $ReportFilePath = "d:\Reporting\Reports\Health-report-"+(Get-Date -UFormat %Y-%m-%d) 

    Send-MailMessage -From $EmailFrom -To $EmailTo -SmtpServer $SmtpServer -Subject $EmailSub -Body "The DFS-R Health Report is attched to this e-mail" -Attachments ($ReportFilePath+".html")

    The is all on Windows 2008 R2

    Monday, August 18, 2014 4:49 PM

Answers

  • Trying too hard with quotes. This works as expected:


    PS C:\> $Rgname = "Domain System Volume"
    PS C:\> ShowArgs /RgName:$Rgname
    "/RgName:Domain System Volume"
    

    It isn't a problem that the /RgName parameter and its argument are quoted. PowerShell's parser inserts the quotes for you since the variable contains spaces.


    -- Bill Stewart [Bill_Stewart]

    Tuesday, August 19, 2014 4:34 PM
    Moderator

All replies

  • You don't need to embed the double-quotes in the $Rgname variable. This should work:


    $Rgname = "Domain System Volume"
    DfsrAdmin.exe Health New /RgName:$Rgname
    

    This article might clear up some confusion for you:

    Windows IT Pro: Running Executables in PowerShell


    -- Bill Stewart [Bill_Stewart]

    Monday, August 18, 2014 5:28 PM
    Moderator
  • Just using

    $Rgname = "Domain System Volume"

    doesn't work, I get

    Failed:

    The subobject "/RgName:Domain is not a valid subobject"

    Seems like it doesn't like the spaces either.


    • Edited by JT_CP Monday, August 18, 2014 5:35 PM
    Monday, August 18, 2014 5:34 PM
  • Replace DfsrAdmin.exe with ShowArgs.exe (from the article download) and take a look at its output.

    -- Bill Stewart [Bill_Stewart]

    Monday, August 18, 2014 5:39 PM
    Moderator
  • Unfortunately, we can't download outside apps without going through hoops....
    Monday, August 18, 2014 5:48 PM
  • The ShowArgs.exe program is simple and its source code is included.

    All I can do is provide general guidance and principles (which the article lists).

    In general I would say that the PowerShell command-line parser is pretty smart so don't try too hard to insert quotes everywhere.


    -- Bill Stewart [Bill_Stewart]

    Monday, August 18, 2014 6:03 PM
    Moderator
  • $PSBoundArguments will dump all arguments passed by name.

    $args will dump all unbound arguments.


    ¯\_(ツ)_/¯

    Monday, August 18, 2014 6:19 PM
  • I've replaced dfsradmin.exe with showargs.exe in a home lab.....

    I get the following result, (missing first ")

    $Rgname = "Domain System Volume"

    /RgName:Domain System Volume"

    Changing the variable to following doesn't work either: (add a double quote)

    $Rgname = "`"Domain System Volume"

    Re-ran showargs.exe and display is correct but fails with dfsradmin.exe

    Showargs.exe shows:     "/RgName:"Domain System Volume"

    DFSRadmin.exe still error out:   The subobject "/RgName:"Domain is not a valid subobject.

    Tuesday, August 19, 2014 4:13 PM
  • Do it correctly and it might work.

    $Rgname = '"Domain System Volume"'

    Single quotes on outside will prevent PowerShell from hanging it.


    ¯\_(ツ)_/¯

    Tuesday, August 19, 2014 4:18 PM
  • Trying too hard with quotes. This works as expected:


    PS C:\> $Rgname = "Domain System Volume"
    PS C:\> ShowArgs /RgName:$Rgname
    "/RgName:Domain System Volume"
    

    It isn't a problem that the /RgName parameter and its argument are quoted. PowerShell's parser inserts the quotes for you since the variable contains spaces.


    -- Bill Stewart [Bill_Stewart]

    Tuesday, August 19, 2014 4:34 PM
    Moderator
  • Hi guys, this is an old post but it's probably the closest to solving my issue which it's pretty much the same as the JT_CP's.

    I'm trying what's been suggested but I'm getting nowhere.

    PS C:\> $RGName = "Replication Name"
    PS C:\> ./ShowArgs /RgName:$Rgname
    "/RgName:Replication Name"
    PS C:\> dfsradmin membership list /RgName:$RGName /Attr:MemName,RfName,IsPrimary

    Failed:
    The subobject "/RgName:Replication is not a valid subobject.

    Any suggestions please?

    Thank you,

    Filipe

    Sunday, April 22, 2018 3:39 AM
  • It may be that that command-line utility (dfsradmin.exe) parses its command-line in a non-standard way.

    Experiment with showargs.exe until you get a combination that works.


    -- Bill Stewart [Bill_Stewart]

    Monday, April 23, 2018 2:23 AM
    Moderator