THWACK logo
THWACK
  • Sign In
  • Search
  • Community
    Community

    Find all you need to begin your THWACK journey, including documentation, missions, blogs, community groups, events, and media.

    Command Central
    • Getting Started
    MVP Program
    • MVP Program
    Monthly Mission
    • Network Uptime, Summer Downtime
    Blogs
    • Community Announcements
    • Product Blog
    Groups
    • DevOps Discourse
    • Data Driven
    • See All Groups
    Events
    • SolarWinds User Group
    • THWACKcamp
      • ↪ 2024: On Demand
    • Bracket Battle
    Media Vault
    • Movies & Mainframes
    • TechPod
    • THWACK Tech Tips
    • THWACK Livecast
    • SolarWinds Lab Archive
    • THWACKcamp Archive
    • See All Media
  • Products
    Products

    Find the best place to learn and ask questions about your SolarWinds products.

    Observability
    • Observability Solutions
    • SolarWinds Observability SaaS
    • SolarWinds Observability Self-Hosted
    • SolarWinds Platform
    Network Management
    • Network Performance Monitoring
    • NetFlow Traffic Analyzer
    • Network Configuration Manager
    • IP Address Manager
    • User Device Tracker
    • VoIP & Network Quality Manager
    • Log Analyzer
    • Engineer's Toolset
    • Network Topology Mapper
    • Kiwi CatTools
    • Kiwi Syslog Server
    • ipMonitor
    Application Management
    • AppOptics
    • Loggly
    • Papertrail
    • Pingdom
    • DevOps
    IT Security
    • Access Rights Manager
    • Identity Monitor
    • Security Event Manager
    • Patch Manager
    • Serv-U FTP & MFT
    IT Service Management
    • SolarWinds Service Desk
    • Web Help Desk
    • DameWare Remote Support
    • DameWare Remote Everywhere
    • DameWare Mini Remote Control
    System Management
    • Server & Application Monitor
    • Virtualization Manager
    • Storage Resource Monitor
    • Server Configuration Monitor
    • SolarWinds Backup
    • Web Performance Monitor
    Database Management
    • Database Performance Analyzer
    • SQL Sentry
    • Database Performance Monitor
    • Database Mapper
    • Task Factory
  • Content Exchange
    Content Exchange

    Find downloadable files and templates other users have built and found useful to share with others.

    SolarWinds Platform
    • Alerts
    • Custom HTML
    • Custom Queries
    • Modern Dashboards
    • Reports
    • Scripts
    Server & Application Monitor
    • API Pollers
    • Application Monitor Templates
    Database Performance Analyzer
    • Custom Alerts
    • Custom Metrics
    • Custom Queries
    Server Configuration Monitor
    • Policies
    • Profiles
    Network Performance Monitor
    • Device Pollers
    • Universal Device Pollers
    Network Configuration Manager
    • Config Change Scripts
    • Device Templates
    • Firmware Upgrade Templates
    • Policy Documents
    SQL Sentry
    • Advisory Conditions
    Web Help Desk
    • Style Sheets
  • Resources
    SolarWinds Customer Portal Customer Portal

    Create individual user accounts for your team, manage your licenses, download your SolarWinds software, create and track support tickets, and more.

    SolarWinds Academy Academy

    A one-stop-shop for world-class training for SolarWinds products through on-demand videos, and instructor-led classes. All SolarWinds Academy content is included with every software purchase.

    SolarWinds Customer Success Support

    Get help when you need it from a world-class support team, available to assist with technical product issues 24 hours a day, seven days a week, 365 days a year.

    SolarWinds Partner Portal Partner Portal

    Accelerate SolarWinds Partners’ ability to drive digital and IT transformation for customers with powerful tools, resources, and increased profit potential.

  • Free Tools & Trials
  • Store
The SolarWinds Platform
  • Products
The SolarWinds Platform
SolarWinds Platform API Initial Launch of Visual Studio Code
  • Newsroom
  • Forums
  • SolarWinds Platform API
  • Content Exchange
  • What We're Working On
  • Feature Requests
  • More
  • Cancel
  • New
  • -SolarWinds Platform API
    • About the SolarWinds Information Service (SWIS)
    • +Setting up a Python Development Environment
    • -Using PowerShell 7+ and Visual Studio Code
      • +Step-by-Step Installation Instructions [PowerShell 7+]
      • Initial Launch of Visual Studio Code
    • +SolarWinds Query Language (SWQL) Basics
    • +Data Presentation Examples
    • Additional Resources
    • Glossary

Initial Launch of Visual Studio Code

From this point forward the steps are identical regardless of your operating system.  Your operating system may ask for permissions and there will be some visual difference on fonts or path formatting (‘/’ vs. ‘\’), but for the most part the steps are the same.

Open VS Code and choose a theme.

At this point, you can continue to explore the interface, or click Mark Done.

Click Open Folder and create a new folder in your user profile called “Scripts.”  Select that new “Scripts” folder to open.

You’ll be prompted to trust the authors in the parent folder as well.  Since this is in your own user profile, you can select “Trust the authors.”

Creating a Test File

In the left-hand Explorer pane, click the new file icon to create a new file in this folder.

Name that file “Test.ps1” (notice that the icon changes to match the file type).

Since this is the first “PS1” file detected for this install, VS Code prompts if you’d like to install the recommended extensions.  You can either show the recommendations and install them as you wish or just take the defaults.  This autodetection of file extensions works for most common file types and VS Code will suggest the required extensions for execution.

The recommendation for handling PowerShell files is just a single extension and should be installed.

Additional Recommended Extensions

On the left-hand bar, click on the ‘blocks’ to access the extensions.  There are several that I like to use in addition to the required one for PowerShell, and you can either take the recommendations or leave them.

  • Indent-rainbow – colorizes your tabs, making it easier to visualize script levels
  • Prettier - Code formatter – formats your scripts the same way all the time

There are several thousand other extensions available.  They range from those required to compile/interpret code, those for working with repositories, and those which help with the code layout/formatting itself.  Choose those that work best for you and your coding style.

Installing the SolarWinds Orion PowerShell Module

In the lower half of the screen, click on the “Terminal” tab and enter Find-Module -Name SwisPowerShell and then hit Enter.

This is the module we’ll need to install.  Make sure it reports version 3.0.0 or later.

To install the module, in the same space, type Install-Module -Name SwisPowerShell followed by Enter.

You’ll be prompted to authorize the PSGallery as a trusted repository if you have not previously installed from it.  Type Y and hit Enter to confirm.

Lastly, we’ll need to confirm that the module’s functions are available, so type Get-Command -Name Connect-Swis and hit Enter.

If anything is returned (as above), then that command is available from the module which is listed under Source.

Validating Our Work

We’re good to write our Test.ps1 script.  Feel free to copy the below into your PS1 file or download the Test.ps1 from the GitHub repository. (link forthcoming).  After you have it in your editor, be sure to change the third line to use the IP or Name of your Orion Server.

# this is the name of your SolarWinds Orion server (or IP Address)
# replace with your own server name/IP
$SwisHost = "kmsorion01v.kmsigma.local" #<-- replace with your server's IP or DNS name

# Do we have a connection already to the SolarWinds Information Service?
# If not, prompt for credentials and build one
if ( -not $SwisConnection ) {
    $SwisCreds = Get-Credential -Message "Enter Orion credentials to connect to '$SwisHost'"
    $SwisConnection = Connect-Swis -Hostname $SwisHost -Credential $SwisCreds
}

# Simple SolarWinds Query Language (SWQL) Query
$SwqlQuery = "SELECT Caption, IPAddress FROM Orion.Nodes"

# Run the query against the SolarWinds Orion server
Get-SwisData -SwisConnection $SwisConnection -Query $SwqlQuery

From the Menu Bar, click Run / Start Debugging, press F5, or click the “play” button in the top-right to execute the script.

In the Terminal tab you’ll be prompted for your Orion username and password.

If you get no errors and the data is returned, then you have successfully completed all the steps and are ready to build your own scripts to interact with the SolarWinds Orion API via PowerShell.

  • SolarWinds Query Language (SWQL)
  • Visual Studio Code
  • SolarWinds Platform
  • PowerShell 7
  • Share
  • History
  • More
  • Cancel
Related
Recommended

SolarWinds solutions are rooted in our deep connection to our user base in the THWACK® online community. More than 200,000 members are here to solve problems, share technology and best practices, and directly contribute to our product development process.

SolarWinds Customer Success Center Certification SolarWinds Lab Link Customer Portal
About THWACK SolarWinds Blog Federal & Government Edit Settings Free Tools & Trials
Legal Documents Terms of Use Privacy California Privacy Rights Security Information
©2021 SolarWinds Worldwide, LLC. All Rights Reserved.