PS => CLR Examples

Started by stanl, January 30, 2024, 08:10:51 AM

Previous topic - Next topic

stanl

Didn't want to cloud up previous thread concerning PowerShellGet and installing modules in WB.  There is a little context: I was contacted by a user whom I had written database scripts years ago. They had a number of SQLite db's and tables they wanted to move in SQL Server Express 2019 64bit. Pure WB code for this seemed daunting even with Jim's extenders or Tony's improvements. However, was able to do this with 2-3 lines of PS code and further was able leverage the CLR and System.Management.Automation.PowerShell so that the process could be done in WB. Kinda felt PS modules could act as mini-extenders.  The 2 modules needed were SqlSever and PPSQLite.  After success for the user [I don't charge to learn something] I wanted to look at the larger picture of working with PS within WB.


Anyway, I have attached 3 scripts. If you have Win10 or even Win7 you should have the basics of Powershell installed which should include a version of PowerShellGet. Appreciate if anyone wants to take a few minutes to test.



       
  • CLR_PSAvailable - will search for modules/versions insalled on PC and output to Gridview
  • PS_Modules4Databse - searches for modules in Powershell Gallery related to 'database'
  • CLR_PSModulePath - outputs CurrentUser path to .txt file
keeps me busy: no time for anger/depression after being termed, and might help with the onslaught of Alzheimer's ;D

stanl

Even seeing there is no interest in the initial post on this thread, I have attached an additional script displaying a bit of the versatility of the PS Gridview to drill down to the syntax of a module command. This and previous scripts are simplistic but meant only to suggest a wider range.


Attached script will

       
  • display available modules but allow selecting one for further drill down [click the OK button]
  • If [OK] display any Commands associated with Module
  • Then if selected, drill down to syntax/parameters associated with command
Also included a snapshot of the WriteSqlTable command which indicates 3 ways to execute.

nrr

Tested and works as described although I'm not always sure what I'm looking at.  Let me know if there's something specific that you want tested.

spl

Quote from: nrr on February 08, 2024, 11:28:53 AM
Tested and works as described although I'm not always sure what I'm looking at.  Let me know if there's something specific that you want tested.

Thank you. Just wanted to know if cross-interface works at basic level.
Stan - formerly stanl [ex-Pundit]