Re: PowerShell script to Get-RemotePrograms and export to .CSV for multiple AD computer object not working for bulk?
Posted: Thu Jan 10, 2019 9:09 pm
It cannot retrieve the value of $OUList?jvierra wrote: ↑Thu Jan 10, 2019 9:04 pm This would be easier to work with and debug.Code: Select all
$OUList = @( 'OU=Workstations,OU=Testing,DC=Domain,DC=com', 'OU=Desktops,DC=Domain,DC=com', 'OU=Laptops,DC=Domain,DC=com' ) $computers = ForEach-Object{ Get-ADComputer -Properties Name -Filter { Enabled -eq $True -and OperatingSystem -like "*Windows*" } -SearchBase $_ | Where-Object { Test-Connection $_.Name -Count 1 -Quiet } } $computers | ForEach-Object { Write-Host "Checking $($_.Name) ..." Get-RemoteProgram -ComputerName $_.Name -IncludeProgram '*Office*' } | Sort-Object ProgramName | Export-Csv -Path C:\Logs\Office.txt -NoTypeInformation
Hence the error:
Get-ADComputer : Cannot validate argument on parameter 'SearchBase'. The argument is null. Provide a valid value for the argument, and then try running the command again.At line:249 char:118
+ ... d -eq $True -and OperatingSystem -like "*Windows*" } -SearchBase $_ |
+ ~~
+ CategoryInfo : InvalidData: (:) [Get-ADComputer], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.ActiveDirectory.Management.Commands.GetADComputer