
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Export and Import CSV File Manually in PowerShell
When you run a command Export-Csv in PowerShell, it automatically creates a CSV file to the specific location.
Example
Get-Service | Select Name, Starttype, Status | Export-Csv C:\temp\services.csv -NoTypeInformation
In 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 -Autosize
Output
Name StartType Status ---- --------- ------ AarSvc_7a82a Manual Stopped AdobeARMservice Automatic Running AdobeFlashPlayerUpdateSvc Manual Stopped AJRouter Manual Stopped ALG Manual Stopped AppIDSvc Manual Stopped Appinfo Manual Running AppMgmt Manual Stopped AppReadiness Manual Stopped AppVClient Disabled Stopped AppXSvc Manual Stopped AssignedAccessManagerSvc Manual Stopped AudioEndpointBuilder Automatic Running
If you need only Name and Status then you can use Select command after pipeline
Import-Csv C:\temp\Services.csv | Select Name,Status
Output
Name Status ---- ------ AarSvc_7a82a Stopped AdobeARMservice Running AdobeFlashPlayerUpdateSvc Stopped AJRouter Stopped ALG Stopped AppIDSvc Stopped Appinfo Running AppMgmt Stopped AppReadiness Stopped AppVClient Stopped AppXSvc Stopped
Advertisements