This particular code block is used to loop through a set of object. To iterate through the ports in the file, we use the following The simplest next step is iterate through all the ports in the file to see if the ports are listening. Again, we store this output in the variables. On the next line, we want to read a list of ports from the file. The convention to create variables is used as: We are then saving the output of this cmdlet into a variable. We do this using the Get-NetTCPConnection cmdlet. On the first line, we want to get a list of all the ports on the system that are listening. $text_port = Get-Content -Path C:\Users\Administrator\Desktop\ports.txt $system_ports = Get-NetTCPConnection -State Listen Open the listening-ports.ps1 script on the Desktop using Powershell ISE. Given a list of port numbers, we want to use this list to see if the local port is listening. To show an example of this script, let’s use a particular scenario. Now that we have run powershell commands, let’s actually try write and run a script to do more complex and powerful actions.įor this ask, we’ll be using PowerShell ISE(which is the Powershell Text Editor). NT SERVICE\TrustedInstaller Basic Scripting Challenge Here’s an example of checking the stopped processes:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |