Add System_Management
This commit is contained in:
131
5.System_Management/PowerShell System Management.md
Normal file
131
5.System_Management/PowerShell System Management.md
Normal file
@@ -0,0 +1,131 @@
|
||||
# PowerShell System Management
|
||||
|
||||
## Get-ComputerInfo
|
||||
|
||||
For having information about the system
|
||||
|
||||
```powershell
|
||||
Get-ComputerInfo
|
||||
|
||||
$serverInfo = Get-ComputerInfo
|
||||
$serverInfo.OsVersion
|
||||
Get-ComputerInfo | Seleect-Object -Property 'Timezone'
|
||||
```
|
||||
|
||||
## Processes
|
||||
|
||||
Windows **processes** are running instances of programs that contain
|
||||
their own memory space and system resources.
|
||||
Each process can host one or more threads and is
|
||||
managed by the operating system to provide isolation, scheduling,
|
||||
and controlled access to system resources.
|
||||
|
||||
### Get-Process
|
||||
|
||||
For having all the process
|
||||
|
||||
```powershell
|
||||
Get-Process
|
||||
|
||||
#find one by name
|
||||
Get-Process -Name taskmngr
|
||||
|
||||
Get-Process | Format-Table -Property Name, Id
|
||||
```
|
||||
|
||||
### Start-Process
|
||||
|
||||
start a process
|
||||
|
||||
```Powershell
|
||||
Start-Process -FilePath "C:\Windows\system32\notepad.exe"
|
||||
```
|
||||
|
||||
### Stop-Process
|
||||
|
||||
```powershell
|
||||
Stop-Process -Name "notepad"
|
||||
|
||||
Stop-Process -Name "notepad" -Force
|
||||
```
|
||||
|
||||
## Service
|
||||
|
||||
Windows **services** are background programs that run independently of
|
||||
user logins and provide core system or application functionality.
|
||||
They are managed by the Service Control Manager and can be started,
|
||||
stopped, paused, or configured to run automatically,
|
||||
making them essential for system stability, networking,
|
||||
security, and ongoing operations.
|
||||
|
||||
### Get-Service
|
||||
|
||||
For listing every services
|
||||
|
||||
```powershell
|
||||
Get-Service -Name "Print Spooler"
|
||||
|
||||
Get-Service | Format-Table -Property Statys, DisplayName
|
||||
|
||||
Get-Service | Where-Object {$_.Status -eq "Stopped"}
|
||||
Get-Service | Where-Object {$_.Status -eq "Running"}
|
||||
```
|
||||
|
||||
### Stop-Service
|
||||
|
||||
```powershell
|
||||
Stop-Service -Name "Print Spooler"
|
||||
```
|
||||
|
||||
### Start-Service
|
||||
|
||||
```powershell
|
||||
Start-Service -Name "Print Spooler"
|
||||
```
|
||||
|
||||
### Restart-Service
|
||||
|
||||
```powershell
|
||||
Restart-Service -Name "Print Spooler"
|
||||
```
|
||||
|
||||
## Volumes
|
||||
|
||||
Windows **volumes** are logical storage units used to organize and
|
||||
access data on physical disks.
|
||||
They are formatted with a file system, assigned a drive letter or mount point,
|
||||
and managed by the operating system to provide structured,
|
||||
persistent storage for files and applications.
|
||||
|
||||
|
||||
### Get-Volume
|
||||
|
||||
|
||||
```powershell
|
||||
Get-Volume
|
||||
|
||||
Get-Volume -DriveLetter C | Format-List
|
||||
|
||||
$CDrive = Get-Volume -DriveLetter C
|
||||
|
||||
#To format Size Remaining output to GB
|
||||
$CDrive.SizeRemaining/1GB
|
||||
```
|
||||
|
||||
## Recycle Bin
|
||||
|
||||
The Windows **Recycle Bin** is a special system folder that temporarily stores
|
||||
deleted files and folders.
|
||||
It allows users to restore items if they were removed accidentally,
|
||||
acting as a safety mechanism before permanent deletion.
|
||||
|
||||
## Clear-RecycleBin
|
||||
|
||||
```powershell
|
||||
Clear-RecycleBin
|
||||
|
||||
Clear-RecycleBin -Drive C -Force
|
||||
```
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user