1

I have a list of employees who need skype access, and Im looking to run a create user script from this list, but only have it run on people who do not have msRTCSIP-UserEnabled as a null value.

The following will show me if msRTCSIP-UserEnabled is present / True

get-aduser -identity $username -Properties msRTCSIP-UserEnabled

I need to use the value as a conditional in something like

foreach($username in $userlist)
{

    if (get-aduser -identity $username -Properties msRTCSIP-UserEnabled -eq $null)
        {Run user creation / output script}

    else
        {continue to next $username}

}

I have all of it working / outputting properly, but cant seem to figure out how to use the msRTCSIP-UserEnabled attribute value as a conditional. I've tried looking around, but everything I see on this is for pulling info from AD not a specific file list.

2
  • Punt: Try storing the value in a variable prior to checking it in the if statement. It's been a few years since I've done scripting so I'm uncertain about best syntax, but the if condition (the part between the parentheses) looks suspect to me. Separating out the value into a variable would simplify the if condition.
    – Bob Smiley
    Commented Jul 21, 2017 at 15:57
  • Thats exactly what i had to do.
    – mweldinger
    Commented Jul 21, 2017 at 23:23

2 Answers 2

0

I'm not sure i fully understand your question, but would something like this work?

foreach ($username in $userlist)
{
    $aduser = get-aduser -Identity $username -Properties msRTCSIP-UserEnabled

    if ($aduser.'msRTCSIP-UserEnabled' -ne $null)
    {
        ##Code to Run user creation / output script
    }
}
1
  • It looks like you're understanding correctly. Basically i need to use the value of the AD attribute msRTCSIP-UserEnabled to determine rather or not to execute the lync user creation. How would I store just the msRTCSIP-UserEnabled attribute?
    – mweldinger
    Commented Jul 21, 2017 at 16:23
0

With some help from leinad13 I figured it out.

foreach ($Username in $userlist) 
{

$User = get-aduser $username -properties msRTCSIP-UserEnabled
$LyncStatus = $User.'msRTCSIP-UserEnabled'


if ($lyncstatus -notlike "True")
    {
     #run add lync user script
    }
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .