Chapter 1
Activities
- You can use
ADD_FILE_CONTEXT_MENU_RUNPOWERSHELL
, like this:msiexec.exe /package c:\Users\WDAGUtilityAccount\Downloads\PowerShell-7.2.1-win-x64.msi /quiet REGISTER_MANIFEST=1 USE_MU=1 ENABLE_MU=1 ADD_FILE_CONTEXT_MENU_RUNPOWERSHELL=1
- By using
kill()
. Charming, right?CloseMainWindow(
)
might work for a graphical process, andClose(
)
will ask politely, butkill(
)
should do it. Note that sometimes it won’t, for instance, if the process you are trying to kill is running with higher privileges than the account you are running PowerShell with.You can use it like this. Here’s my list of
pwsh
processes:
Figure A.1 – Some PowerShell processes
Let’s get rid of 4052
:
Figure A.2 – Fewer PowerShell processes
Exercises
- Input
Get-Random
. - Input
Get-Random -Minimum 1 -
Maximum 11
. - Input
Get-ChildItem -
Path <folderpath>
. - Input
Get-ChildItem -Path...