Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Powershell to Access Database, can't get IPaddress

$
0
0

I am making an inventory PS script with access and everything is going well until I get to the network portion of my code.  For some reason that I must be overlooking or just do not know I cant get the fields to populate in the database.  Some will like the network card and device_name. But fields like IPaddress, subnetmask, default gateway, etc... will not return any value, when I check the database its blank.  I am confused and need some direction, any help is appreciated!  Thank you!

Here is a snippet of my network function:

# ============================================================================================== # Function Name 'Update-Network' - Gathers Network info using WMI # ============================================================================================== Function Update-Network {"Updating Network Info" foreach ($strComputer in $colComputers){ $NetItems = gwmi Win32_NetworkAdapterConfiguration -Comp $StrComputer | `

where{$_.IPEnabled -eq "True"} } foreach ($objItem in $NetItems){ $RecordSet.AddNew() $RecordSet.Fields.Item("Device_Name") = $StrComputer $RecordSet.Fields.Item("Network_Card") = $objItem.Caption+" (enabled)" $RecordSet.Fields.Item("DHCP_Enabled") = $objItem.DHCPEnabled $RecordSet.Fields.Item("IP_Address") = $objItem.IPAddress $RecordSet.Fields.Item("Subnet_Mask") = $objItem.IPSubnet $RecordSet.Fields.Item("Default_Gateway") = $objItem.DefaultIPGateway $RecordSet.Fields.Item("DNS_Servers") = $objItem.DNSServerSearchOrder $RecordSet.Fields.Item("DNS_Reg") = $objItem.FullDNSRegistrationEnabled $RecordSet.Fields.Item("Primary_WINS") = $objItem.WINSPrimaryServer $RecordSet.Fields.Item("Secondary_WINS") = $objItem.WINSSecondaryServer $RecordSet.Fields.Item("WINS_Lookup") = $objItem.WINSEnableLMHostsLookup $RecordSet.Update() } } #End Update-Network





Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>