Using Powershell for Discovery Troubleshooting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2024 09:39 AM
Here is a list of commands you can use to troubleshoot MID server to Target discovery when it comes to connectvity.
1. Ping Test
While ping is simple yet powerful command. You can use powershell to ping multiple servers or target devices at same time from the MID server host.
Option A: Computer Names in the command line
Test-Connection -ComputerName 192.168.0.2,192.168.0.1,examplehost -Count 1
Option B: Ping computer details from a text file
Test-Connection -ComputerName (Get-Content C:\Data\Computers.txt) -Count 1
Option C: Subnet Ping (works in powershell 7 or Higher
1 2 3 4 5 6 | # PowerShell 7 $subnet = '192.168.0.' $ips = 1..254 $ips | ForEach-Object -Parallel { Test-Connection -ComputerName $using:subnet$_ -Count 1 } |
2. Port Connectivity Check
Depending on the target port for discovery you can do the port connectivity test using the same command, for example Port 22 for linux/unix devices or 135 for windows devices
Test-NetConnection -ComputerName 192.168.0.1 -Port 135 -Count 1
Example:
Test-NetConnection -ComputerName 192.168.0.2 -Port 135 -Count 1
RemoteAddress : 192.168.0.2
RemotePort : 135
InterfaceAlias : Wi-Fi
SourceAddress : 192.168.0.1
TcpTestSucceeded : True
As shown in the ping test, you can do this for multiple computers at a time using a text file or command line.
3. Credential Check from MID server to Target Host
gwmi win32_operatingsystem -computer 192.168.0.2 -credential 'LOCALDOMAIN\mid'
#discovery #cmdb #servicenow
Best regards
Surya Prakash Garg
Connect me on Linked In
https://www.linkedin.com/in/spgarg/
- 562 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2024 02:20 PM
very nice article