Useful powershell commands (and cmd) Flashcards

must learn these!

1
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Show system information

A

systeminfo

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

List all running processes

A

tasklist

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Kill a process by name

A

taskkill /IM <process_name> /F</process_name>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Kill a process by PID

A

taskkill /PID <pid> /F</pid>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Clear the command prompt screen

A

cls

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

List files in a directory

A

dir

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Change directory

A

cd <directory></directory>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Create a new directory

A

mkdir <directory></directory>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Remove a directory

A

rmdir /S /Q <directory></directory>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Copy a file

A

copy <source></source> <destination></destination>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Move or rename a file

A

move <source></source> <destination></destination>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Delete a file

A

del <file_name></file_name>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Show IP configuration

A

ipconfig /all

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Release IP address

A

ipconfig /release

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Renew IP address

A

ipconfig /renew

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Flush DNS cache

A

ipconfig /flushdns

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Display active network connections

A

netstat -an

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Display listening ports

A

netstat -an | find “LISTEN”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Ping a host

A

ping <hostname_or_ip></hostname_or_ip>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Trace route to a host

A

tracert <hostname_or_ip></hostname_or_ip>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Check open ports on a remote host

A

telnet <hostname_or_ip> <port></port></hostname_or_ip>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Shutdown the computer

A

shutdown /s /t 0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Restart the computer

A

shutdown /r /t 0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

Log off current user

A

shutdown /l

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

Check disk usage

A

chkdsk

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

Check and repair disk errors

A

chkdsk /f

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

Show available disk space

A

wmic logicaldisk get size,freespace,caption

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

List installed programs

A

wmic product get name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

Find specific installed program

A

wmic product where “name like ‘%<program_name>%'" get name</program_name>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

Create a new user

A

net user <username> <password> /add</password></username>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

Delete a user

A

net user <username> /delete</username>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

Add user to a group

A

net localgroup <groupname> <username> /add</username></groupname>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

Remove user from a group

A

net localgroup <groupname> <username> /delete</username></groupname>

35
Q

List all users

36
Q

List all groups

A

net localgroup

37
Q

Enable remote desktop

A

reg add “HKLM\System\CurrentControlSet\Control\Terminal Server” /v fDenyTSConnections /t REG_DWORD /d 0 /f

38
Q

Disable remote desktop

A

reg add “HKLM\System\CurrentControlSet\Control\Terminal Server” /v fDenyTSConnections /t REG_DWORD /d 1 /f

39
Q

Start a service

A

net start <service_name></service_name>

40
Q

Stop a service

A

net stop <service_name></service_name>

41
Q

List all services

42
Q

Check service status

A

sc query <service_name></service_name>

43
Q

Enable a service

A

sc config <service_name> start= auto</service_name>

44
Q

Disable a service

A

sc config <service_name> start= disabled</service_name>

45
Q

List all environment variables

46
Q

Set an environment variable

A

setx <variable_name> <value> /M</value></variable_name>

47
Q

Delete an environment variable

A

setx <variable_name> "" /M</variable_name>

48
Q

Get current date

A

echo %DATE%

49
Q

Get current time

A

echo %TIME%

50
Q

Find a string in a file

A

findstr “pattern” <file_name></file_name>

51
Q

Create a compressed zip file

A

Compress-Archive -Path <file_name> -DestinationPath <output.zip></output.zip></file_name>

52
Q

Extract a zip file

A

Expand-Archive -Path <input.zip> -DestinationPath <directory></directory></input.zip>

53
Q

Get running processes (PowerShell)

A

Get-Process

54
Q

Kill a process (PowerShell)

A

Stop-Process -Name <process_name> -Force</process_name>

55
Q

Get system uptime (PowerShell)

A

(get-date) - (gcim Win32_OperatingSystem).LastBootUpTime

56
Q

Get system information (PowerShell)

A

Get-ComputerInfo

57
Q

List installed software (PowerShell)

A

Get-WmiObject -Query “SELECT * FROM Win32_Product”

58
Q

Check Windows version (PowerShell)

59
Q

Restart a service (PowerShell)

A

Restart-Service -Name <service_name></service_name>

60
Q

List network adapters (PowerShell)

A

Get-NetAdapter

61
Q

Disable network adapter (PowerShell)

A

Disable-NetAdapter -Name “<adapter_name>"</adapter_name>

62
Q

Enable network adapter (PowerShell)

A

Enable-NetAdapter -Name “<adapter_name>"</adapter_name>

63
Q

Get IP configuration (PowerShell)

A

Get-NetIPConfiguration

64
Q

Get firewall rules (PowerShell)

A

Get-NetFirewallRule

65
Q

Enable firewall rule (PowerShell)

A

Enable-NetFirewallRule -DisplayName “<rule_name>"</rule_name>

66
Q

Disable firewall rule (PowerShell)

A

Disable-NetFirewallRule -DisplayName “<rule_name>"</rule_name>

67
Q

Check open ports (PowerShell)

A

Test-NetConnection -ComputerName <hostname_or_ip> -Port <port></port></hostname_or_ip>

68
Q

Ping a host (PowerShell)

A

Test-Connection -ComputerName <hostname_or_ip></hostname_or_ip>

69
Q

List active TCP connections (PowerShell)

A

Get-NetTCPConnection

70
Q

Restart computer (PowerShell)

A

Restart-Computer -Force

71
Q

Shutdown computer (PowerShell)

A

Stop-Computer -Force

72
Q

Get available storage (PowerShell)

A

Get-PSDrive -PSProvider FileSystem

73
Q

Check disk health (PowerShell)

A

Get-PhysicalDisk

74
Q

Format a disk (PowerShell)

A

Format-Volume -DriveLetter <drive_letter> -FileSystem NTFS -NewFileSystemLabel "NewLabel"</drive_letter>

75
Q

List running services (PowerShell)

A

Get-Service

76
Q

Start a service (PowerShell)

A

Start-Service -Name <service_name></service_name>

77
Q

Stop a service (PowerShell)

A

Stop-Service -Name <service_name></service_name>

78
Q

Set execution policy (PowerShell)

A

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

79
Q

Run a script as administrator (PowerShell)

A

Start-Process PowerShell -Verb RunAs -ArgumentList “-File <script.ps1>"</script.ps1>

80
Q

List scheduled tasks (PowerShell)

A

Get-ScheduledTask

81
Q

Get system logs (PowerShell)

A

Get-EventLog -LogName System -Newest 10

82
Q

Export event logs to a file (PowerShell)

A

wevtutil epl System C:\Logs\system.evtx /ow:true

83
Q

Get information about an AD Domain

A

Get-ADDomain

84
Q

See what groups you’re in

A

whoami /groups