This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Get-SwisData equivalent to Invoke-SQLCmd

I am trying to query the subnet and CIDR from the table based on a Location variable that I am providing.  Does anyone know the syntax to get this same query with the Get-SwisData command instead of the Invoke-Sqlcmd which requires the logged in user to have access to the database?

this is what currently works:

$SWIS = Connect-Swis -Credential $DomainCreds -Hostname FakeSWServer

$IPQuery = "SELECT TOP 100 * FROM [dbo].[IPAM_Group] WHERE Location = '$Site'"

$SubnetResult = Invoke-Sqlcmd -ServerInstance 'solarwinds\MSSQLSERVER,1433' -Query $IPQuery -Database 'SolarWindsOrion'

$SubnetResult = Get-SwisData -Query $IPQuery -SwisConnection $SWIS

Any help would be appreciated this is the only step in my overall script that requires the logged in context, and it would be great to eliminate that.

  • So I will guess that you probably did not install the SWQL Studio SDK yet did you?

    https://github.com/solarwinds/OrionSDK/releases

    Thats the easiest way to figure these kinds of things out for yourself.  

    You can also look up the schema here, but it's much easier to be able to work with the data live and interactively from your own system.

    SWQL does not support select *, you have to specify the column names you want to pull back, what you probably want is 

    select [all the columns you need for this]

    from ipam.groupnode

    but it might also be ipam.groupreport.  I don't have a copy installed right now to verify the contents of the actual DB table.

  • The Select * was the problem.  Thank you, it turned out to be the following to get this to work in case anyone else needs it:

    $IPQuery = "SELECT SubnetID, CIDR, FriendlyName, Location FROM IPAM.GROUPREPORT WHERE Location = '$Site'"

    $SubnetResult = Get-SwisData -Query $IPQuery -SwisConnection $SWIS