Info
Powershell Powershell, bring more helpful and memorable command which can reuse on next time π π π
Extract zip
file
You can use Expand-Archive
for extract ZIP
file, for example
The command will extract the translators-main.zip
file in current folder
Restart wsl
to claim memory
You can use --shutdown
flag to restart the wsl
machine or you can setup .wslconfig
on PATH $env:USERPROFILE
, read more: Advanced settings configuration in WSL. More about scenarios you can read in StackOverFlow - How can I reduce the consumption of the vmmem
process?
Note
Shutdown to reclaim resource
Info
Set new configuration
Common wsl
command
Official documentation: Basic commands for WSL and Remove WSL
Invoke-WebRequest
alias of wget
& curl
Reference: StackExchange - PowerShell equivalent of curl - Invoke-WebRequest
You can use curl
alias of command Invoke-WebRequest
Because the powershell output work really special, object-type
I think so. Thus, you can use select-object
to get the what actually you want, such as Content
For expand the raw string, you can use -ExpandProperty
flag like example
Go to the administrator
Use can use start-process
with -verb
flag on runas
mode to change your shell to Administrator role
But on the currently, Windows just ready to release sudo
command for help you doing super user command can do without open terminal with Administrator. Read more at: Sudo for Windows
Reload $PROFILE
When you want to reload or apply plugin which you put on your $PROFILE
, you can make it straightway with command
Enable Hyper-V service
Info
Information about Issue StackOverFlow - How to disable Hyper-V in command line?]
Command Prompt (CMD)
In anΒ elevatedΒ Command Prompt write this
Restart to take effect or you can do it with command
Powershell
Run in administrator before execute this
To disable
And restart or use command
Get execute policy
Try to list all permission of powershell
of currently user
View all permission of user
Use whoami
command to view
Set and change permission of file
Documentation: How to change file permissions on Windows via powershell / cmd?
To change and set permission of file or folder in powershell, you can use Get-AclΒ andΒ Set-Acl
Or we can use icacls to handle with same situation. Read more tutorial and explanation
If you want to create 400
permission for your ssh-key or readonly file for currently user, you can use
Create new file
Explore more about methodology: How to Use PowerShell to Create a File?
There is more of stuff way for create new file, and one of popular is use New-Item
In another, you can use Out-File
or Set-Content
Find the string in documentation
If you want to find the same idea of grep
in Powershell, you can try with. Read more at PowerShell equivalent to grep -f
Command can be used
Get-Help
Use theΒ Get-HelpΒ cmdlet to display the syntax of any PowerShell cmdlet
Get-Service
Helpful to know what services are installed on the system
Get-EventLog
Actually use PowerShell to parse your machineβs event logs using the Get-EventLog cmdlet
Get-Process
Getting a list of available services, itβs often useful to be able to get a quick list of all the currently running processes
Format-Table
Β Used to format any output as a table
Format-List
Output properties as a list, each on a new line
Where-Object
Where-ObjectΒ is one of the most important cmdlets to know, as it enables you to take a dataset and pass it further down your pipeline for filtering
For-Each
The ForEach-Object cmdlet performs an operation against every item in a specified group of input objects.
Compare-Object
Useful to be able to compare two objects directly
Select-Object
The Select-Object cmdlet selects the specified properties of a single object or group of objects.
Get-Member
One quality that makes PowerShell so versatile is that almost everything in PowerShell is an object consisting of a name, methods, and properties
Get-ChildItem
Β Get-ChildItem
Β returns all the items in one or more containers
Out-GridView
Β PowerShell output returns to the console window. However, if you need to interact with the output, you can use theΒ Out-GridView
Β cmdlet