Monday, November 4, 2013

powershell filtering two arrays and using text and variables

Comparing two list/Array/ and work from that...
#
# Active FPS list
#

$OUName= 'OU=File and Print,OU=Servers,OU=MOE Servers,DC=Kool,DC=Kids'
$TheComputers = Get-ADComputer -filter * -searchbase $OUName

#
# Exclude File and Print Server
# ,,
#
$ExcludedFPs="PANDA"
Write-host Excluded File and Print Server - $ExcludedFPs

#Filter the List of objects
$AcutalFPStargets=Compare-Object $TheComputers.name $ExcludedFPs | where {$_.sideindicator -eq "<="} | % {$_.inputobject}

#now... do stuff 
foreach ($server in $AcutalFPStargets){
Variables in text.. so I can remember sometimes need brackets othertimes not... @#$@#
if(!($user.homedirectory -like '*'+($server).name+'*'))

$path = "\\"+$server.Name+"\users"

No comments: