SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Capture Linux Drive Space data with Powershell

By Michael D'Spain ,

I work in an environment that is half SQL Server and half Postgres, around 1400 servers total.  I wanted to find a way to capture drive space info on my Postgres database servers.   I am connecting to the Linux servers via POSH-SSH module.  Info regarding this module can be found at http://www.powershellmagazine.com/2014/07/03/posh-ssh-open-source-ssh-powershell-module/ .  This script is scheduled to run from the SQL Agent using a Proxy Account with my credentials so it can use the POSH-SSH module.    
This process captures drive space info.  The data comes in as an array.  I then break up the array with the split function and insert each element into a table in my Repository server.  From there you can do whatever you want with the data.  Also included is error handling that logs any errors that might occur during the process.  
All the best,
Michael D'Spain

Total article views: 205 | Views in the last 30 days: 1
Related Articles

New Perl Module for SQL Server released

For those who use Perl and access SQL Server, MVP Erland Sommarskog has announced a new module whic...



sys.dm_os_loaded_modules  is a SQL Server OS Dynamic Management View (DMV). When executing the t-sq...


PowerShell: Extending Modules – System Parameter measurement

The Microsoft Technet Guru Award  (August 2016) winning article  – Silver PowerShell: Extending Mod...


AzureRM Module Version

When working with the AzureRM PowerShell module, remember the module is constantly being updated to ...


Stairway to SQL PowerShell Level 6: PowerShell Modules

In this level, we will walk through creating and using modules for PowerShell. Modules are simply a ...