Guys.
Looking for some assistance. Can anyone explain where i am going wrong? I am sure the get-qadcomputer part is working as it returns each workstation in the OU. However the $DefaultGateway code is like its not picking up the machine names?
Any ideas?
The code below =====
Get-QADComputer -SearchRoot "OU DN HERE" | ForEach-Object {$_.Name}
$DefaultGateway = (Get-wmiObject Win32_networkAdapterConfiguration -ComputerName $_.Name | ?{$_.IPEnabled}).DefaultIPGateway
$DefaultGateway
When i run the code i get the message below
Get-WmiObject : Cannot validate argument on parameter 'ComputerName'. The argument is null or empty. Supply an argument that
is not null or empty and then try the command again.
At C:\Users\cjw-admin\AppData\Local\Temp\2\f2d9aeaa-8ce3-42b8-9eae-196b98df6dfb.ps1:20 char:81
+ $DefaultGateway = (Get-wmiObject Win32_networkAdapterConfiguration -ComputerName <<<< $_.Name | ?{$_.IPEnabled}).DefaultIP
Gateway
+ CategoryInfo : InvalidData: (:) [Get-WmiObject], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.GetWmiObjectCommand