PowerShell Commands
PowerShell Commands
Example:
Invalid command or path
Example:
list directory c:\ -force
Example:
get-help ls
Example:
get-help ls -full
Change directory
cd [relative or absolute path of directory]
Examples:
cd C:\users\agustin\documents
cd documents
cd ..\documents
cd ..
Example:
mkdir my_super_directory
Command History
history
You can also use Ctrl + R and start typing a previously used command.
Clean the screen
clear
1
Copy files and directories
cp [file] [destination location]
Example:
copy my_file c:\users\Augustin\my_folder
cp *.jpg c:\users\agustin\images
Examples:
move my_yellow_file to my_new_green_file
Examples
remove archivo.txt
rm .\directory_to_delete
Examples:
cat file.txt
Example:
more long_file.txt
Examples:
select-string vacation farm_file.txt
select-string vacation *.txt
2
Example:
ls "C:\Program Files\" -recurse -filter *.exe
Passwords
Change a user's password
net user [user] ["password"]
Example:
net user agustin "123456"
Example:
net user agustin /logonpasswordchge:yes
Add a user with a password and force them to change it at the next login.
net user [user] [password] /add /logonpasswordchge:yes
Remove a user.
net user [user] /del
3
File permissions
Check the permissions of a file or directory
icacls [file or directory]
Modify permissions
icacls [file or directory] /grant '[user]:[permissions]'
Examples:
Modify a user permission:
icacls 'D:\Test\' /grant 'Everyone:(OI)(CI)(R)'
Compressed files
Compress a file
compress-archive -path [file or folder] [compressed file name]
Example:
compress-archive -path c:\users\my_folder backup.zip
Package dependencies
Locate a package
find-package [package name] -includedependencies
Example:
find-package sysinternals -includedependencies
Example:
register-packagesource -name chocolatey -providername chocolatey -location
http://chocolatey.org/api/v2
Install a package
install-package -name [package name]
Example
install-package -name sysinternals
Verify packages
get-package [package name]
Uninstall packages
uninstall-package -name [package name]
4
select disk [disk number]
Create partition.
create primary partition
Select partition.
select partition [partition number]
Files
Symbolic links
Create a symbolic link to a file.
If the name of the source file is changed, the link will remain
rotor.
mklink [link name] [source file]
Example:
mklink symlink file.txt
Physical ties
Create a physical link to a file.
If the source file name is changed, the link will remain
working.
mklink /h [link name] [source file]
Example:
mklink /h hardlink_file arhivo.txt
Processes
List the processes
This command is for PowerShell only.
get-process
Delete a process
taskkill /pid [process number]
Signals
signals intelligence
To interrupt a process, it is necessary to send the SigInt signal by pressing the keys Ctrl + C.
Resource monitoring
Show the top three processes that consume the most resources
of the microprocessor.
get-process | sort cpu -descending | select -first 3 -property id, processname, cpu
5
Management services
Get-Service command
Check the status of a service.
get-service [service]