Get-Date
The "Get-Date" cmdlet retrieves a DateTime object that represents the current date and time. It allows us to format the date and time in various Windows and UNIX formats. Additionally, Get-Date can be utilized to generate a specific date or time.
PS C:\Users\HARI> Get-Date
08 June 2023 19:08:12
Below command gets a DateTime object, but it displays only date or only time or date and time. It uses the DisplayHint parameter to indicate that only date or only time or date and time to be displayed. 
PS C:\Users\HARI> Get-Date
15 June 2023 02:09:51
PS C:\Users\HARI> Get-Date -DisplayHint DateTime
15 June 2023 02:09:57
PS C:\Users\HARI> Get-Date -DisplayHint Date
15 June 2023
PS C:\Users\HARI> Get-Date -DisplayHint Time
02:10:09
Below command gets the current date and time and formats it in short-date and short-time format. It uses the .NET Framework g format specifier (General [short date and short time]) to specify the format. 
PS C:\Users\HARI> Get-Date -Format g
08-06-2023 19:16
PS C:\Users\HARI> Get-Date -Format "yyyy/MM/dd HH:mm:ss"
2023-06-15 01:27:58
PS C:\Users\HARI> Get-Date -Format "yyyy/MM/dd HH:mm:ss dddd"
2023-06-15 01:28:04 Thursday
Below command gets the current date and time and formats it as specified by the command (Unix format). In this case, the format includes the full year (%Y), the two-digit numeric month (%m), the date (%d), the full day of the week (%A), the hour, minutes, seconds.
PS C:\Users\HARI> Get-Date -UFormat "%Y-%m-%d %A %H:%M:%S"
2023-06-08 Thursday 19:20:47
PS C:\Users\HARI> Get-Date -UFormat "%Y-%m-%d %H:%M:%S %A"
2023-06-15 01:30:49 Thursday
 Set-Date
The Set-Date cmdlet changes the system date and time on the computer to a date and time that we specify. (We require to launch the PowerShell as Administrator to run the Set-Date command)
 Add 5 days to the system date: This command adds 5 days to the current system date.
PS C:\WINDOWS\system32> Set-Date -Date (Get-Date).AddDays(5)
20 June 2023 01:50:07
Sets current system date back by 5 days: This command adds -5 days to the current system date.
PS C:\WINDOWS\system32> Set-Date -Date (Get-Date).AddDays(-5)
15 June 2023 01:50:41
Name            MemberType 	Definition                           
—————           —————————— 	———————————                           
AddDays         Method     datetime AddDays(double value)       
AddMonths       Method     datetime AddMonths(int months)       
AddYears        Method     datetime AddYears(int value) 
AddHours        Method     datetime AddHours(double value)      
AddMinutes      Method     datetime AddMinutes(double value)    
AddSeconds      Method     datetime AddSeconds(double value)    
AddMilliseconds Method     datetime AddMilliseconds(double value)
We can also get the required date time values as bellow.
PS C:\Users\HARI> $c_date=Get-Date
PS C:\Users\HARI>
PS C:\Users\HARI> $c_date
15 June 2023 13:10:45
PS C:\Users\HARI> $c_date.AddDays(5)
20 June 2023 13:10:45
PS C:\Users\HARI> $c_date
15 June 2023 13:10:45
PS C:\Users\HARI> $c_date.AddMonths(1)
15 July 2023 13:10:45
PS C:\Users\HARI> $c_date.AddYears(1)
15 June 2024 13:10:45
PS C:\Users\HARI> $c_date.AddHours(1)
15 June 2023 14:10:45
PS C:\Users\HARI> $c_date.AddMinutes(30)
15 June 2023 13:40:45
PS C:\Users\HARI> $c_date=((Get-Date).AddDays(1)).addhours(-2)
PS C:\Users\HARI>
PS C:\Users\HARI> $c_date
16 June 2023 11:30:32
 Get-Process 
The "Get-Process" command retrieves information about running processes on a Windows system. It provides a list of currently running processes, including their names, process IDs (PIDs), memory usage, and other details. Refer the below sample data.
PS C:\Users\HARI> Get-Process
Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName
-------  ------    -----      -----     ------     --  -- -----------
    150       9     2668       3308              6020   0 AggregatorHost
    204      15    19136       6332       3.63  59324   1 ai
    421      25    16988      27228      14.80   2448   1 ApplicationFrameHost
    160       9     1864       1196       0.03  44156   1 AppVShNotify
    933      55    77672      18236   4,323.86  13756   1 atmgr
    204      13     3148       4964      24.67   7924   1 AutoModeDetect
    316      32    17684        868       0.13  57580   1 backgroundTaskHost
    239      14     4940       3484       0.05  62984   1 backgroundTaskHost
    300      18    29900      63160       0.38   7972   1 chrome
    543      21    68100     117204       3.97   8956   1 chrome
PS C:\Users\HARI> Get-Process -Name PowerShell
Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName
-------  ------    -----      -----     ------     --  -- -----------
    713      32    60608      73144       3.73  66280   1 powershell
PS C:\Users\HARI> Get-Process -Name WmiPrvSE
Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName
-------  ------    -----      -----     ------     --  -- -----------
    376      21    33172       7852              7212   0 WmiPrvSE
    174      11     2740      10128             49204   0 WmiPrvSE
    401      21    13956      24924             53360   0 WmiPrvSE
PS C:\Users\HARI> Get-Process -id 67548
Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName
-------  ------    -----      -----     ------     --  -- -----------
    932      44    71428      61056      21.33  67548   1 WindowsTerminal
PS C:\Users\HARI> Get-Process | Format-Table Name, Id, CPU
Name                    	Id 	CPU
----                    	-- 	---
AggregatorHost        		6020
ai                   		59324 	3.65625
ApplicationFrameHost  		2448 	14.796875
AppVShNotify         		44156 	0.03125
atmgr                		13756 	4325.46875
audiodg              		61232 	0.046875
AutoModeDetect        		7924 	24.6875
backgroundTaskHost   		57580 	0.125
PS C:\Users\HARI> Get-Process | Select-Object Name, ID, CPU
Name                    	Id 	CPU
----                    	-- 	---
AggregatorHost        		6020
ai                   		59324 	3.65625
ApplicationFrameHost  		2448 	14.796875
AppVShNotify         		44156 	0.03125
atmgr                		13756 	4325.984375
audiodg              		61232 	0.046875
AutoModeDetect        		7924 	24.703125
backgroundTaskHost   		57580 	0.125
PS C:\Users\HARI> Get-Process | Where-Object { $_.CPU -gt 50 }
Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName
-------  ------    -----      -----     ------     --  -- -----------
    933      55    77672      18448   4,326.33  13756   1 atmgr
    386      21    80916      99700      53.86   9052   1 chrome
    587      26   214032     204788     675.94  20200   1 chrome
   1595      83   719964     256016   9,943.72  28532   1 chrome
    382      19   137972     129948     196.19  30596   1 chrome
PS C:\Users\HARI> Get-Process | Group-Object ProcessName | Select-Object Name, Count
Name                                         Count
----                                         -----
AggregatorHost                                   1
ai                                               1
ApplicationFrameHost                             1
AppVShNotify                                     1
atmgr                                            1
AutoModeDetect                                   1
backgroundTaskHost                               2
chrome                                          29
conhost                                          5
 Stop-Process
