powershell - Trying to disable users in AD who are not in a CSV -



powershell - Trying to disable users in AD who are not in a CSV -

i've been trying find analogs in forums, it's logic that's tying me - putting together.

i have advertisement , have csv of users should in particular ou. want compare users in ou csv, , users not in csv, want disable them , move them different ou.

i'm new powershell , having bit of rough time this. what's getting me comparing , if-then logic...i can't syntax right. i've tried few options...this have right

import-module activedirectory $path = "f:\admgmt\" $logpath = "f:\admgmt\logs\diable_ad_users.log" $userfile = $path + "\files\ad_currentemployees.csv" $location = "ou=faculty,ou=people,dc=mydomain,dc=com" $disabledou = "ou=disabledemployees,ou=disabled,dc=mydomain,dc=com" $ad_users = get-aduser -filter * -searchbase "ou=faculty,ou=people,dc=mydomain,dc=com" | select -expandproperty samaccountname $sams = $userfile | select-object -expandproperty nameunique #the compare-object $ad_users $sams | out-file $logpath

but tags available things includeequal , excludedifferent...but not includedifferent...and how 1 side?

help!

what pipe results where clause using sideindicator filter on.

compare-object $ad_users $sams | where-object{$_.sideindicator -eq "<="} | select-object -expandproperty inputobject

using direction need, either "<=" or "=>", pipe select-object restore input object filtering on. lastly part more of import if object multidimensional.

i going seek real info has breifly tested should work.

powershell csv active-directory

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -