Get-DbaPowerShell

  • Comments posted to this topic are about the item Get-DbaPowerShell

  • Thanks for the write-up Steve, I’m kind of in the same boat...but I think for me it’s more tnullhat I feel intimidated by that language than anything else!

    ______________________________________________________________________________Never argue with an idiot; Theyll drag you down to their level and beat you with experience

  • We are being forced to add PoSh to the daily toolkit by some smarter folks here. I really don't care for the syntax, looks like Perl, DCL and AppleScript had a mutant love child. But since it hooks into SQL Server, it's what we have.

  • Most of PowerShell is just wrappers around .NET, so why not just use .NET in the first place.  Download VS Code, learn some of the .NET API, and become familiar with the documentation.  You'll get a much better IDE environment, namely Intellisense, many more code examples, and integrated source control, to name a few.

    I despise PowerShell.  I wish Microsoft would have never released it.  (Having to deal with the multiple versions of PowerShell was horrible.)  It's great to have options and I believe you should use the right tool for the job, but it also causes problems by having too many options and a disparate set of tools.

  • kevin77 - Monday, October 2, 2017 9:59 AM

    Most of PowerShell is just wrappers around .NET, so why not just use .NET in the first place.  Download VS Code, learn some of the .NET API, and become familiar with the documentation.  You'll get a much better IDE environment, namely Intellisense, many more code examples, and integrated source control, to name a few.

    I despise PowerShell.  I wish Microsoft would have never released it.  (Having to deal with the multiple versions of PowerShell was horrible.)  It's great to have options and I believe you should use the right tool for the job, but it also causes problems by having too many options and a disparate set of tools.

    I'm not sure I think a .NET program by most people will be better written than the PoSh wrappers. I think that's asking for more bugs and trouble, not to mention a much more difficult deployment process than using PoSh.

  • chrisn-585491 - Monday, October 2, 2017 7:31 AM

    We are being forced to add PoSh to the daily toolkit by some smarter folks here. I really don't care for the syntax, looks like Perl, DCL and AppleScript had a mutant love child. But since it hooks into SQL Server, it's what we have.

    Hmm... I'm actually loving powershell, so far I haven't had to actually hook it into SQL Server but from a general batch scripting perspective it's awesome.  It has far more power than dos batch commands and isn't limited by being a compiled program.

  • ...and isn't limited by being a compiled program.

    A PowerShell script has many of the same limitations as a compiled program, namely, it requires a specific framework in order to run and run correctly.  That is no different than any compiled program.

  • kevin77 - Monday, October 2, 2017 11:12 AM

    ...and isn't limited by being a compiled program.

    A PowerShell script has many of the same limitations as a compiled program, namely, it requires a specific framework in order to run and run correctly.  That is no different than any compiled program.

    Requiring a dedicated tool to even see the code, Visual Studio for example, is very limiting.  Not to mention that unless you can read binary you have no idea if the source code you're looking at is actually what is running.  

    That's not to say huge applications should be built in powershell but for basic scripting tasks like file maintenance or simple web service calls it's a very powerful tool that trying to do in C# would be more trouble and ad no benefit.

  • ZZartin - Monday, October 2, 2017 11:22 AM

    kevin77 - Monday, October 2, 2017 11:12 AM

    ...and isn't limited by being a compiled program.

    A PowerShell script has many of the same limitations as a compiled program, namely, it requires a specific framework in order to run and run correctly.  That is no different than any compiled program.

    Requiring a dedicated tool to even see the code, Visual Studio for example, is very limiting.  Not to mention that unless you can read binary you have no idea if the source code you're looking at is actually what is running.  

    That's not to say huge applications should be built in powershell but for basic scripting tasks like file maintenance or simple web service calls it's a very powerful tool that trying to do in C# would be more trouble and ad no benefit.

    A .cs file can be opened in Notepad and compiled on the command line, which equates to about the same experience you get with PowerShell.
    How is executing a binary that you wrote in the past and placed on a server any different than executing a PowerShell script that you wrote and placed on a server?  Are you saying that you always review every line of code of a PowerShell file, and understand it, before executing it?

    As I said, I do believe in using the right tool for the job.  However, if Microsoft would have made PowerShell a "scriptable .NET", the world would have been a much better place.

  • kevin77 - Monday, October 2, 2017 9:59 AM

    Most of PowerShell is just wrappers around .NET, so why not just use .NET in the first place.  Download VS Code, learn some of the .NET API, and become familiar with the documentation.  You'll get a much better IDE environment, namely Intellisense, many more code examples, and integrated source control, to name a few.

    I despise PowerShell.  I wish Microsoft would have never released it.  (Having to deal with the multiple versions of PowerShell was horrible.)  It's great to have options and I believe you should use the right tool for the job, but it also causes problems by having too many options and a disparate set of tools.

    Visual Studio Code, the lightweight cross-platform (win/mac/linux) version of Visual Studio, now has an extension to support PowerShell editing.

    https://trevorsullivan.net/2017/02/24/use-visual-studio-code-write-powershell/
    https://code.visualstudio.com/docs/editor/whyvscode

    "Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho

  • Steve Jones - SSC Editor - Monday, October 2, 2017 10:49 AM

    kevin77 - Monday, October 2, 2017 9:59 AM

    Most of PowerShell is just wrappers around .NET, so why not just use .NET in the first place.  Download VS Code, learn some of the .NET API, and become familiar with the documentation.  You'll get a much better IDE environment, namely Intellisense, many more code examples, and integrated source control, to name a few.

    I despise PowerShell.  I wish Microsoft would have never released it.  (Having to deal with the multiple versions of PowerShell was horrible.)  It's great to have options and I believe you should use the right tool for the job, but it also causes problems by having too many options and a disparate set of tools.

    I'm not sure I think a .NET program by most people will be better written than the PoSh wrappers. I think that's asking for more bugs and trouble, not to mention a much more difficult deployment process than using PoSh.

    You've just described some of the misgivings that I have for PoSH. πŸ˜‰

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff Moden - Monday, October 2, 2017 8:03 PM

    Steve Jones - SSC Editor - Monday, October 2, 2017 10:49 AM

    kevin77 - Monday, October 2, 2017 9:59 AM

    Most of PowerShell is just wrappers around .NET, so why not just use .NET in the first place.  Download VS Code, learn some of the .NET API, and become familiar with the documentation.  You'll get a much better IDE environment, namely Intellisense, many more code examples, and integrated source control, to name a few.

    I despise PowerShell.  I wish Microsoft would have never released it.  (Having to deal with the multiple versions of PowerShell was horrible.)  It's great to have options and I believe you should use the right tool for the job, but it also causes problems by having too many options and a disparate set of tools.

    I'm not sure I think a .NET program by most people will be better written than the PoSh wrappers. I think that's asking for more bugs and trouble, not to mention a much more difficult deployment process than using PoSh.

    You've just described some of the misgivings that I have for PoSH. πŸ˜‰

    I don't use PoSH much.
    I have one SQL job that uses it.
    Recently decided to use it in a .NET library to do data transformation of different formatted flat files into a common format. This enabled me to create new transformations using one script and one row in a database table.

    Far away is close at hand in the images of elsewhere.
    Anon.

  • Here is where I've found PowerShell particularly useful:
    - Iterating across multiple servers. In my case that's hundreds of servers.
    - Integration with Windows, things like gathering disk space and other system information.
    - Automated installation scripts.
    - File and operating system processing, as a replacement for MS-DOS batch files.

    "Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho

  • Eric M Russell - Tuesday, October 3, 2017 6:58 AM

    Here is where I've found PowerShell particularly useful:
    - Iterating across multiple servers. In my case that's hundreds of servers.
    - Integration with Windows, things like gathering disk space and other system information.
    - Automated installation scripts.
    - File and operating system processing, as a replacement for MS-DOS batch files.

    That's mostly where I see it being used well.

  • Sadly my most recent foray into powershell was to do a rename of a tree in the file system. The shell was very very slow.

    This has been a multiyear project, but I'm hopeful that I'll find a place for it yet. I went to SQL Saturday last Saturday and Allen White (https://twitter.com/SQLRunr) did a great job of showing how to do collect a baseline with Powershell. ( http://www.sqlsaturday.com/636/Sessions/Details.aspx?sid=67890 )

    412-977-3526 call/text

Viewing 15 posts - 1 through 15 (of 15 total)

You must be logged in to reply to this topic. Login to reply