The "Stop-Process" cmdlet in PowerShell is used to terminate one or more running processes on a Windows system. It allows you to stop processes based on their process ID (PID) or by specifying their names.
PS C:\Users\HARI> Stop-Process -Name chrome
PS C:\Users\HARI>
PS C:\Users\HARI> Stop-Process -Name chrome, msedge
PS C:\Users\HARI>
PS C:\Users\HARI> Stop-Process -Id 1234
PS C:\Users\HARI>
PS C:\Users\HARI> Stop-Process -Id 1234, 5678, 9012
PS C:\Users\HARI>
PS C:\Users\HARI> Stop-Process -Id <ProcessID> -Force
PS C:\Users\HARI>
PS C:\Users\HARI> Stop-Process -Id 1234 -Force
PS C:\Users\HARI>
PS C:\Users\HARI> Stop-Process -Name *notepad*
PS C:\Users\HARI>
 Start-Process
The "Start-Process" cmdlet in PowerShell is used to launch an executable or start a new process on a Windows system. It allows to open applications, run scripts, launch file or execute commands from within PowerShell.
PS C:\Users\HARI> Start-Process -FilePath <Path to Executable>
PS C:\Users\HARI>
PS C:\Users\HARI> Start-Process -FilePath "C:\Windows\System32\notepad.exe"
PS C:\Users\HARI>
PS C:\Users\HARI> Start-Process -FilePath "C:\Users\HARI\Desktop\table.html"
PS C:\Users\HARI>
 Get-Service
The "Get-Service" in PowerShell is used to retrieve information about services on a Windows system. It allows to view the status, startup type, and other details of installed services.
PS C:\Users\HARI> Get-Service
Status   Name               DisplayName
------   ----               -----------
Stopped  AJRouter           AllJoyn Router Service
Stopped  ALG                Application Layer Gateway Service
Stopped  AppIDSvc           Application Identity
Running  Appinfo            Application Information
Stopped  AppReadiness       App Readiness
PS C:\Users\HARI> Get-Service -Name <ServiceName>
PS C:\Users\HARI> 
PS C:\Users\HARI> Get-Service -Name Appinfo
Status   Name               DisplayName
------   ----               -----------
Running  Appinfo            Application Information
PS C:\Users\HARI> Get-Service -Name Spooler
Status   Name               DisplayName
------   ----               -----------
Running  Spooler            Print Spooler
PS C:\Users\HARI> Get-Service -Name "Print*"
Status   Name               DisplayName
------   ----               -----------
Stopped  PrintNotify        Printer Extensions and Notifications
Running  PrintWorkflowUs... PrintWorkflow_43a44
PS C:\Users\HARI> Get-Service -DisplayName "Print*"
Status   Name               DisplayName
------   ----               -----------
Stopped  PrintNotify        Printer Extensions and Notifications
Running  PrintWorkflowUs... PrintWorkflow_43a44
Running  Spooler            Print Spooler
PS C:\Users\HARI> Get-Service -DisplayName "Print Spooler"
Status   Name               DisplayName
------   ----               -----------
Running  Spooler            Print Spooler
PS C:\Users\HARI> Get-Service | Format-Table Name, Status, StartType
Name                                                    Status StartType
----                                                    ------ ---------
AJRouter                                               Stopped    Manual
ALG                                                    Stopped    Manual
AppIDSvc                                               Stopped    Manual
Appinfo                                                Running    Manual
PS C:\Users\HARI> Get-Service | Select-Object Name, Status, StartType
Name                                                    Status StartType
----                                                    ------ ---------
AJRouter                                               Stopped    Manual
ALG                                                    Stopped    Manual
AppIDSvc                                               Stopped    Manual
Appinfo                                                Running    Manual
PS C:\Users\HARI> Get-Service | Where-Object { $_.Status -eq "Running" }
Status   Name               DisplayName
------   ----               -----------
Running  Appinfo            Application Information
Running  AppXSvc            AppX Deployment Service (AppXSVC)
Running  AudioEndpointBu... Windows Audio Endpoint Builder
Running  Audiosrv           Windows Audio
PS C:\Users\HARI> Get-Service | Select-Object Name, Status, StartType | Where-Object { $_.Status -eq "Running" -and $_.StartType -eq "Automatic" }
Name                        Status StartType
----                        ------ ---------
AudioEndpointBuilder       Running Automatic
Audiosrv                   Running Automatic
BFE                        Running Automatic
BITS                       Running Automatic
BrokerInfrastructure       Running Automatic
 Stop-Service
The "Stop-Service" in PowerShell is used to stop one or more running services on a Windows system. It allows you to gracefully stop services by sending a stop signal to the specified services.
PS C:\WINDOWS\system32> Stop-Service -Name "ServiceName"
PS C:\WINDOWS\system32>
PS C:\WINDOWS\system32> Stop-Service -Name "Service1", "Service2", "Service3"
PS C:\WINDOWS\system32> 
PS C:\WINDOWS\system32> Stop-Service -Name "<ServiceName>" -Force
PS C:\WINDOWS\system32>
PS C:\WINDOWS\system32> Get-Service -Name "Spooler"
Status   Name               DisplayName
------   ----               -----------
Running  Spooler            Print Spooler
PS C:\WINDOWS\system32> Stop-Service -Name "Spooler"
PS C:\WINDOWS\system32>
PS C:\WINDOWS\system32> Get-Service -Name "Spooler"
Status   Name               DisplayName
------   ----               -----------
Stopped  Spooler            Print Spooler
 Start-Service
The "Start-Service" in PowerShell is used to start one or more stopped services on a Windows system. It allows to initiate the start process for the specified services.
Syntax Samples:
PS C:\WINDOWS\system32> Start-Service -Name "<ServiceName>"
PS C:\WINDOWS\system32> 
PS C:\WINDOWS\system32> Start-Service -Name "Service1", "Service2", "Service3"
PS C:\WINDOWS\system32> 
PS C:\WINDOWS\system32> Start-Service -Name "ServiceName" -TimeoutSec 30
PS C:\WINDOWS\system32>
PS C:\WINDOWS\system32> Start-Service -Name "ServiceName" -Delay 5
PS C:\WINDOWS\system32> 
Examples:
PS C:\WINDOWS\system32> Get-Service -Name "Spooler"
Status   Name               DisplayName
------   ----               -----------
Stopped  Spooler            Print Spooler
PS C:\WINDOWS\system32>
PS C:\WINDOWS\system32> Start-Service -Name "Spooler"
PS C:\WINDOWS\system32>
PS C:\WINDOWS\system32>
PS C:\WINDOWS\system32> Get-Service -Name "Spooler"
Status   Name               DisplayName
------   ----               -----------
Running  Spooler            Print Spooler
 Get-Location
The "Get-Location" in PowerShell is used to retrieve the current working location, which represents the directory or folder we are currently in within the file system.
PS C:\Users\HARI> Get-Location
Path
----
C:\Users\HARI
PS C:\Users\HARI> pwd
Path
----
C:\Users\HARI
 Set-Location
