Posts

Showing posts with the label Network

Scan your network with PowerShell

Image
 I recently came across this cool script on LinkedIn that let you scan your network for devices with open ports. This is normally something that requires 3. party tool software that you might not be keen to install in your server. With this tool you can scan your network with a PowerShell script. How to run this Script Copy the script below to PowerShell ISE or save it as a script. Change the $localIP variable to your own IP address and your are ready to go. Clear # if you dont specify IP Address here, the script will get automatically address from network card with DHCP attribute $localIP = '192.168.1.10' # Obtain the IP address of the local machine if($localIP -eq '') {      $localIP = (Get-NetIPAddress | Where-Object { $_.AddressFamily -eq 'IPv4' -and $_.PrefixOrigin -eq 'Dhcp' }).IPAddress } # List of common ports to be scanned $portsToScan = @(20,21,22,23,25,53,80,110,123,143,161,443,445,993,995,3306,3389,5900,8080) # Extract the first three bytes ...

Use PowerShell to Discover Network Switch and port number

Image
 If you are working with Networks, that I am, you can sometimes have trouble to find out what switch port a computer is connected to. That can be because of bad marking of a network socket or because a cable simply just disappear into a wall and you are not able to follow it all the way to the rack cabinet. Let me show you an easy way to discover not just port number, but also name of the switch and VLAN for the connection. You will have to run the script below as an administrator, in order for it to work. Script: # Is Module installed - install if not available. if (Get-Module -ListAvailable -Name PSDiscoveryProtocol) {   Import-Module PSDiscoveryProtocol } else {   Install-Module -Name PSDiscoveryProtocol -Force   Import-Module PSDiscoveryProtocol } $Packet = Invoke-DiscoveryProtocolCapture -Type LLDP Get-DiscoveryProtocolData -Packet $Packet Be aware that you will need to have a manage lager 3 switch,  for the LLDP protocol,  to collect these information...

Popular posts from this blog

Use PowerShell to Discover Network Switch and port number

How to get Public IP Using PowerShell

Use ChatGPT to write PowerShell Scripts