- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Chirag Nagrekar has Published 465 Articles
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
Chirag Nagrekar
1K+ Views
To retrieve the specific number of lines from the beginning or the end of the file, you first need to get the content of the file using Get-Content and then need to pipeline the -First for retrieving the number of files from the beginning and -Last to retrieve the number ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
Chirag Nagrekar
478 Views
To retrieve the content of the file in PowerShell, you need to use Get-Content cmdlet. For example, we are going to retrieve the content of the text file called Aliases.txt from a specific location.ExampleGet-Content D:\Temp\aliases.txtOutputPS C:\WINDOWS\system32> Get-Content D:\Temp\aliases.txt # Alias File # Exported by : admin # Date/Time : 26 January 2020 19:20:24 # Computer : DESKTOP-9435KM9 "foreach", "ForEach-Object", "", "ReadOnly, AllScope" "%", "ForEach-Object", "", "ReadOnly, AllScope" "where", "Where-Object", ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
Chirag Nagrekar
344 Views
Get-Content cmdlet in PowerShell is useful for retrieving the contents of the file or the function. This cmdlet is introduced in PowerShell 3.0. When a file is read by this cmdlet, it reads one line at a time and finally returns the whole content as a collection of objects.SyntaxGet-Content ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
Chirag Nagrekar
3K+ Views
Recycle bin in Windows operating system is to store the soft-deleted data. Soft deleted data means, data that is not deleted with (SHIFT + DEL) button but simply deleted with DEL button. Each local disk has its own configured recycle bin space.To delete the recycle bin data using GUI, you ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
Chirag Nagrekar
683 Views
When the break statement is mentioned with the Label, PowerShell exits to the label instead of exiting the current loop.Example$i = 1 while ($i -lt 10) { Write-Output "i = $i" if($i -eq 5){ Write-Output "Break statement executed" Break :mylable } $i++ ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
Chirag Nagrekar
345 Views
In Switch command, when the single value passed and if it matches the condition then the loop gets automatically exited but when there are multiple values passed and if the value matches the first condition and if you want to terminate the loop then you can use the Break statement. ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
Chirag Nagrekar
575 Views
You can use the PowerShell Break statement with the foreach loop as mentioned below.Exampleforeach($obj in (Get-ChildItem D:\Temp)){ Write-Output $obj if($obj.Name -eq "cars.xml"){Break} }OutputDirectory: D:\Temp Mode LastWriteTime Length Name ---- ------------- ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
Chirag Nagrekar
368 Views
To use the Break statement with the For loop, consider the below example.Examplefor($i=1; $i -le 10; $i++){ Write-Host "i = $i" if($i -eq 5){break} }Outputi = 1 i = 2 i = 3 i = 4 i = 5Here, when the value of $i reaches to 5, For loop gets terminated.To use the Break with the nested For loop.Inner For loop Break ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
Chirag Nagrekar
2K+ Views
You can use the break statement with both the While loop and the Do-While loop.To use the Break with a while loop, see the example below.Example$i = 1 While($i -ne 10){ Write-Output $i if($i -eq 5){break} $i++ }Output1 2 3 4 5In the above example, the loop terminates when the value ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
Chirag Nagrekar
143 Views
The break statement in PowerShell is useful for terminating the loop. When the break statement is executed inside the inner loop, it terminates that particular loop execution and when it is placed in the outer loop, it terminates the entire loop including child loop(s).Break statement is used with Foreach, For, ... Read More