The "Set-Location" in PowerShell is used to change the current working location to a specified directory or folder within the file system. It allows to navigate to different directories within PowerShell.
PS C:\Users\HARI>  Set-Location -Path "C:\Users\HARI\Documents"
PS C:\Users\HARI\Documents>
PS C:\Users\HARI\Documents> Get-Location
Path
----
C:\Users\HARI\Documents
PS C:\Users\HARI\Documents>  Set-Location -Path "D:\"
PS D:\>
PS D:\> Get-Location
Path
----
D:\
PS D:\>  Set-Location -Path "C:\Users\HARI\"
PS C:\Users\HARI>
PS C:\Users\HARI> Get-Location
Path
----
C:\Users\HARI
PS C:\Users\HARI>
PS C:\Users\HARI> Set-Location -Path ".\Documents"
PS C:\Users\HARI\Documents>
PS C:\Users\HARI\Documents> Get-Location
Path
----
C:\Users\HARI\Documents
PS C:\Users\HARI\Documents> pwd
Path
----
C:\Users\HARI\Documents
PS C:\Users\HARI\Documents>
PS C:\Users\HARI\Documents> cd ..
PS C:\Users\HARI>
PS C:\Users\HARI> pwd
Path
----
C:\Users\HARI
PS C:\Users\HARI> cd Documents
PS C:\Users\HARI\Documents>
PS C:\Users\HARI\Documents> pwd
Path
----
C:\Users\HARI\Documents
PS C:\Users\HARI\Documents>
 Get-ChildItem
The "Get-ChildItem" cmdlet in PowerShell is used to retrieve the child items (files and directories) within a specified directory. It allows to list and access the contents of a directory.
PS C:\Users\HARI\Documents>  Set-Location -Path "C:\Users\HARI\"
PS C:\Users\HARI>
PS C:\Users\HARI>  Get-ChildItem
    Directory: C:\Users\HARI
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-r---        19-03-2023     00:27                Contacts
d-r---        22-06-2023     17:10                Desktop
d-r---        02-06-2023     15:47                Documents
d-r---        22-06-2023     20:21                Downloads
d-r---        19-03-2023     00:27                Favorites
d-r---        19-03-2023     00:27                Links
d-r---        19-03-2023     00:27                Music
dar--l        03-04-2023     19:37                OneDrive
d-r---        19-03-2023     00:27                Pictures
d-r---        19-03-2023     00:27                Saved Games
d-r---        19-03-2023     00:27                Searches
d-r---        19-06-2023     12:24                Videos
PS C:\Users\HARI> Get-ChildItem -Path "C:\Users\HARI\Pictures"
    Directory: C:\Users\HARI\Pictures
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-r---        02-10-2022     07:06                Camera Roll
d-r---        02-10-2022     07:06                Saved Pictures
d-r---        05-06-2023     21:34                Screenshots
PS C:\Users\HARI> Get-ChildItem -Path "C:\Users\HARI\desktop" -Filter "*.html"
    Directory: C:\Users\HARI\desktop
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        08-06-2023     13:57           4321 table.html
-a----        08-06-2023     15:53           4298 table_2.html
PS C:\Users\HARI>
 New-Item
The "New-Item" cmdlet in PowerShell is used to create a new item, such as a file or directory, in a specified location within the file system.
Syntax to create directory or file:
PS C:\Users\HARI> New-Item -ItemType Directory -Path "<File-Path>\<New Directory Name>"
PS C:\Users\HARI>
PS C:\Users\HARI> New-Item -ItemType File -Path "<File-Path>\<New File Name>"
PS C:\Users\HARI>
Examples:
PS C:\Users\HARI> New-Item -ItemType Directory -Path "C:\Users\HARI\Desktop\Test Folder"
    Directory: C:\Users\HARI\Desktop
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----        23-06-2023     10:42                Test Folder
PS C:\Users\HARI>
PS C:\Users\HARI> New-Item -ItemType File -Path "C:\Users\HARI\Desktop\Test Folder\Test File.txt"
    Directory: C:\Users\HARI\Desktop\Test Folder
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        23-06-2023     10:50              0 Test File.txt
PS C:\Users\HARI>
PS C:\Users\HARI> New-Item -ItemType Directory -Path "C:\Users\HARI\Desktop\Folder2", "C:\Users\HARI\Desktop\Folder3"
    Directory: C:\Users\HARI\Desktop
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----        23-06-2023     11:07                Folder2
d-----        23-06-2023     11:07                Folder3
PS C:\Users\HARI>
PS C:\Users\HARI> New-Item -ItemType File -Path "C:\Users\HARI\Desktop\Folder2\File1.txt", "C:\Users\HARI\Desktop\Folder2\File2.txt"
    Directory: C:\Users\HARI\Desktop\Folder2
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        23-06-2023     11:08              0 File1.txt
-a----        23-06-2023     11:08              0 File2.txt
PS C:\Users\HARI> New-Item -ItemType File -Path "C:\Users\HARI\Desktop\Folder2\File3.txt" -Value "This is the content of the file."
    Directory: C:\Users\HARI\Desktop\Folder2
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        23-06-2023     11:11             32 File3.txt
PS C:\Users\HARI> New-Item -ItemType File -Path "C:\Users\HARI\Desktop\Folder2\File4.txt" -Value "This is the content of the file 4."
    Directory: C:\Users\HARI\Desktop\Folder2
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        23-06-2023     11:18             34 File4.txt
 Get-Content
