Csv-Powershell

import-csv powershell powershell import-csv powershell export-csv powershell csv powershell read csv export-csv powershell powershell export-csv append powershell output csv

Scenario 1:
Read CSV file. Although below daigram is self exploratory.
Created a CSV file that uses column headings and then we used the Import-CSV cmdlet to read the CSV file and to create a custom object from that file.

using this information, we can define the statuses of any windows service and then we can turn on and off services as expected/desired results.
This can be performed on any all computers in network.
this will be very helpful for system admins.
We will see that example as well.
Now we have find the service in system services and then we can set or the expctected status for that service
this can be performed on N number of systems using single powershell script using Get-Service cmdlet. Finally set the status using service object method e.g. start(), stop(), pause(), waitforstatus and many more...

Example


        
    $ServicesFromFile = Import-csv C:\powershell-scripts\test.csv
    foreach($services in $ServicesFromFile)
    {
    #Write-host $services.ServiceName #given column header name
    #Write-host $services.Status #given column header name
    # now we have find the service in system services and then we can set or the expctected status for that service
    # this can be performed on N number of systems using single powershell script
    $MatchingService = get-service | where { $_.ServiceName -eq $services.ServiceName }
    Write-host "Found matching serice:---" $MatchingService.ToString()
    $MatchingService.Start()
    }


Copy and Try it