WPF application and Powershell

Notice: Page may contain affiliate links for which we may earn a small commission through services like Amazon Affiliates or Skimlinks.
Jul 2, 2016
62
13
8
39
Iceland
Hey guys

I was wondering if anyone is doing any WPF application programming and gathering data with Powershell and store in a database ?

As a sysadmin i really like gathering information with powershell but would like to store the information in a database (SQL express).

Been thinking if anyone in here has any experience integrading Powershell scripts with your WPF applications using C# , entity framework,WPF and SQL database ? If yes would you recommend it ?

Cheers
-Hjalti-
 

Jon Massey

Active Member
Nov 11, 2015
339
82
28
37
Why WPF and PS? Really easy to write to SQL db via PS (Performing an INSERT from a PowerShell script - SQLServerCentral) using simple ADO.NET queries or using the excellent SQLPSX extensions (GitHub - MikeShepard/SQLPSX: SQL PowerShell Extensions). Adding EF to the mix just complicates matters.

WPF/C#/EF stack is pretty decent, although EF isn't the best choice for complicated data models and doesn't always produce the most elegant SQL for complex queries IMHO.

What are your actual requirements here?
 
  • Like
Reactions: Hjalti Atlason
Jul 2, 2016
62
13
8
39
Iceland
I´m thinking about gathering asset report to a database (using a similar script to This one with a couple of twists) and try to work with the data to identify Server trends (for example when and why disks are filling up etc...). Yeah i know Nagios or other monitoring tools can log this but not too handy when trying to work with the data.

Thanks for the tip, will look into this SQLPSX extensions.

WPF/C#/EF is what i know to be honest :)
 
Jul 2, 2016
62
13
8
39
Iceland
If i can gather the information needed from a powershell script and store the information in a database using this SQLPSX extension i could do some Data binding to output the information to a Window application (WPF) and use some C# Code to work with the information (and probably use Entity framework to make my life easier). But this will need some trial and error before i could use it in production on the domain/s i work in. BTW not a pro coder , just trying to make my life as a sysadmin easier since nobobdy else is doing it.
 

Jon Massey

Active Member
Nov 11, 2015
339
82
28
37
If you're concerned about databinding in your WPF frontend then one way you could do it is define your domain data model as POCOs, use EF code first to generate your database schema and then just use plain-ol SQL insert statements in your PS scripts to populate them.
 
  • Like
Reactions: Hjalti Atlason
Jul 2, 2016
62
13
8
39
Iceland
Ok nice,
this info will come in handy when i'll start coding , was reading alot of books on safaribooksonline.com before i asked in this Forum since no one around me has put any thought into this.

This is my pet project at the moment , hopefully i can come up with something cleaver to simplify certain tasks.
Worst case scenario , i´ll learn more about programming and find another project to work on.