Mindblown: a blog about philosophy.
-
Execution Policy Scope
The following are the valid values for the execution policy scope: MachinePolicy This scope sets by the group policy for all the computer users. UserPolicy This scope sets by the Group policy for the current user of a computer. Process This scope only affects the current session of PowerShell. CurrentUser In this scope, the execution…
-
PowerShell Execution Policy
An execution policy is the feature of PowerShell that specifies the conditions under which PowerShell loads the configuration files and run the scripts. On a Windows operating system, we can set the execution policy for the current user, local computer, or for a specific session. Execution policies for the Current user and the local computer…
-
Examples
Example1: The following example uses only one Catch block with the Try block: In this example, the command is correct in the Try block, so there is no error and displays the following output: Example2: The following example also uses only one Catch block with the Try block: In this example, the command is wrong in the Try block, so there exists an error in…
-
Catch {…..}
The Catch block is the part in the script which handles the errors generated by the Try block. We can define which type of error to be handled by the Catch block. A type of error is an exception of a Microsoft .NET framework. A Try block can have multiple catch blocks for different types of errors. Instead of the Catch block, you…
-
PowerShell Try Catch Finally
When you need to handle the terminating errors within the script blocks, use a Try, Catch, and finally blocks in a PowerShell. The terminating errors are those errors which stop the statement from running. When PowerShell does not handle the terminating errors in some way, then it also stops running a script or function using the current…
-
SubString()
The SubString is a method which accepts the two overload arguments and returns a part of the longer string. Both the arguments are numerical values and separated by the comma (,). The left value is that value where you had like to start the SubString. The right value represents the number of characters you had like to move…
-
Examples of Functions
Example1: The following example is a simple function which returns a current date Type the following command in the PowerShell console to get the output of above example: Output: Example2: The following example is a function which accepts one parameter and returns a value on that parameter. Type the following command to get the input…
-
Advanced function
Advanced functions are those functions which can perform operations that are similar to the operations performed with the cmdlets. These functions are used when a user wants to write a function without having to write a compiled cmdlet. The main difference between using a compiled cmdlet and an advanced function is that the compiled cmdlets are…
-
Simple function
The following block describes you how to create the simplest function in a PowerShell: To add the multiple statements to the function, we must use a semicolon to separate the statements or type each statement on a separate line. To use the function, type the name of the function as given in the following block:…
-
Scope of a function
Got any book recommendations?