alienvoice
asked on
Powershell script - IP of local PC
I am attempt to write a powershell script that will extract the IP address of a local PC it is being run on.
So far I have written this:
$strComputerID = "."
$Ipinfo = Get-WmiObject -Class Win32_NetworkAdapterConfig uration -Filter "IPEnabled=TRUE and DHCPEnabled=TRUE" -comp $strComputerID
# get-member -inputobject $Ipinfo ----------- I am using this line to identify the type of info available
get-member -name IPAddress $IPinfo
What am I missing. I understand $Ipinfo is an array, but I can't extract individual information from it like IPAddress or DefaultIPGateway and so on.
Ideas?
So far I have written this:
$strComputerID = "."
$Ipinfo = Get-WmiObject -Class Win32_NetworkAdapterConfig
# get-member -inputobject $Ipinfo ----------- I am using this line to identify the type of info available
get-member -name IPAddress $IPinfo
What am I missing. I understand $Ipinfo is an array, but I can't extract individual information from it like IPAddress or DefaultIPGateway and so on.
Ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
$strComputerID = "."
$Ipinfo = Get-WmiObject -Class Win32_NetworkAdapterConfig
$IPinfo.IPAddress
Reason behind this is, it will allow me to modify the input if needed at a later date and it will run a check to verify the IP is DHCP enabled, (which is important for the situation it will be used in).