Found 989 Articles for Software & Coding

Difference between Multiprocessing and Multithreading

Kiran Kumar Panigrahi
Updated on 14-Dec-2022 18:08:37

8K+ Views

Both multiprocessing and multithreading are used in computer operating systems to increase its computing power. The fundamental difference between multiprocessing and multithreading is that multiprocessing makes the use of two or more CPUs to increase the computing power of the system, while multithreading creates multiple threads of a process to be executed in a parallel fashion to increase the throughput of the system. In this article, we will discuss all the important differences between multiprocessing and multithreading. Let's start with some basics of multiprocessing and multithreading so that it becomes easier to understand how they are different from each ... Read More

How to use Measure-Object in PowerShell?

Chirag Nagrekar
Updated on 07-Apr-2020 12:21:33

2K+ Views

Measure-Object in PowerShell is used to measure the property of the command. There are various measurement parameters are available. For example, Average, Count, sum, maximum, minimum and more.ExampleGet-Process | Measure-ObjectOutputPS C:\WINDOWS\system32> Get-Process | Measure-Object Count       : 278 Average     : Sum         : Maximum     : Minimum     : Property    :Here, in the above output, there are total 278 processes are running. If you want to check the maximum memory usage then you can use WorkingSet property with − Maximum Parameter.Get-Process | Measure-Object -Property WorkingSet -MaximumOutputPS C:\WINDOWS\system32> Get-Process | Measure-Object ... Read More

How to use Group-Object cmdlet in PowerShell?

Chirag Nagrekar
Updated on 07-Apr-2020 12:18:10

630 Views

As the name suggests, Group-Object is useful to group similar properties.ExampleGet-Service | Group-Object StatusOutputCount Name          Group ----- ----          ----- 160 Stopped         {AarSvc_8f3023, AdobeFlashPlayerUpdateSvc, AJR outer, ALG...} 130 Running         {AdobeARMservice, Appinfo, AudioEndpointBuilder, Audiosrv...}The above output is grouped with the Status (“Stopped” and “Running”). There is a total of 160 services are in Stopped status and 130 are in Running status.Similarly, you can filter the group with the starttype property.Get-Service | Group-Object StartTypeOutputPS C:\WINDOWS\system32> Get-Service | Group- Object StartType Count Name           ... Read More

How to sort the output in PowerShell?

Chirag Nagrekar
Updated on 07-Apr-2020 12:25:24

10K+ Views

To sort the output in the PowerShell you need to use Sort-Object Pipeline cmdlet. In the below example, we will retrieve the output from the Get-Process command and we will sort the, according to memory and CPU usage.ExampleGet-Process | Sort-Object WorkingSet | Select -First 10OutputHandles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName -------  ------    -----      -----     ------     --  -- -----------       0       0       60          8                 0 ... Read More

How to check the PowerShell version installed in local and remote systems?

Chirag Nagrekar
Updated on 07-Apr-2020 11:58:36

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

How to edit the CSV file using PowerShell?

Chirag Nagrekar
Updated on 26-Mar-2020 07:32:48

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

How to append data into a CSV file using PowerShell?

Chirag Nagrekar
Updated on 26-Mar-2020 07:28:05

36K+ 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

How to create a CSV file manually in PowerShell?

Chirag Nagrekar
Updated on 26-Mar-2020 07:23:52

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

How to Export and import CSV file manually in PowerShell?

Chirag Nagrekar
Updated on 26-Mar-2020 07:19:32

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

How to use custom headers in the PowerShell output table?

Chirag Nagrekar
Updated on 26-Mar-2020 07:07:34

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

Advertisements