From the course: PowerShell for SQL Server Administration

Differences between the two modules - PowerShell Tutorial

From the course: PowerShell for SQL Server Administration

Start my 1-month free trial

Differences between the two modules

- [Instructor] There's two ways we can run PowerShell code. So let's go ahead and take a look at those two options. There's the PowerShell.exe which is a command line tool so you can use pretty much from anywhere and then there's the ISE which is our quote unquote GUI to run in PowerShell. So the PowerShell command line tool is a great way of scheduling tasks or just running code that you've downloaded. Because it doesn't have any sort of GUI, it's really light on the server. So if you downloaded scripts or you need to schedule scripts that need to run and you just want to run them and you don't have any interaction enough to view what's going on, the PowerShell Command Line tool is a great way to actually run that code. Now this has the exact same functionality and exact same output as the GUI. This is just the lighter version of running code so you don't have to worry about popping up a GUI and actually wasting all the CPU cycles. It's actually bringing gooey on the screen if you don't need to so if you're just going to scheduling things, this is going to be the way to do it. When it comes to the ISE, that's going to be your quote unquote GUI. So this is what ships with the Windows. There are other ways of editing PowerShell code that are not native to Windows so you can download some of the visuals to do a code, install them on box and use that to do your PowerShell editing but that's not going to be your native way of doing things so the native option is the PowerShell ISE and we'll look at it in just a second. So one of the really cool things about PowerShell ISE is it comes with IntelliSense for the cmdlets and the parameters. So you can see what you need to type before you actually have to type it out. You could also just tap through a lot of those options. So this can be used to help you see what the various parameters are going to be of cmdlets and get some general help about those cmdlets. Makes life much, much easier. So let's go ahead and take a peak at the ISE real fast. So your basic ISE window is here. So we've got a blank window so we can write code. Underneath that we've got a Windows so we can actually see the output of whatever we're writing. We could also type command list in there as well. Over on the right, we've got a list of all the commands that are available on the server. So we can see here what all our cmdlets are if we want to just sub things down like asking PowerShell what command lists are on the box so if we want to look at something, we're going to do a Get dash and then it's going to be this whole list of all the various commands that meet that requirement. So if we do Get AdlJob, we can pull that cmdlet out then we can just hit a hyphen and that should pop up a list of parameters that are available to us. Soon as you're here, Account, Jobid, et cetera, all the various parameters for that specific cmdlet. So if we fill all those out, we can then execute that script. The Execute is going to be this little play button up here and it's going to be F5 just like in visual studio or in SequeL server and if we just want to highlight something to run it, we can just highlight it and hit this Run Selection button or hit F8 and that'll just go ahead and run that code that we've highlighted on the screen.

Contents