5 Replies Latest reply: Aug 1, 2013 12:29 PM by JGPSHNTAP RSS

Get list of Filers from DFM to run PS commands against

MARTINLEGGATT Sprinter
Currently Being Moderated

I'm trying to get a list of Filers from our DFM server (Oncommand Core 5.1) so that I can loop through them and then run powershell commands against them.

I want to do this so that I don't have to maintain a list of Filers in a text File and I know the list is up to date.

 

I found you can get a list of the Filers from report view as XML or CSV from DFM using the url:

 

https://{dfm-server}:8443/dfm/report/filers-ops?output-format=csv

 

I tried using Powershell:

System.Net.Webclient

and

Invoke-WebRequest

but the issue I have is it returns nothing as I'm not logged in.

 

Has anyone managed to get a list of Filers from DFM to run Powershell commands against?  The only other way I can think of is to run Powershell remotely on the DFM server with something like "dfm host list"

  • Re: Get list of Filers from DFM to run PS commands against
    JSHACHER11 Cyclist
    Currently Being Moderated

    'dfm host list' will give you a list that is unreadable by PS

     

    the closest you can get to that is:

     

    dfm report create -R controller -f name filers

    dfm report view filers >> c:\filers.txt

     

    PS > Get-Content -Path c:\filers.txt

     

    the only problem is the first 2 lines - the file will look like this:

     

    volume name

    ---------------------

    filer01

    filer02

    filer03

    • Re: Get list of Filers from DFM to run PS commands against
      JGPSHNTAP Kart Racer
      Currently Being Moderated

      In the coming days I will be releasing tons of my oncommand scripts.. I just haven't decided how to release them to the community.... But we do exactly this.. and we separate it based on group, so I can query via DFM

       

      Here's a script to do this, but I will repost to a blog shortly.

       

      <#
      .SYNOPSIS
        Queries all DFM controllers
      .DESCRIPTION
       
        .EXAMPLE
        .\dfm_controller_dump_wgroup.ps1
      .DATE
        4-15-2013
      .Version
           v1
      .Notes
        .Author
         Josh Goldfarb
      .Change Log
            v1.0 - Initial
        

       

      #>

       

      cls
      write-host "`t`t`t`t`tDFM Controller Dump is running.  Do not close window..........." -fore Red -background black
      $dfmcontrollers = dfm controller list

      $globalarray=@()
      $dfmcontrollers | % {
      if ($_ -like "*controller*" -and $_ -like "*filernodeb*") {

      $var = $_.trim()
      $array = $var -replace '\s+', " "
      $array = $array.split(" ")
      ## Build Array with Controllers
      $controller = $array[2]
      } elseif ($_ -like "*controller*") {
      $var = $_.trim()
      $array = $var -replace '\s+', " "
      $array = $array.split(" ")
      ## Build Array with Controllers
      $controller = $array[3]
      }

      $customobject = new-object psobject
      Add-Member -inputobject $customobject -membertype Noteproperty -name Filer -value $controller

      $globalarray += $customobject

       

      }
      ## Remove null variables

      $globalarray = $globalarray | ? {$_.filer -ne $null}
      ## Export Events
      #$globalarray | export-csv c:\temp\dfmfilers.csv -notypeinformation

      $dfmfilers = @()
      $globalarray | % {
      $filer = $_.filer

      ## Get group information for Filer
      $custom = new-object psobject
      Add-Member -inputobject $custom -membertype Noteproperty -name Filer -value $filer

      $group = dfm group list $filer
      $group[2] | % {
      $var = $_.trim()
      $var = $var -replace '\s+', " "
      $var = $var.split(" ")
      }

      if ($var.count -eq 3) {

      $groupname = $var[1] + " " + $var[2]

      } else {
      $groupname = $var[1]
      }


      Add-Member -inputobject $custom -membertype Noteproperty -name Purpose -value $groupname
      $dfmfilers += $custom
      }

      $dfmfilers = $dfmfilers | ? {$_.filer -ne $Null}
      ## Export filers
      $dfmfilers | Sort Purpose,Filer |  export-csv c:\temp\dfmfilers.csv -notypeinformation


      ## Copy file to httproot$ dump share for scripting
      Copy-item c:\temp\dfmfilers.csv "\\netappinfo\httproot$\dfmfilers.csv" -force


      cls
      write-host "`t`t`t`t`tDFM Controller dump complete.........." -fore Red -background black

       

      ####

       

      Then when I write script, I can do it off groups,

       

      for example.

       

      $host  = import-csv dfmfiler.csv | ? {$_.purpose -eq "vmware"}

       

      stuff like that..

More Like This

  • Retrieving data ...

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points