PowerShell – Looping

There may be a situation when you need to execute a block of law several number of times. In general, statements are executed succession ally The first statement in a function is executed first, followed by the alternate, and so on. Programming languages give colorful control structures that allow for more complicated prosecution paths. A circle statement allows us to execute a statement or group of statements multiple times and following is the general form of a circle statement in utmost of the programming languages −   For loop – Execute a sequence of statements multiple times and abbreviates the code that manages the loop variable. > $array = @(“item1”, “item2”, “item3”) > for($i = 0; $i -lt $array.length; $i++){ $array[$i] } item1 item2 item3 … Read more

Powershell – Copy File

Cmdlet Copy-Item cmdlet is used to copy a file by passing the path of the file to be copied and destination path where the file is to be copied. Example 1 In this example, we’ll copy a folder from D:\Temp\Test Folder\Test1.txt to D:\Temp\Test2 Type the following command in PowerShell ISE Console Copy-Item ‘D:\temp\Test Folder\Test File.txt’ ‘D:\temp\Test … Read more