Currently I am doing this in my PowerShell script:
$ServiceTagsPath=$filePath + '\DellAPIWarrantyLIST.csv'
write-host 'get all computer names from Active Directory...for Windows 7...'
Get-ADComputer -properties * -filter {(operatingsystem -like "*Windows 7*")} |
Where-Object {$_.name -like "*-*"} |
Where-Object {$_.name -NotLike "V7-*"} |
Where-Object {$_.name -NotLike "*-NONE"} |
Where-Object {$_.name -NotLike "*-ONCALL"} |
Where-Object {$_.name -NotLike "*-BLACKBAUD"} |
Where-Object {$_.name -NotLike "SC-WIN7-1"} |
Where-Object {$_.name -NotLike "UT-SWCLIENT-01"} |
Select-Object -property Name , LastLogonDate | export-csv $ServiceTagsPath -NoTypeInformation -Force
$computers= Get-ADComputer -properties * -filter {(operatingsystem -like "*Windows 7*")} |
Where-Object {$_.name -like "*-*"} |
Where-Object {$_.name -NotLike "V7-*"} |
Where-Object {$_.name -NotLike "*-NONE"} |
Where-Object {$_.name -NotLike "*-ONCALL"} |
Where-Object {$_.name -NotLike "*-BLACKBAUD"} |
Where-Object {$_.name -NotLike "SC-WIN7-1"} |
Where-Object {$_.name -NotLike "UT-SWCLIENT-01"} |
Select-Object -Expand Name
Write-Host $computers.Length + ' computers found in Active Directory...'
The first one gives me a csv file with 2 columns, and about 1500 records, the second one gives me an array variable which I use in web-service calls to an API...
But would it be possible to do both in one step? is there a way to do both of these in one so as well as having a csv file with 2 columns, showing the Computer Name and LastLogondate, I'd have an array with just the computer names?