active directory department issue

Welcome Forums General PowerShell Q&A active directory department issue

Viewing 2 reply threads
  • Author
    Posts
    • #277059
      Participant
      Topics: 46
      Replies: 98
      Points: 633
      Rank: Major Contributor

      Hi,

      as in many organizations we have people with an ADM account.
      I would also like to include these in our offboarding process and I’m running into problems with the following:

      if I run the above mentioned code my department remains empty
      If I run the else part of my if statement then this works correctly and gives me the department name.
      what is the reason that it doesn’t work in my if statement?

      thanks for your help

      Paul

      • This topic was modified 1 month, 2 weeks ago by acer460527.
    • #277131
      Participant
      Topics: 4
      Replies: 425
      Points: 748
      Helping Hand
      Rank: Major Contributor

      -contains is for checking if a collection contains a object, it’s not meant for string comparisons.  Try changing your statement to

      if ($user -notlike ‘*.adm’) {}

      Looks like your variables are mixed up in the else statement too.

      • This reply was modified 1 month, 2 weeks ago by Matt Bloomfield. Reason: Added a missing word
      • This reply was modified 1 month, 2 weeks ago by Matt Bloomfield. Reason: Changed a word for clarity
    • #277167
      Participant
      Topics: 17
      Replies: 1951
      Points: 3,987
      Helping Hand
      Rank: Community Hero

      Assuming the disable process is the same for both accounts (which you could do certain steps for non-adm with a simple if), why not try something like this:

Viewing 2 reply threads
  • You must be logged in to reply to this topic.