The "Get-Content" cmdlet in PowerShell is used to read the contents of a file and display it in the PowerShell console.
PS C:\Users\HARI> Get-Content -Path "C:\Users\HARI\Desktop\Folder2\File3.txt"
This is the content of the file.
PS C:\Users\HARI> Get-Content -Path "C:\Users\HARI\Desktop\Folder2\File3.txt", "C:\Users\HARI\Desktop\Folder2\File4.txt"
This is the content of the file.
This is the content of the file 4.
PS C:\Users\HARI> Get-Content -Path "C:\Users\HARI\Desktop\Folder2\File4.txt" >> "C:\Users\HARI\Desktop\Folder2\File5.txt"
PS C:\Users\HARI>
PS C:\Users\HARI> Get-Content -Path "C:\Users\HARI\Desktop\Folder2\File5.txt"
This is the content of the file 4.
PS C:\Users\HARI>
PS C:\Users\HARI> gc -Path "C:\Users\HARI\Desktop\Folder2\File4.txt"
This is the content of the file 4.
PS C:\Users\HARI>
PS C:\Users\HARI> Get-Content -Path "C:\Users\HARI\Desktop\Folder2\File5.txt"
2023-05-22 10:15:21 [INFO] Application started.
2023-05-22 10:15:23 [DEBUG] Initializing database connection.
2023-05-22 10:15:25 [INFO] Database connection established successfully.
2023-05-22 10:15:27 [WARNING] Invalid input detected.
2023-05-22 10:15:27 [ERROR] Failed to process request: Invalid input format.
2023-05-22 10:15:30 [DEBUG] Sending data to external API.
2023-05-22 10:15:33 [DEBUG] Received response from API: 200 OK.
2023-05-22 10:15:35 [INFO] Application shutdown initiated.
2023-05-22 10:15:37 [INFO] Application shutdown completed.
PS C:\Users\HARI> Get-Content -Path "C:\Users\HARI\Desktop\Folder2\File5.txt" | Select-String -Pattern "error"
2023-05-22 10:15:27 [ERROR] Failed to process request: Invalid input format.
PS C:\Users\HARI> Get-Content -Path "C:\Users\HARI\Desktop\Folder2\File5.txt" | Select-String -Pattern "INFO"
2023-05-22 10:15:21 [INFO] Application started.
2023-05-22 10:15:25 [INFO] Database connection established successfully.
2023-05-22 10:15:35 [INFO] Application shutdown initiated.
2023-05-22 10:15:37 [INFO] Application shutdown completed.
2023-05-22 10:15:42 [INFO] Data processing completed successfully. Processed 100 records.
2023-05-22 10:15:50 [INFO] Report generated and saved to /var/logs/reports/report_20230522.pdf.
PS C:\Users\HARI> Get-Content -Path "C:\Users\HARI\Desktop\Folder2\File5.txt" -Tail 5
2023-05-22 10:22:30 [DEBUG] Generating report.
2023-05-22 10:22:35 [INFO] Report generated and saved to /var/reports/weekly_report_202305.pdf.
2023-05-22 10:22:40 [DEBUG] Scheduled task: Report generation completed.
2023-05-22 10:22:45 [DEBUG] Exiting application.
2023-05-22 10:22:50 [INFO] Application exited.
PS C:\Users\HARI> Get-Content -Path "C:\Users\HARI\Desktop\Folder2\File5.txt" -Head 5
2023-05-22 10:15:21 [INFO] Application started.
2023-05-22 10:15:23 [DEBUG] Initializing database connection.
2023-05-22 10:15:25 [INFO] Database connection established successfully.
2023-05-22 10:15:27 [WARNING] Invalid input detected.
2023-05-22 10:15:27 [ERROR] Failed to process request: Invalid input format.
PS C:\Users\HARI> Get-Content -Path "C:\Users\HARI\Desktop\Folder2\File5.txt" | Select-Object  -First 18
2023-05-22 10:15:21 [INFO] Application started.
2023-05-22 10:15:23 [DEBUG] Initializing database connection.
2023-05-22 10:15:25 [INFO] Database connection established successfully.
2023-05-22 10:15:27 [WARNING] Invalid input detected.
2023-05-22 10:15:27 [ERROR] Failed to process request: Invalid input format.
2023-05-22 10:15:30 [DEBUG] Sending data to external API.
2023-05-22 10:15:33 [DEBUG] Received response from API: 200 OK.
2023-05-22 10:15:35 [INFO] Application shutdown initiated.
2023-05-22 10:15:37 [INFO] Application shutdown completed.
2023-05-22 10:15:40 [DEBUG] Starting data processing.
2023-05-22 10:15:42 [INFO] Data processing completed successfully. Processed 100 records.
2023-05-22 10:15:45 [DEBUG] Generating report.
2023-05-22 10:15:50 [INFO] Report generated and saved to /var/logs/reports/report_20230522.pdf.
2023-05-22 10:15:52 [DEBUG] Archiving processed data.
2023-05-22 10:15:55 [INFO] Processed data archived successfully. Archive location: /var/data/archive_20230522.zip.
2023-05-22 10:15:58 [DEBUG] Cleaning up temporary files.
2023-05-22 10:16:00 [INFO] Temporary files cleaned up.
2023-05-22 10:16:02 [DEBUG] Exiting application.
PS C:\Users\HARI> Get-Content -Path "C:\Users\HARI\Desktop\Folder2\File5.txt" | Select-Object -Skip 5 -First 10
2023-05-22 10:15:30 [DEBUG] Sending data to external API.
2023-05-22 10:15:33 [DEBUG] Received response from API: 200 OK.
2023-05-22 10:15:35 [INFO] Application shutdown initiated.
2023-05-22 10:15:37 [INFO] Application shutdown completed.
2023-05-22 10:15:40 [DEBUG] Starting data processing.
2023-05-22 10:15:42 [INFO] Data processing completed successfully. Processed 100 records.
2023-05-22 10:15:45 [DEBUG] Generating report.
2023-05-22 10:15:50 [INFO] Report generated and saved to /var/logs/reports/report_20230522.pdf.
2023-05-22 10:15:52 [DEBUG] Archiving processed data.
2023-05-22 10:15:55 [INFO] Processed data archived successfully. Archive location: /var/data/archive_20230522.zip.
 
PS C:\Users\HARI> Get-Content -Path "\\RemoteServer\Share\File.txt"
 Add-Content
The "Add-Content" cmdlet in PowerShell is used to append content to the end of a file. It allows to add new data or text to an existing file without overwriting the existing content.
PS C:\Users\HARI> Get-Content -Path "C:\Users\HARI\Desktop\Folder2\File4.txt"
This is the content of the file 4.
PS C:\Users\HARI> Add-Content -Path "C:\Users\HARI\Desktop\Folder2\File4.txt" -Value "This is the new line of content updated."
PS C:\Users\HARI>
PS C:\Users\HARI> Get-Content -Path "C:\Users\HARI\Desktop\Folder2\File4.txt"
This is the content of the file 4.This is the new line of content updated.
PS C:\Users\HARI> Add-Content -Path "C:\Users\HARI\Desktop\Folder2\File4.txt" -Value "New line 1`nNew line 2`nNew line 3"
PS C:\Users\HARI>
PS C:\Users\HARI> Get-Content -Path "C:\Users\HARI\Desktop\Folder2\File4.txt"
This is the content of the file 4.This is the new line of content updated.
New line 1
New line 2
New line 3
PS C:\Users\HARI>
 Out-File
The "Out-File" cmdlet in PowerShell is used to save the output of a command or script to a file. It allows to redirect the output to a file for later use or analysis. The "Out-File" cmdlet provides more control over the file output, including the ability to specify the encoding, append content to an existing file, and customize the formatting of the output.
PS C:\Users\HARI> "This is sample test to test" | Out-File -FilePath "C:\Users\HARI\Desktop\Folder2\File4.txt"
PS C:\Users\HARI>
PS C:\Users\HARI> Get-Content -Path "C:\Users\HARI\Desktop\Folder2\File4.txt"
This is sample test to test
PS C:\Users\HARI> "This is sample test to test Append option." | Out-File -FilePath "C:\Users\HARI\Desktop\Folder2\File4.txt"  -Append
PS C:\Users\HARI>
PS C:\Users\HARI> Get-Content -Path "C:\Users\HARI\Desktop\Folder2\File4.txt"
This is sample test to test
This is sample test to test Append option.
PS C:\Users\HARI>  Get-Service | Out-File -FilePath "C:\Users\HARI\Desktop\Folder2\File3.txt"
PS C:\Users\HARI>
PS C:\Users\HARI> Get-Content -Path "C:\Users\HARI\Desktop\Folder2\File3.txt"  -Head 8
Status   Name               DisplayName
------   ----               -----------
Stopped  AJRouter           AllJoyn Router Service
Stopped  ALG                Application Layer Gateway Service
Stopped  AppIDSvc           Application Identity
Running  Appinfo            Application Information
Stopped  AppReadiness       App Readiness
 Copy-Item
