![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)
2K+ Views
To check the PowerShell version installed in your system, you can use either $PSVersionTable or $host command.Check if $host command available in remote servers.Open the PowerShell console in the system and run the command $PSVersionTable.$PSVersionTableOutputPS C:\WINDOWS\system32> $PSVersionTable Name Value ---- ----- PSVersion 5.1.18362.628 PSEdition Desktop PSCompatibleVersions ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
6K+ Views
To edit the CSV file using PowerShell, you need to use the below commands.We already have the CSV file output.csv, we will import this file first.$csvfile = Import-csv C:\temp\Outfile.csvOutputBelow is the output of the CSV file.EMP_Name EMP_ID CITY -------- ------ ---- Charles 2000 New York James 2500 Scotland Charles 3000 PolandWe need to update the above file. We will change the CITY of the EMP_ID ‘3000’ to MUMBAI. If we update the CITY name by the EMP_Name, it ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
35K+ Views
To append the data into CSV file you need to use –Append parameter while exporting to the CSV file.In the below example, we have created a CSV fileExample$outfile = "C:\temp\Outfile.csv" $newcsv = {} | Select "EMP_Name", "EMP_ID", "CITY" | Export-Csv $outfile $csvfile = Import-Csv $outfile $csvfile.Emp_Name = "Charles" $csvfile.EMP_ID = "2000" $csvfile.CITY = "New York" $csvfile | Export-CSV $outfile Import-Csv $outfileNow we need to append the below data to the existing file. So first we will import the csv file into a variable called $csvfile$csvfile = Import-Csv $outfile $csvfile.Emp_Name = "James" $csvfile.EMP_ID = "2500" $csvfile.CITY = "Scotland"Once data is inserted into ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
4K+ Views
There are few methods to create a CSV file in the PowerShell, but we will use the best easy method to create it.First, to create a CSV file in PowerShell, we need to create headers for it. But before it, we need output file name along with its path.$outfile = "C:\temp\Outfile.csv"Here we have given output file name Outfile.csv in the path C:\temp.Now we will create headers, $newcsv = {} | Select "EMP_Name", "EMP_ID", "CITY" | Export-Csv $outfileHere, we have created a CSV file and exported a file to the newly created file.We will now import this file to check if ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
1K+ Views
When you run a command Export-Csv in PowerShell, it automatically creates a CSV file to the specific location.ExampleGet-Service | Select Name, Starttype, Status | Export-Csv C:\temp\services.csv -NoTypeInformationIn the above example, Services.csv file created in C:\Temp folders with the header Name, Starttype, and Status headers.Similarly, you can use the other commands to get the output into the CSV file format.If you want to check this file from the PowerShell console, you need to use Import-CSV command.Import-Csv C:\temp\Services.csv | ft -AutosizeOutputName StartType ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
5K+ Views
If you want the specific properties in PowerShell, you need to use the Select-Object (Alias − Select) as a pipeline.In the below example, we will retrieve the specific properties of the Spooler service.ExampleGet-Service Spooler | Select Name, DisplayName, Starttype, StatusOutputName DisplayName StartType Status ---- ----------- --------- ------ Spooler Print Spooler Automatic RunningNow we will customize the header by renaming the “Name” property to the “Alias Name” by the Name and the Expression syntax inside the Select-object.ExampleGet- Service Spooler | Select @{N='Alias Name';E={$_.Name}}, DisplayName, Starttype, StatusYou can also use ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
414 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)
2K+ 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