Microsoft Virtualization Discussions
Microsoft Virtualization Discussions
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:
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"
Solved! See The Solution
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..
'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
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..
Hi,
Thanks for the PS code. I also noticed the thread you started which is along a very similar line of what I am trying to do:
https://communities.netapp.com/thread/20462
It would be good if Netapp created DFM cmdlets but this works which is great.
Thanks
Martin
I rely on "dfm report" over dfm host list, and the same applies for "dfm report view volumes" over "dfm volume list $controller" for this type of output.
"dfm report view controllers" will get a list of controllers, and if you group controllers(by region, type, etc) within DFM, then you can run the same report against that group, as well as run commands against the group(for rolling out an option change, for example). You can also make the output more manageable by making the output format in csv by typing something like:
dfm report view -F csv controller
Then each column will be delimited by a comma, so you can use the split function to filter the output by doing something like:
dfm report view -F csv controller | select-string fas6240 | %{$_.tostring().split(",")[3]}
That will show you the hostname of every fas6240 known to your DFM server and obviously you can get ONTAP ver, sysid, etc through other reports or canned reports.
ah, i didn't even think to do that.. nice.. I can switch my code to that and addd the group..