- 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
Found 989 Articles for Software & Coding
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
417 Views
In PowerShell, the output is in the default table format. To format the output in the desired format, mainly below pipeline commands are used.Format-TableFormat-ListFormat-WideThere are also commands to format the output data but not used widely.Format-CustomFormat-HexIn the below example, we will get the service's details using Get-Service and format it using the different output cmdlets.Get-Service WinRM, SpoolerOutputStatus Name DisplayName ------ ---- ----------- Running Spooler Print Spooler Stopped WinRM Windows Remote Management (WS-Manag...As you can see Display Name for the WinRM service is not ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
2K+ Views
To add/remove date from the date string you need to use AddDay() method. For example,We need to add 6 days to the current date.(Get-Date).AddDays(6) 25 March 2020 22:40:36To go back to the specific number of days, the same AddDays() method will be used but the numbers are negative. For example,(Get-Date).AddDays(-6) 13 March 2020 22:45:34
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
3K+ Views
By default the when you run the (Get-Date) cmdlet, its output is in the below format.PS C:\WINDOWS\system32> Get-Date 18 March 2020 22:56:18You can format the above output in the various format supported by PowerShell.Examplesd – Short date pattern.PS C:\WINDOWS\system32> Get-Date -Format d 18-03-2020D – Long date patternPS C:\WINDOWS\system32> Get-Date -Format D 18 March 2020f – Full date pattern with a short time pattern.PS C:\WINDOWS\system32> Get-Date -Format f 18 March 2020 23:01F – Full date pattern with a long time pattern.PS C:\WINDOWS\system32> Get-Date -Format F 18 March 2020 23:02:22g – General date pattern with a short time pattern.PS C:\WINDOWS\system32> Get-Date -Format g 18-03-2020 ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
3K+ Views
To check if the date is adjusted by the daylight savings you need to use the function IsDayLightSavingTime() of the Get-Date cmdlet.PS C:\WINDOWS\system32> (Get-Date).IsDaylightSavingTime() FalseTo know more about DST, check the link below.http://www.webexhibits.org/daylightsaving/b.html
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
469 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)
29K+ 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)
67K+ 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