![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
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
Found 463 Articles for PowerShell
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
457 Views
Get-Date function in PowerShell is to get the current system date and time. For example, when you type simply Get-Date, the output will be, Get-DatePS C:\WINDOWS\system32> Get-Date 18 March 2020 19:17:03When you check the type of the (Get-Date) function, it is DateTime.(Get-Date).GetType() PS C:\WINDOWS\system32> (Get-Date).GetType() IsPublic IsSerial Name BaseType -------- -------- ---- -------- True True DateTime System.ValueTypeWhen you check all the properties of the (Get-Date).PS C:\WINDOWS\system32> Get-Date | fl * DisplayHint : DateTime DateTime : 18 March 2020 19:32:32 Date : 18-03-2020 ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
28K+ Views
To convert the integer variable to the string variable, you need to use the explicit conversion or the functional method. In the below example, we are assigning an integer value to the variable $X.$x = 120 $x.GetType().NameNow when you check the data type of that variable, it will be Int32.To convert it into the string variable, first, we will use the explicit method by using a square bracket and data type to convert inside the brackets.[string]$x = 130 $x.GetType().NameThe data type of $x is the String.In the second method, you can use the PowerShell functional method ToString() to convert. For ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
66K+ Views
There are different data types exist for the variable like Byte, Int32, Float, String, etc. To get the variable type, we need to use the GetType() method.Example$x = 10 $x.GetType()OutputIsPublic IsSerial Name BaseType -------- -------- ---- -------- True True Int32 System.ValueTypeTo get only the variable datatype use Name property.$x.GetType().NameInt32
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
3K+ Views
To convert the content of the file into the upper case, you need to use the method ToUpper() and to convert into lower case, you need to use ToLower() method.Upper case example(Get-Content D:\Temp\PowerShellaliases.txt).ToUpper()OutputPS C:\WINDOWS\system32> (Get-Content D:\Temp\PowerShellaliases.txt).ToUpper() COMMANDTYPE NAME VERSION SOURCE ----------- ---- ------- ------ ALIAS ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
12K+ Views
To search the content in the file in PowerShell, you need to first get the content from the file using Get-Content command and then you need to add Select-String pipeline command. In the below example, we need to search the lines which contain the Get word.PS C:\WINDOWS\system32> Get-Content D:\Temp\PowerShellaliases.txt | Select-String -Pattern Get Alias cat -> Get-Content Alias dir -> Get-ChildItem Alias gal -> Get-Alias Alias gbp -> Get-PSBreakpoint Alias gc -> Get-Content Alias ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
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 of lines from the bottom.Check the below example of retrieving the content of the first 10 lines.ExampleGet-Content D:\Temp\PowerShellaliases.txt -First 10OutputPS C:\WINDOWS\system32> Get-Content D:\Temp\PowerShellaliases.txt -First 10 CommandType Name Version ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
28K+ Views
To count the total number of lines in the file in PowerShell, you first need to retrieve the content of the item using Get-Content cmdlet and need to use method Length() to retrieve the total number of lines. An example is shown below.Example(Get-Content D:\Temp\PowerShellcommands.csv).LengthOutputPS C:\WINDOWS\system32> (Get-Content D:\Temp\PowerShellcommands.csv).Length 5727
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
467 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", "", "ReadOnly, AllScope" "?", "Where-Object", "", "ReadOnly, AllScope" "ac", "Add-Content", "", "ReadOnly, AllScope" "clc", "Clear-Content", "", "ReadOnly, AllScope" "cli", "Clear-Item", "", "ReadOnly, AllScope" "clp", "Clear-ItemProperty", "", "ReadOnly, AllScope" "clv", "Clear-Variable", "", "ReadOnly, AllScope" "compare", "Compare-Object", "", "ReadOnly, AllScope" "cpi", "Copy-Item", "", "ReadOnly, AllScope" "cpp", "Copy-ItemProperty", "", "ReadOnly, AllScope" "cvpa", "Convert-Path", ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
339 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 [-ReadCount ] [-TotalCount ] [-Tail ] [-Path] [-LiteralPath] [-Filter ] [-Include ] [-Exclude ] [-Force] [-Credential ] [-Delimiter ] [-Wait] [-Raw] [-Encoding ] [-AsByteStream] [-Stream ] []
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
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 can simply right click and delete the content.It is also possible to delete the recycle bin content with the PowerShell command with the Clear-Recyclebin cmdlet. This command is introduced in PowerShell 5 and available in newer versions as well.ExampleClear-RecycleBinOutputPS C:\WINDOWS\system32> Clear-RecycleBin Confirm Are you sure you want to perform this action? Performing the operation "Clear-RecycleBin" on target "All of the contents of the Recycle Bin". [Y] Yes [A] Yes to All ... Read More
To Continue Learning Please Login