From the course: Complete Guide to PowerShell 7

Unlock this course with a free trial

Join today to access over 24,800 courses taught by industry experts.

Running scripts interactively

Running scripts interactively - PowerShell Tutorial

From the course: Complete Guide to PowerShell 7

Running scripts interactively

- [Instructor] Now for this example, I've brought back the PowerShell terminal on the right hand side, which is PowerShell 7.0, and I'm actually going to minimize this bottom section here. We don't need this one here. Let's go all the way back down. And what we're going to look at is interactively executing a PowerShell script. Before we do that though, we need to look at what the script actually does. So let me just slide this across here so we can see. Well, first off, what we're going to do here is we're going to define a log file path, which will be DiskSpaceLog.txt. Then we're going to go ahead and in that specific location, we're going to put that log file, so we're going to generate it. We are then going to generate this new function called log that would allow us to log entries directly into that too. The next thing we're going to do is go and check all of the disk space. We're going to use the Get-PSDrive with the specific file system provider, loop through each drive and do…

Contents