PoshC2_Python/Modules/Get-IPConfig.ps1

32 lines
1.3 KiB
PowerShell
Raw Permalink Normal View History

2018-11-18 19:05:08 +00:00
# https://gallery.technet.microsoft.com/scriptcenter/IPConfig-all-cfe08dc0
function Get-Ipconfig {
2018-12-07 14:25:22 +00:00
$array= @()
2018-11-18 19:05:08 +00:00
2018-12-07 14:25:22 +00:00
$wmi=Get-WmiObject win32_ComputerSystem
2018-11-18 19:05:08 +00:00
2018-12-07 14:25:22 +00:00
$obj=New-Object PSObject
2018-11-18 19:05:08 +00:00
2018-12-07 14:25:22 +00:00
$obj |Add-Member -MemberType NoteProperty -Name "ComputerName" $wmi.Name
2018-11-18 19:05:08 +00:00
2018-12-07 14:25:22 +00:00
# Finding the Network Adapter and MAC Address, DHCP Server
2018-11-18 19:05:08 +00:00
2018-12-07 14:25:22 +00:00
$wmi=Get-WmiObject win32_networkadapterconfiguration | where {$_.Ipenabled -Match "True"}
$obj |Add-Member -MemberType NoteProperty -Name "IPAddress" $wmi.IPAddress
$obj |Add-Member -MemberType NoteProperty -Name "NetworkAdapter" $wmi.description
$obj |Add-Member -MemberType NoteProperty -Name "MACAddress" $wmi.macaddress
$obj |Add-Member -MemberType NoteProperty -Name "DefaultGateway" $wmi.DefaultIPGateway
$obj |Add-Member -MemberType NoteProperty -Name "DHCPServer" $wmi.DHCPServer
$obj |Add-Member -MemberType NoteProperty -Name "DHCPEnabled" $wmi.DHCPEnabled
$obj |Add-Member -MemberType NoteProperty -Name "SubnetMask" $wmi.IPSubnet
$obj |Add-Member -MemberType NoteProperty -Name "DNSServer" $wmi.DnsServerSearchOrder
$obj |Add-Member -MemberType NoteProperty -Name "WinsPrimaryServer" $wmi.WinsPrimaryServer
$obj |Add-Member -MemberType NoteProperty -Name "WinsSecondaryServer" $wmi.WinsSecondaryServer
$array +=$obj
2018-11-18 19:05:08 +00:00
echo "[+] IPConfig "
echo $array
}