#14 PowerShell Learning: Conditional Logic in PowerShell
Like other programming languages, Windows PowerShell is a dynamic scripting language. Script code can be executed based on conditions that exist or occur.
24 articles
Like other programming languages, Windows PowerShell is a dynamic scripting language. Script code can be executed based on conditions that exist or occur.
Each programming language or scripting language has several different methods of applying the loop. Looping is a basic programming process that allows us to repeat a command and process large amounts of data. Without this ability, writing scripts would be tedious and almost impossible.
A hash table, also known as a dictionary or associative array, is a compact data structure that stores one or more key/value pairs. For example, a hash table can contain a series of Computer names and IP addresses where the Computer Names are the keys and the IP Addresses are the values, or vice versa.
An array is a data structure that is designed to store a collection of items. The items can be the same type or different types. Arrays allow the user to store information in an index.
Variable is a container (memory unit) which stores the value. You can store all types of values in Windows PowerShell variables. Variable is typically used to store the result of command and to store elements that are used in commands and expressions, such as names, paths, settings, and values.
You can use the Process cmdlets to manage local and remote processes with PowerShell. To find out all the PowerShell cmdlets that deal with Processes, use the following command.
As a Windows administrator, you might need to deal with Services on regular basis. You mainly need to list the services, to stop them, and sometimes need to change the Startup Mode. PowerShell offers you various cmdlets which can help you deal with Services. But before start managing the Services, you need to run the PowerShell console with administrator privileges since PowerShell does not violate the Windows security policies; it respects the security policies.
The Windows PowerShell Integrated Scripting Environment (ISE) is one of two hosts for the Windows PowerShell engine and language. In Windows PowerShell ISE, you can write, run, test, and debug the scripts in a single Windows-based graphic user interface with multiline editing, tab completion, syntax coloring, selective execution, IntelliSense and context-sensitive help. You can use menu items and keyboard shortcuts to perform many of the same tasks that you would perform in the Windows PowerShell console.
Windows PowerShell is designed especially for system administration. In this section we will discuss some important PowerShell commands every system administrator must know to make their life easier.
When you add aliases, functions, and variables, you are actually adding them only to the current Windows PowerShell session. If you exit the session or close Windows PowerShell, the changes are lost.