Data Backup and Recovery

SnapCenter Data Export

TMADOCTHOMAS
4,354 Views

I need to export the SnapCenter Resources SQL Server Database view. I don't see anything in the GUI. I've been experimenting with some PowerShell commands but nothing yet. It should basically return three of the same fields as is seen in the GUI, in a columnar format that can be imported into Excel - specifically database name, instance, host. I've mainly been working with Get-SmResources but from what I can tell you have to enter a specific host you want data for. Does anyone know if what I'm looking for is possible/doable?

1 ACCEPTED SOLUTION

matte
4,121 Views

try out this one

 

Foreach ($hostname in ((Get-SmHost).Hostname)) { (get-smresources -HostName $hostname -PluginCode SCSQL) | Select-Object -Property dbname,dbversion}

 

then you can redirect the out in a .csv file..

hope that helps in getting what you need 🙂

View solution in original post

10 REPLIES 10

matte
4,132 Views

Hello

with get-smresources you have to specify the host name, yes!

so you can get the SQL resources for all the hosts you have

one example you can start with is

 

Foreach ($hostname in ((Get-SmHost).Hostname)) { get-smresources -HostName $hostname -PluginCode SCSQL }

 

then you can modify/improve the script as you like

TMADOCTHOMAS
4,122 Views

Thank you @matte ! I will try that (hopefully later today) and will see if that works.

matte
4,122 Views

try out this one

 

Foreach ($hostname in ((Get-SmHost).Hostname)) { (get-smresources -HostName $hostname -PluginCode SCSQL) | Select-Object -Property dbname,dbversion}

 

then you can redirect the out in a .csv file..

hope that helps in getting what you need 🙂

TMADOCTHOMAS
4,111 Views

Thank you @matte ! I am not a mysql expert by any means. Any idea what I'm missing here? It's just giving me a prompt in return as seen below. I tried removing the redirect to a file at the end and I got the same thing. I then tried use nsm; and then ran it and still got the same result.

 

TMADOCTHOMAS_0-1686237769127.png

 

matte
4,105 Views

oh .. what i shared is to run in Powershell

if you want to query nsm let me know what you want to get exaclty.

but with PS i think it is much easier

TMADOCTHOMAS
4,098 Views

Ah, for some reason @matte I thought your code was mySQL. Okay I just tried it in PowerShell, but it is trying to connect directly to each host rather than just pulling the data from the SnapCenter server itself for some reason. I'm thinking there's likely a way to tell it to gather all it's information from the database. I'll research a little myself but would love to hear any suggestions!

 

get-smresources : Unable to connect to the remote server : <server_name>

TMADOCTHOMAS
4,098 Views

Weirdly, the individual components of your command are working perfectly. For some reason when I put them together it tries to connect to each host.  For example, I can run the two lines below without a problem. I only have about 50 servers so at the very least I could run the bottom command once per host. I just need to verify fieldnames for the ones I need. Still experimenting...

 

(Get-SmHost).Hostname

get-smresources -HostName $hostname -PluginCode SCSQL | Select-Object -Property dbname,dbversion

matte
4,080 Views

there is this parameter in get-smresoruces.. maybe is the one for you

-UseKnownResources [<SwitchParameter>]
Indicates that you want to return the cached resources. You can use this parameter when you have already queried resources from the SnapCenter GUI. In this case, you receive information only about the already discovered resources.

TMADOCTHOMAS
4,071 Views

Good to know @matte ! I will try that out. Thanks!

TMADOCTHOMAS
4,064 Views

@matte ! You are ingenius :). The following version of the command works! Thank you very very much for the help! That gave me just what I needed.

 

Foreach ($hostname in ((Get-SmHost).Hostname)) { (get-smresources -HostName $hostname -PluginCode SCSQL -UseKnownResources) | Select-Object -Property dbname,dbid >> databases.txt}

Public