The "Copy-Item" cmdlet in PowerShell is used to copy files and directories from one location to another. It allows to duplicate files and directories within the same location or across different locations.
The "Copy-Item" cmdlet uses several additional parameters that allow to customize the copy operation:
Recurse	:	Allows to copy directories recursively, including all subdirectories and files.
Force	:	Allows to overwrite existing files in the destination folder without prompting for confirmation.
Filter	:	Allows to specify a wildcard pattern to filter the files to be copied.
Exclude	:	Allows to specify a wildcard pattern to exclude certain files from being copied.
Container:	Allows to copy the container folder without its content.
Copy file to directory/folder:
PS C:\Users\HARI\Desktop> Copy-Item -Path "C:\Users\HARI\Desktop\Folder2\File1.txt" -Destination "C:\Users\HARI\Desktop\Folder3\"
Copy multiple files to directory/folder:
PS C:\Users\HARI\Desktop> Copy-Item -Path "C:\Users\HARI\Desktop\Folder2\File2.txt", "C:\Users\HARI\Desktop\Folder2\File3.txt" -Destination "C:\Users\HARI\Desktop\Folder3\"
Rename file while copying to directory/folder:
PS C:\Users\HARI\Desktop> Copy-Item -Path "C:\Users\HARI\Desktop\Folder2\File4.txt" -Destination "C:\Users\HARI\Desktop\Folder3\File_Renamed.txt"
Refer the below for results to above commands (cmdlet's):
PS C:\Users\HARI\Desktop>  Get-ChildItem -Path "C:\Users\HARI\Desktop\Folder3"
    Directory: C:\Users\HARI\Desktop\Folder3
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        23-06-2023     11:08              0 File1.txt
-a----        23-06-2023     11:08              0 File2.txt
-a----        23-06-2023     17:20          40950 File3.txt
-a----        23-06-2023     14:31            150 File_Renamed.txt
Copy directory to another directory/folder with all subdirectories and files:
PS C:\Users\HARI\Desktop> Copy-Item -Path "C:\Users\HARI\Desktop\Folder3" -Destination "C:\Users\HARI\Desktop\Folder1" -Recurse
PS C:\Users\HARI\Desktop>
PS C:\Users\HARI\Desktop>  Get-ChildItem -Path "C:\Users\HARI\Desktop\Folder1"
    Directory: C:\Users\HARI\Desktop\Folder1
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----        23-06-2023     22:31                Folder3
PS C:\Users\HARI\Desktop>  Get-ChildItem -Path "C:\Users\HARI\Desktop\Folder1\Folder3"
    Directory: C:\Users\HARI\Desktop\Folder1\Folder3
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        23-06-2023     11:08              0 File1.txt
-a----        23-06-2023     11:08              0 File2.txt
-a----        23-06-2023     17:20          40950 File3.txt
-a----        23-06-2023     14:31            150 File_Renamed.txt
 Move-Item
The "Move-Item" cmdlet in PowerShell is used to move a file or directory from one location to another. It allows to relocate files and directories within the same location or across different locations.
The "Move-Item" cmdlet uses several additional parameters that allow to customize the move operation, some are:
Recurse	:	Allows to copy directories recursively, including all subdirectories and files.
Force	:	Allows to overwrite existing files in the destination folder without prompting for confirmation.
Filter	:	Allows to specify a wildcard pattern to filter the files to be copied.
Current directory information:
PS C:\Users\HARI\Desktop\Folder3>  Get-Location
Path
----
C:\Users\HARI\Desktop\Folder3
PS C:\Users\HARI\Desktop\Folder3> Get-ChildItem -Path "C:\Users\HARI\Desktop\Folder3"
    Directory: C:\Users\HARI\Desktop\Folder3
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----        27-06-2023     02:13                Dir1
d-----        27-06-2023     02:07                Dir2
d-----        27-06-2023     02:16                Dir3
d-----        27-06-2023     02:16                Dir4
d-----        27-06-2023     02:16                Dir5
-a----        23-06-2023     11:08              0 File1.txt
-a----        23-06-2023     11:08              0 File2.txt
-a----        23-06-2023     17:20          40950 File3.txt
-a----        23-06-2023     14:31            150 File_Renamed.txt
-a----        27-06-2023     02:04              0 test.txt
Move file to directory/folder:
PS C:\Users\HARI\Desktop\Folder3> Move-Item -Path "C:\Users\HARI\Desktop\Folder3\File1.txt" -Destination "C:\Users\HARI\Desktop\Folder3\Dir1"
Rename file while moving to directory/folder:
PS C:\Users\HARI\Desktop\Folder3> Move-Item -Path "C:\Users\HARI\Desktop\Folder3\File2.txt" -Destination "C:\Users\HARI\Desktop\Folder3\Dir1\NewName.txt"
Move directory to directory/folder:
PS C:\Users\HARI\Desktop\Folder3> Move-Item -Path "C:\Users\HARI\Desktop\Folder3\Dir2" -Destination "C:\Users\HARI\Desktop\Folder3\Dir1"
Move file to directory/folder forcefully:
PS C:\Users\HARI\Desktop\Folder3> Move-Item -Path "C:\Users\HARI\Desktop\Folder3\File3.txt" -Destination "C:\Users\HARI\Desktop\Folder3\Dir1" -Force
Move directory to another directory/folder forcefully:
PS C:\Users\HARI\Desktop\Folder3> Move-Item -Path "C:\Users\HARI\Desktop\Folder3\Dir3" -Destination "C:\Users\HARI\Desktop\Folder3\Dir1" -Force
Refer the below for results to above commands (cmdlet's):
PS C:\Users\HARI\Desktop\Folder3> Get-ChildItem -Path "C:\Users\HARI\Desktop\Folder3"
    Directory: C:\Users\HARI\Desktop\Folder3
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----        27-06-2023     02:13                Dir1
d-----        27-06-2023     02:16                Dir4
d-----        27-06-2023     02:16                Dir5
-a----        23-06-2023     14:31            150 File_Renamed.txt
-a----        27-06-2023     02:04              0 test.txt
Move files which match with pattern to another directory/folder:
PS C:\Users\HARI\Desktop\Folder3> Move-Item -Path "C:\Users\HARI\Desktop\Folder3\*.txt" -Destination "C:\Users\HARI\Desktop\Folder3\Dir1"
Refer the below for results to above commands (cmdlet's):
PS C:\Users\HARI\Desktop\Folder3> Get-ChildItem -Path "C:\Users\HARI\Desktop\Folder3"
    Directory: C:\Users\HARI\Desktop\Folder3
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----        27-06-2023     02:24                Dir1
d-----        27-06-2023     02:16                Dir4
d-----        27-06-2023     02:16                Dir5
PS C:\Users\HARI\Desktop\Folder3> Get-ChildItem -Path "C:\Users\HARI\Desktop\Folder3\Dir1\"
    Directory: C:\Users\HARI\Desktop\Folder3\Dir1
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----        27-06-2023     02:07                Dir2
d-----        27-06-2023     02:16                Dir3
-a----        23-06-2023     11:08              0 File1.txt
-a----        23-06-2023     17:20          40950 File3.txt
-a----        23-06-2023     14:31            150 File_Renamed.txt
-a----        23-06-2023     11:08              0 NewName.txt
-a----        27-06-2023     02:04              0 test.txt
 Remove-Item
The "Remove-Item" cmdlet in PowerShell is used to delete files and directories. It allows to remove individual files, empty directories, or directories and their contents.
The "Remove-Item" cmdlet uses several additional parameters that allow to customize the remove operation, some are:
Force	: Allows to force the deletion of read-only files or directories.
Filter	: Allows to specify a wildcard pattern to filter the files or directories to be deleted.
Exclude	: Allows to specify a wildcard pattern to exclude certain files or directories from being deleted.
 Current directory information:
PS C:\Users\HARI\Desktop\Folder3> Get-ChildItem -Path "C:\Users\HARI\Desktop\Folder3"
    Directory: C:\Users\HARI\Desktop\Folder3
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----        27-06-2023     02:24                Dir1
d-----        27-06-2023     02:16                Dir4
d-----        27-06-2023     02:16                Dir5
d-----        27-06-2023     11:56                Dir6
d-----        27-06-2023     12:00                Dir8
-a----        27-06-2023     11:28              0 file1.txt
-a----        27-06-2023     11:28              0 file2.txt
-a----        27-06-2023     11:28              0 file3.txt
-a----        27-06-2023     11:29              0 file4.txt
-a----        27-06-2023     11:29              0 file5.txt
-a----        27-06-2023     11:54              0 file6.txt
 Remove a file:
PS C:\Users\HARI\Desktop\Folder3> Remove-Item -Path "C:\Users\HARI\Desktop\Folder3\file1.txt"
PS C:\Users\HARI\Desktop\Folder3> Remove-Item -Path "C:\Users\HARI\Desktop\Folder3\file2.txt" -Force
 Remove Multiple Files:
PS C:\Users\HARI\Desktop\Folder3> Remove-Item -Path "C:\Users\HARI\Desktop\Folder3\file3.txt", "C:\Users\HARI\Desktop\Folder3\file4.txt"
 Remove directory:
PS C:\Users\HARI\Desktop\Folder3> Remove-Item -Path "C:\Users\HARI\Desktop\Folder3\Dir6"
Remove directory and its contents with the "-Recurse" parameter:
PS C:\Users\HARI\Desktop\Folder3> Remove-Item -Path "C:\Users\HARI\Desktop\Folder3\Dir8" -Recurse
Refer the below for results to above commands (cmdlet's):
PS C:\Users\HARI\Desktop\Folder3> Get-ChildItem -Path "C:\Users\HARI\Desktop\Folder3"
    Directory: C:\Users\HARI\Desktop\Folder3
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----        27-06-2023     02:24                Dir1
d-----        27-06-2023     02:16                Dir4
d-----        27-06-2023     02:16                Dir5
-a----        27-06-2023     11:29              0 file5.txt
-a----        27-06-2023     11:54              0 file6.txt
 Test-Path
The "Test-Path" cmdlet in PowerShell is used to check whether a file or directory exists at a specified path. It returns a Boolean value (True or False) indicating the existence of the item.
Current directory information:
PS C:\Users\HARI\Desktop\Folder3> Get-ChildItem -Path "C:\Users\HARI\Desktop\Folder3"
    Directory: C:\Users\HARI\Desktop\Folder3
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----        27-06-2023     02:24                Dir1
d-----        27-06-2023     02:16                Dir4
d-----        27-06-2023     02:16                Dir5
-a----        27-06-2023     11:29              0 file5.txt
-a----        27-06-2023     11:54              0 file6.txt
 Test the existence of a file:
PS C:\Users\HARI\Desktop\Folder3> Test-Path -Path "C:\Users\HARI\Desktop\Folder3\file5.txt"
True
 Test the existence of a directory:
PS C:\Users\HARI\Desktop\Folder3> Test-Path -Path "C:\Users\HARI\Desktop\Folder3"
True
 Test the Existence of Multiple Paths:
PS C:\Users\HARI\Desktop\Folder3> Test-Path -Path "C:\Users\HARI\Desktop\Folder3\file5.txt", "C:\Users\HARI\Desktop\Folder3\file6.txt"
True
True
 Test the Existence of Wildcard Patterns:
PS C:\Users\HARI\Desktop\Folder3> Test-Path -Path "C:\Users\HARI\Desktop\Folder3\*.txt"
True
 Clear-Host
The "Clear-Host" cmdlet in PowerShell is used to clear the contents of the console window, providing a clean and empty slate for new output. 
PS C:\Users\HARI\Desktop\Folder3> Clear-Host
PS C:\Users\HARI\Desktop\Folder3>
 Select-String
The "Select-String" cmdlet in PowerShell is used to search for text patterns or regular expressions within files or strings. It returns the matching lines or patterns found in the specified input.
Search for a pattern in a file:
Syntax:
Select-String -Path "FilePath\FileName" -Pattern "pattern"
Ex:
PS C:\Users\HARI\Desktop\Folder3> Select-String -Path "C:\Users\HARI\Desktop\Folder3\File5.txt" -Pattern "Application"
File5.txt:1:2023-05-22 10:15:21 [INFO] Application started.
File5.txt:8:2023-05-22 10:15:35 [INFO] Application shutdown initiated.
File5.txt:9:2023-05-22 10:15:37 [INFO] Application shutdown completed.
File5.txt:18:2023-05-22 10:16:02 [DEBUG] Exiting application.
File5.txt:19:2023-05-22 10:16:04 [INFO] Application exited.
File5.txt:49:2023-05-22 10:18:10 [DEBUG] Exiting application.
File5.txt:50:2023-05-22 10:18:15 [INFO] Application exited.
File5.txt:104:2023-05-22 10:22:45 [DEBUG] Exiting application.
File5.txt:105:2023-05-22 10:22:50 [INFO] Application exited.
PS C:\Users\HARI\Desktop\Folder3>
PS C:\Users\HARI\Desktop\Folder3> Select-String -Path "C:\Users\HARI\Desktop\Folder3\File5.txt" -Pattern "ERROR"
File5.txt:5:2023-05-22 10:15:27 [ERROR] Failed to process request: Invalid input format.
PS C:\Users\HARI\Desktop\Folder3>
PS C:\Users\HARI\Desktop\Folder3> Select-String -Path "C:\Users\HARI\Desktop\Folder3\File5.txt" -Pattern "Error"
File5.txt:5:2023-05-22 10:15:27 [ERROR] Failed to process request: Invalid input format.
PS C:\Users\HARI\Desktop\Folder3>
PS C:\Users\HARI\Desktop\Folder3> Select-String -Path "C:\Users\HARI\Desktop\Folder3\File5.txt" -Pattern "ERROR" -CaseSensitive
File5.txt:5:2023-05-22 10:15:27 [ERROR] Failed to process request: Invalid input format.
 Returns a Boolean value indicating if a match was found or not:
PS C:\Users\HARI\Desktop\Folder3> Select-String -Path "C:\Users\HARI\Desktop\Folder3\File5.txt" -Pattern "ERROR" -Quiet
True
PS C:\Users\HARI\Desktop\Folder3>
PS C:\Users\HARI\Desktop\Folder3> Select-String -Path "C:\Users\HARI\Desktop\Folder3\File5.txt" -Pattern "Error" -Quiet
True
 Search for a pattern in a string:
PS C:\Users\HARI\Desktop\Folder3> "Hello, World!" | Select-String -Pattern "World"
Hello, World!
 Select-Object
The "Select-Object" cmdlet in PowerShell is used to select and manipulate specific properties of objects in the pipeline. It allows to choose the properties we want to include in the output and perform various operations on those properties.
  First: This will return only first 5 lines from the result.
PS C:\WINDOWS\system32> Get-Service | Select-Object -First 5
Status   Name               DisplayName
------   ----               -----------
Running  AarSvc_4918a       Agent Activation Runtime_4918a
Stopped  AJRouter           AllJoyn Router Service
Stopped  ALG                Application Layer Gateway Service
Stopped  AppIDSvc           Application Identity
Running  Appinfo            Application Information
  Last: This will return only last 5 lines from the result.
PS C:\WINDOWS\system32> Get-Service | Select-Object -Last 5
Status   Name               DisplayName
------   ----               -----------
Stopped  WwanSvc            WWAN AutoConfig
Stopped  XblAuthManager     Xbox Live Auth Manager
Stopped  XblGameSave        Xbox Live Game Save
Stopped  XboxGipSvc         Xbox Accessory Management Service
Stopped  XboxNetApiSvc      Xbox Live Networking Service
  Filter: This will return last 2 lines from the first 5 lines of the result.
PS C:\WINDOWS\system32> Get-Service | Select-Object -First 5 | Select-Object -Last 2
Status   Name               DisplayName
------   ----               -----------
Stopped  AppIDSvc           Application Identity
Running  Appinfo            Application Information
PS C:\WINDOWS\system32> Get-Service | Select-Object -Property Name, Status -First 5
Name          Status
----          ------
AarSvc_4918a Running
AJRouter     Stopped
ALG          Stopped
AppIDSvc     Stopped
Appinfo      Running
 Unique: This will return unique data.
PS C:\WINDOWS\system32> Get-Service | Select-Object -Property Status -Unique
 Status
 ------
Running
Stopped
  Skip: This will skip the first line from the result
PS C:\WINDOWS\system32> Get-Service | Select-Object -Property Status -Unique | Select-Object -Skip 1
 Status
 ------
Stopped
 
 Set-Variable
The "Set-Variable" cmdlet in PowerShell is used to create or update a variable and assign a value to it.
 Syntax:
Set-Variable -Name "VariableName" -Value "Value"
 Creating a New Variable:
PS C:\Users\HARI\Desktop> Set-Variable -Name "MyVariable" -Value "Hello, World!"
PS C:\Users\HARI\Desktop>
 Updating the Value of an Existing Variable:
PS C:\Users\HARI\Desktop> Set-Variable -Name "MyVariable" -Value "New Value"
PS C:\Users\HARI\Desktop>
 Setting Variables from Command Output:
PS C:\Users\HARI\Desktop> Set-Variable -Name "Date" -Value $(Get-Date)
PS C:\Users\HARI\Desktop>
 Variable Global Scopes:
PS C:\Users\HARI\Desktop> Set-Variable -Name "GlobalVariable" -Value "Global Value" -Scope Global
PS C:\Users\HARI\Desktop>
 Read-Only Variables:
PS C:\Users\HARI\Desktop> Set-Variable -Name "ReadOnlyVariable" -Value "Read-only Value" -Option ReadOnly
PS C:\Users\HARI\Desktop>
 Environment Variables:
PS C:\Users\HARI\Desktop> Set-Variable -Name "Username" -Value $env:USERNAME
PS C:\Users\HARI\Desktop>
 Get-Variable
The "Get-Variable" cmdlet in PowerShell allows to retrieve information about variables in the current session. 
PS C:\Users\HARI\Desktop> Get-Variable
Name                           Value
----                           -----
Date                           28-06-2023 13:45:53
GlobalVariable                 Global Value
MyVariable                     New Value
PWD                            C:\Users\HARI\Desktop
ReadOnlyVariable               Read-only Value
 Filter variable by name: 
PS C:\Users\HARI\Desktop> Get-Variable -Name "myVariable"
Name                           Value
----                           -----
MyVariable                     New Value
 Filter variables by pattern: 
PS C:\Users\HARI\Desktop> Get-Variable -Name "*myVariable"
Name                           Value
----                           -----
MyVariable                     New Value
 Read-Host
The "Read-Host" cmdlet in PowerShell allows to prompt the user to enter input interactively during script execution.
PS C:\Users\HARI\Desktop> Read-Host -Prompt "Enter your name"
Enter your name:
PS C:\Users\HARI\Desktop> $name = Read-Host -Prompt "Enter your name"
Enter your name: 
PS C:\Users\HARI\Desktop> $name = Read-Host -Prompt "Enter your name"
Enter your name: Hari
 Write-Host
The "Write-Host" cmdlet in PowerShell is used to display output in the console or terminal window. It allows to output text or other data to the screen.
PS C:\Users\HARI\Desktop> Write-Host "Hello, World!"
Hello, World!
PS C:\Users\HARI\Desktop> $name = "Hari"
PS C:\Users\HARI\Desktop> $age = 30
PS C:\Users\HARI\Desktop> Write-Host "Hello, $name! You are $age years old."
Hello, Hari! You are 30 years old.
PS C:\Users\HARI\Desktop> Write-Host "Name: $name"
Name: Hari
PS C:\Users\HARI\Desktop> Write-Host "Age: $age"
Age: 30
PS C:\Users\HARI\Desktop> Write-Host ("-" * 40)
----------------------------------------
PS C:\Users\HARI\Desktop>
PS C:\Users\HARI\Desktop> Write-Host ("-" * 5)
-----
 Write-Output
The "Write-Output" cmdlet in PowerShell is used to send output to the pipeline. It allows to display information or pass data to the next command in the pipeline.
PS C:\Users\HARI\Desktop> Write-Output "Hello, World!"
Hello, World!
PS C:\Users\HARI\Desktop>
PS C:\Users\HARI\Desktop> $name = "Hari"
PS C:\Users\HARI\Desktop>
PS C:\Users\HARI\Desktop> $age = 30
PS C:\Users\HARI\Desktop>
PS C:\Users\HARI\Desktop> Write-Output "Name: $name"
Name: Hari
PS C:\Users\HARI\Desktop>
PS C:\Users\HARI\Desktop> Write-Output "Age: $age"
Age: 30
PS C:\Users\HARI\Desktop>
PS C:\Users\HARI\Desktop> Write-Output ("-" * 40)
----------------------------------------
PS C:\Users\HARI\Desktop>
PS C:\Users\HARI\Desktop> Write-Output "Hello, World!" ("-" * 40) "Name: $name" "Age: $age"  ("-" * 40)
Hello, World!
----------------------------------------
Name: Hari
Age: 30
----------------------------------------
Get-Command
The "Get-Command" cmdlet in PowerShell is used to retrieve information about cmdlets, functions, scripts, and other executable commands available in PowerShell. It allows to search for specific commands, get details about their usage, and explore the available commands within PowerShell environment.
 If we use "Get-Command" cmdlet without any arguments, we will get all the available commands in the current PowerShell session. Some displayed for reference.
PS C:\Users\HARI\Desktop> Get-Command
CommandType     Name                                  Version    Source
-----------     ----                                  -------    ------
Alias           Add-AppPackage                        2.0.1.0    Appx
Alias           Add-AppPackageVolume                  2.0.1.0    Appx
Alias           Add-AppProvisionedPackage             3.0        Dism
Function        Update-Script                         1.0.0.1    PowerShellGet
Function        Update-ScriptFileInfo                 1.0.0.1    PowerShellGet
Cmdlet          Clear-History                         3.0.0.0    Microsoft.PowerShell.Core
Cmdlet          Get-Process                           3.1.0.0    Microsoft.PowerShell.Management
Cmdlet          Write-Host                            3.1.0.0    Microsoft.PowerShell.Utility
Cmdlet          Write-Output                          3.1.0.0    Microsoft.PowerShell.Utility
 
PS C:\WINDOWS\system32> Get-Command -Name Get-Process
CommandType     Name                                       Version    Source
-----------     ----                                       -------    ------
Cmdlet          Get-Process                                3.1.0.0    Microsoft.PowerShell.Management
PS C:\WINDOWS\system32> Get-Command -Name Get-Service
CommandType     Name                                       Version    Source
-----------     ----                                       -------    ------
Cmdlet          Get-Service                                3.1.0.0    Microsoft.PowerShell.Management
PS C:\WINDOWS\system32> Get-Command | Select-Object -First 5
CommandType     Name                                       Version    Source
-----------     ----                                       -------    ------
Alias           Add-AppPackage                             2.0.1.0    Appx
Alias           Add-AppPackageVolume                       2.0.1.0    Appx
Alias           Add-AppProvisionedPackage                  3.0        Dism
Alias           Add-ProvisionedAppPackage                  3.0        Dism
Alias           Add-ProvisionedAppSharedPackageContainer   3.0        Dism
PS C:\WINDOWS\system32> Get-Command -Name *-Service
CommandType     Name                                       Version    Source
-----------     ----                                       -------    ------
Cmdlet          Get-Service                                3.1.0.0    Microsoft.PowerShell.Management
Cmdlet          New-Service                                3.1.0.0    Microsoft.PowerShell.Management
Cmdlet          Restart-Service                            3.1.0.0    Microsoft.PowerShell.Management
Cmdlet          Resume-Service                             3.1.0.0    Microsoft.PowerShell.Management
Cmdlet          Set-Service                                3.1.0.0    Microsoft.PowerShell.Management
Cmdlet          Start-Service                              3.1.0.0    Microsoft.PowerShell.Management
Cmdlet          Stop-Service                               3.1.0.0    Microsoft.PowerShell.Management
Cmdlet          Suspend-Service                            3.1.0.0    Microsoft.PowerShell.Management
Get-Help
The "Get-Help" cmdlet in PowerShell is used to retrieve information about PowerShell commands, modules, functions, and other topics. It provides detailed documentation and examples to help us understand and use various PowerShell features
 Syntax:
Get-Help <CommandName>
(OR)
Get-Help <CommandName> -Examples
(OR)
Get-Help <CommandName> -Detailed	
(OR)
Get-Help <CommandName> -Full
Examples:
PS C:\WINDOWS\system32>  Get-Help Get-Date
NAME
    Get-Date
SYNTAX
    Get-Date [[-Date] <datetime>] [-Year <int>] [-Month <int>] [-Day <int>] [-Hour <int>] [-Minute <int>] [-Second <int>]
    [-Millisecond <int>] [-DisplayHint {Date | Time | DateTime}] [-Format <string>]  [<CommonParameters>]
    Get-Date [[-Date] <datetime>] [-Year <int>] [-Month <int>] [-Day <int>] [-Hour <int>] [-Minute <int>] [-Second <int>]
    [-Millisecond <int>] [-DisplayHint {Date | Time | DateTime}] [-UFormat <string>]  [<CommonParameters>]
ALIASES
    None
REMARKS
    Get-Help cannot find the Help files for this cmdlet on this computer. It is displaying only partial help.
        -- To download and install Help files for the module that includes this cmdlet, use Update-Help.
        -- To view the Help topic for this cmdlet online, type: "Get-Help Get-Date -Online" or
           go to https://go.microsoft.com/fwlink/?LinkID=113313.
PS C:\WINDOWS\system32>  Get-Help Move-Item  -Examples
NAME
    Move-Item
ALIASES
    mi
    mv
    move
REMARKS
    Get-Help cannot find the Help files for this cmdlet on this computer. It is displaying only partial help.
        -- To download and install Help files for the module that includes this cmdlet, use Update-Help.
        -- To view the Help topic for this cmdlet online, type: "Get-Help Move-Item -Online" or
           go to https://go.microsoft.com/fwlink/?LinkID=113350.
PS C:\WINDOWS\system32>  Get-Help Move-Item  -Detailed
NAME
    Move-Item
SYNTAX
    Move-Item [-Path] <string[]> [[-Destination] <string>] [-Force] [-Filter <string>] [-Include <string[]>] [-Exclude
    <string[]>] [-PassThru] [-Credential <pscredential>] [-WhatIf] [-Confirm] [-UseTransaction]  [<CommonParameters>]
    Move-Item [[-Destination] <string>] -LiteralPath <string[]> [-Force] [-Filter <string>] [-Include <string[]>] [-Exclude
    <string[]>] [-PassThru] [-Credential <pscredential>] [-WhatIf] [-Confirm] [-UseTransaction]  [<CommonParameters>]
PARAMETERS
    -Confirm
    -Credential <pscredential>
    -Destination <string>
    -Exclude <string[]>
    -Filter <string>
    -Force
    -Include <string[]>
    -LiteralPath <string[]>
    -PassThru
    -Path <string[]>
    -UseTransaction
    -WhatIf
    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer, PipelineVariable, and OutVariable. For more information, see
        about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
ALIASES
    mi
    mv
    move
REMARKS
    Get-Help cannot find the Help files for this cmdlet on this computer. It is displaying only partial help.
        -- To download and install Help files for the module that includes this cmdlet, use Update-Help.
        -- To view the Help topic for this cmdlet online, type: "Get-Help Move-Item -Online" or
           go to https://go.microsoft.com/fwlink/?LinkID=113350.
Get-Host
The "Get-Host" command displays information about the Windows PowerShell console, which is the current host program for Windows PowerShell.
PS C:\Users\HARI> Get-host
Name             : ConsoleHost
Version          : 5.1.22621.963
InstanceId       : 1f0d1a86-68fc-43b2-a336-d0fd1ea364d0
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : en-IN
CurrentUICulture : en-US
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace
PS C:\Users\HARI>