techgenious
asked on
Powershell script to inventory all servers that have IPv6 enabled/disabled
I want to inventory all computers in our AD environment and find out if IPv6 is enabled or not enabled.
I've attached a script and am stuck on disabled.
Can someone add to my script so the column 'disabled' outputs true/false.
Please keep in mind I'm trying to do it with a one-line command as I am learning PS.
thanks
This DOES NOT work (at least not completely), but it's where I was headed with calculated properties. Just leaving it here to see if it sparks an idea for anyone else (and to show how ridiculous one-liners can get).
Import-Module ActiveDirectory
Get-ADComputer -filter * | Select Name,@{ name = "IPv6Address"; expression = { (gwmi Win32_NetworkAdapterConfiguration -computername "$($_.name)" | Where {$_.IPEnabled -eq $True} ).IPAddress | Where {$_ -match ":"} }}, @{ name = "Disabled"; expression = { (gwmi Win32_NetworkAdapterConfiguration -computername "$($_.name)" | Where {$_.IPEnabled -eq $True}).Ipaddress | % {($_ -notmatch ":")} } }
ASKER
Thanks but being a beginner, let me try your script and see what output I get.
Will it tell me if IPv6 is enabled?
thx
Will it tell me if IPv6 is enabled?
thx
I've never seen a property that you can query directly to determine whether IPv6 is enabled. The best I know of is to look at a machine's IP addresses, and if one is an IPv6 address, infer that it is enabled. Test it in your environment with hosts that you know are configured one way or another and see how it works for you.
You will see this when it can't connect via WMI to the remote machine(s). What OSes are you running? Does the firewall configuration on all the remote machines allow inbound WMI traffic?
ASKER
Windows Server 2008 R2, the windows firewall is disabled on all machines.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks so much for this script:
When I run the script I get this:
Write-Progress : Cannot validate argument on parameter 'PercentComplete'. The 933 argument is greater than the maximum allowed range of 100.
Supply an argument that is less than or equal to 100 and then try the command again.
At C:\IPV6.ps1:7 char:183
+ ... ercentComplete (($i/$computers.count) * 100)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~
+ CategoryInfo : InvalidData: (:) [Write-Progress], ParameterBindingValidation Exception
+ FullyQualifiedErrorId : ParameterArgumentValidatio nError,Mic rosoft.Pow erShell.Co mmands.Wri teProgress Command
Write-Progress : Cannot validate argument on parameter 'PercentComplete'. The 933 argument is greater than the maximum allowed range of 100.
Supply an argument that is less than or equal to 100 and then try the command again.
At C:\IPV6.ps1:10 char:185
+ ... ercentComplete (($i/$computers.count) * 100)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~
+ CategoryInfo : InvalidData: (:) [Write-Progress], ParameterBindingValidation Exception
+ FullyQualifiedErrorId : ParameterArgumentValidatio nError,Mic rosoft.Pow erShell.Co mmands.Wri teProgress Command
Write-Progress : Cannot validate argument on parameter 'PercentComplete'. The 967 argument is greater than the maximum allowed range of 100.
Supply an argument that is less than or equal to 100 and then try the command again.
At C:\IPV6.ps1:7 char:183
+ ... ercentComplete (($i/$computers.count) * 100)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~
+ CategoryInfo : InvalidData: (:) [Write-Progress], ParameterBindingValidation Exception
+ FullyQualifiedErrorId : ParameterArgumentValidatio nError,Mic rosoft.Pow erShell.Co mmands.Wri teProgress Command
Write-Progress : Cannot validate argument on parameter 'PercentComplete'. The 1000 argument is greater than the maximum allowed range of 100.
Supply an argument that is less than or equal to 100 and then try the command again.
At C:\IPV6.ps1:7 char:183
+ ... ercentComplete (($i/$computers.count) * 100)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~
+ CategoryInfo : InvalidData: (:) [Write-Progress], ParameterBindingValidation Exception
+ FullyQualifiedErrorId : ParameterArgumentValidatio nError,Mic rosoft.Pow erShell.Co mmands.Wri teProgress Command
Write-Progress : Cannot validate argument on parameter 'PercentComplete'. The 1000 argument is greater than the maximum allowed range of 100.
Supply an argument that is less than or equal to 100 and then try the command again.
At C:\IPV6.ps1:10 char:185
+ ... ercentComplete (($i/$computers.count) * 100)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~
+ CategoryInfo : InvalidData: (:) [Write-Progress], ParameterBindingValidation Exception
+ FullyQualifiedErrorId : ParameterArgumentValidatio nError,Mic rosoft.Pow erShell.Co mmands.Wri teProgress Command
When I run the script I get this:
Write-Progress : Cannot validate argument on parameter 'PercentComplete'. The 933 argument is greater than the maximum allowed range of 100.
Supply an argument that is less than or equal to 100 and then try the command again.
At C:\IPV6.ps1:7 char:183
+ ... ercentComplete (($i/$computers.count) * 100)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Write-Progress], ParameterBindingValidation
+ FullyQualifiedErrorId : ParameterArgumentValidatio
Write-Progress : Cannot validate argument on parameter 'PercentComplete'. The 933 argument is greater than the maximum allowed range of 100.
Supply an argument that is less than or equal to 100 and then try the command again.
At C:\IPV6.ps1:10 char:185
+ ... ercentComplete (($i/$computers.count) * 100)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Write-Progress], ParameterBindingValidation
+ FullyQualifiedErrorId : ParameterArgumentValidatio
Write-Progress : Cannot validate argument on parameter 'PercentComplete'. The 967 argument is greater than the maximum allowed range of 100.
Supply an argument that is less than or equal to 100 and then try the command again.
At C:\IPV6.ps1:7 char:183
+ ... ercentComplete (($i/$computers.count) * 100)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Write-Progress], ParameterBindingValidation
+ FullyQualifiedErrorId : ParameterArgumentValidatio
Write-Progress : Cannot validate argument on parameter 'PercentComplete'. The 1000 argument is greater than the maximum allowed range of 100.
Supply an argument that is less than or equal to 100 and then try the command again.
At C:\IPV6.ps1:7 char:183
+ ... ercentComplete (($i/$computers.count) * 100)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Write-Progress], ParameterBindingValidation
+ FullyQualifiedErrorId : ParameterArgumentValidatio
Write-Progress : Cannot validate argument on parameter 'PercentComplete'. The 1000 argument is greater than the maximum allowed range of 100.
Supply an argument that is less than or equal to 100 and then try the command again.
At C:\IPV6.ps1:10 char:185
+ ... ercentComplete (($i/$computers.count) * 100)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Write-Progress], ParameterBindingValidation
+ FullyQualifiedErrorId : ParameterArgumentValidatio
Only way that could happen is if $i is greater than the number of computer accounts found by the Get-ADComputers cmdlet. Add the statement $i = 0 anywhere before line 4 to make sure each time you run the script the count gets reset.
ASKER
I really appreciate this I've learned alot being a complete beginner.
One other question, when it checks disable IPv6 I noticed the components which I need to see if they are enabled or disabled, which is components of IPV6:
-- Tunnel Adapter isatap
-- Tunnel Adapter 6to4 adapter
-- Tunnel adapter Teredo Tunneling Pseudo-Interface
How can I add that into the script to see if they are enabled/disabled?
I need to inventory those components.
many thanks
One other question, when it checks disable IPv6 I noticed the components which I need to see if they are enabled or disabled, which is components of IPV6:
-- Tunnel Adapter isatap
-- Tunnel Adapter 6to4 adapter
-- Tunnel adapter Teredo Tunneling Pseudo-Interface
How can I add that into the script to see if they are enabled/disabled?
I need to inventory those components.
many thanks
Sorry, I'm not really sure what you're asking. I'm not too familiar with the components you mentioned or how they're supposed to factor into the question here. To my knowledge the components are present on a machine whether IPv6 is configured or not. Perhaps if you could describe the situation better I could give you a better answer.
The closest I've seen for this is to use WMI to check what IP addresses are in use and examine them to see if they contain ":". Possibly could make this a calculated property, but I haven't been able to pull it all together.
Honestly do not know if you can rely on the IPv6Address property from Get-ADComputers since it can return info even when IPv6 isn't enabled.
This the closest I've come up with, using a custom object:
Open in new window