Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Copy Query As / Invoke-WebRequest (PowerShell 7+) #335

Open
kmsigma opened this issue Mar 29, 2023 · 0 comments
Open

Feature Request: Copy Query As / Invoke-WebRequest (PowerShell 7+) #335

kmsigma opened this issue Mar 29, 2023 · 0 comments

Comments

@kmsigma
Copy link
Contributor

kmsigma commented Mar 29, 2023

Although I almost always use the SwisPowerShell module, there's always a chance that I'll encounter a system where it cannot be installed. As a workaround, can we add an option to use the native Invoke-RestMethod PowerShell function as opposed to the Get-SwisData function from the SwisPowerShell module?

Syntax construction would be roughly like this:

$Uri =  'https://solarwinds.domain.local:17778//SolarWinds/InformationService/v3/Json/Query?query='
$Uri += [System.Web.HttpUtility]::UrlEncode($Query)
$Output = 'Invoke-RestMethod -Uri " + $Uri + '" -Authentication Basic -Method Get -SkipCertificateCheck -Credential ( New-Object System.Management.Automation.PSCredential -ArgumentList ( "' + $Username + '", ( "' + $Password + '" | ConvertTo-SecureString -AsPlainText ) ) )'
$Output | Set-Clipboard

What's copied to clipboard:
Invoke-RestMethod -Uri 'https://solarwinds.domain.local:17778/SolarWinds/InformationService/v3/Json/Query?query=SELECT+TOP+10+Caption+%2c+IP+%2c+CONCAT(Caption%2c%27%22%2f%22%27%2cIP)+AS+%5bComboName%5d+%2c+GETUTCDATE()+AS+%5bRightNow%5d+FROM+Orion.Nodes+WHERE+IP+LIKE+%27192.168.%25.%25%27' -Authentication Basic -Method Get -SkipCertificateCheck -Credential ( New-Object System.Management.Automation.PSCredential -ArgumentList ( "MyUsername", ( "MyC0mpl3xP@ssw0rd" | ConvertTo-SecureString -AsPlainText ) ) )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant