active directory - Trying to Generate the superior list of User in AD using Powershell -
This is a simple power script that takes the user as input and generates the user's hierarchy in the organization It does not ensure that where I am doing wrong, the following is the code; <$> $ User = "XXXX" function managed ($ user, $ route) {$ search = [adsisearcher] $ root $ search.filter = "((Samaccountname = $ user))" $ UserAtt = $ Search.Findone () $ title = $ UserAtt.Properties.title $ ManDN = $ UserAtt.properties.manager ($ title -mail "avp") {$ ManDN $ title} Other {$ ManRoot = "[ADSI ] `" LDAP: // "+ $ MANDN $ ManDN =" `'" + $ Mandan + "`' "$ ManSamID = dsquery user $ MandIdN -Sap $ $ $ ManSamID $ MANRoot managed by}} Foreach ($ User $ user) {$ UserDN = dsquery user - SIM $ user $ UserCN = $ UserDN.split ("=") [1] .split (",") [0] $ User DN = $ USerDN .Substring (1) $ root = "[ADSI]` "LDAP: //" + $ UserDN $ user $ root is managed by "
This person's AVP is supposed to be printed, but failing with its errors; what am I doing wrong? If you ask a question, then tell me I am preventing any adi command from using it - it works universally for powers lets you. Please advise accordingly.
You can correct the typo in the ManagedBy
function first and
$ ManRoot = " [ADSI] `'LDAP: //" + $ MANDN
Then you should get the error.
Comments
Post a Comment