PowerShell ISE


This entry is part 3 of 9 in the series PowerShell

Windows PowerShell Integrated Scripting Environment (ISE)

This offers a point-and-click graphical interface that takes a lot of the guesswork out of typing cmdlets. The Windows PowerShell ISE is tailor-made for creating Windows PowerShell scripts and its Commands add-on serves as a useful training tool. Just type ise at the PowerShell window. The window in the screenshot is dragged in much smaller than you would normally have it set at to just to make it more easily fit on the screen. Another IDE option is Visual Studio Code.

You may get an error similar to the following screenshot of an error message when you try to run a command from a script.

Ed Bott’s free eBook discusses other topics as well, such as Hyper-V, the File Explorer, Registry Editor, Event Viewer, Task Manager, Disk Management, Sysinternals, DaRT and Azure.

Sysinternals Suite can be downloaded here. It’s 21MB. There are many parts to it. It is probably easiest to just download the whole suite. Many of these programs have been replaced by native Windows programs. There are still many useful utilities in this however.

You have two choices for running the examples provided in this book. The first is to use the PowerShell console. This provides a command-line interface. It’s the tool of choice for interactive work. The second choice is the PowerShell Integrated Scripting Environment (ISE). The ISE supplies 1an editing pane plus a combined output and interactive pane. The ISE is the tool of choice when developing scripts, functions, and other advanced functionality.

WMI

You can get part of a WMI instance with the following code running in Windows Powershell. This code is at the MSDN website of Microsoft. The data is simply returned to the next line in Powershell. DeviceID is not the only thing in this class. You can try FreeSpace instead of DeviceID.

(Get-WmiObject -class Win32_logicalDisk).DeviceID

In Windows, at a DOS prompt (command line – Search, cmd , vol, ) if you type vol to get the volume information you get the drive letter (probably C and under that you get the serial number). You can do this in the C# language also. Below is the code for that.

using System.Management;
...
ManagementObject myDisk = new ManagementObject("Win32_LogicalDisk.DeviceID='C:'");
string myProperty = myDisk.GetPropertyValue("VolumeSerialNumber").ToString();
Console.WriteLine(myProperty);
Series Navigation<< PowerShell Hello WorldPowerShell Variables >>