none
Lync Powershell help -getting error "Management Object Not found" RRS feed

  • Question

  • Hi,

    I want to reference a list of users in Lync that do not have a HostedVoicemailPolicy applied. Please can someone help me..

    I have a list of users that form a txt file I am referencing called $lynctest.

    User1
    User2
    User3
    NoSuchUser1
    NoSuchUser2

    I have the following and its not catching the error so that I can output to another file.

    try
    {
    foreach($lyncuser in $lynctest)
        {
        Get-CsUser -Identity $lyncuser | select displayname, hostedvoicemailpolicy
     
    }
    catch
    {
       write-host "$lyncuser user not found" > "c:\datatemp\listofusers.txt"
    }

    Monday, March 23, 2015 3:21 PM

All replies


  • Get-CsUser -Identity $lyncuser -ErrorAction:stop | select displayname, hostedvoicemailpolicy

    Monday, March 23, 2015 3:27 PM
    Moderator
  • Hi, Thanks. Already tried that but doesn't work :(
    Monday, March 23, 2015 5:44 PM
  • Not super efficient, but quick and dirty.  If you're talking about thousands of users, this might be too slow and we can work something else out.  If you're talking about a handful, this might be fine.

    foreach($lyncuser in $lynctest)

    { $founduser=Get-CSUser|Where-Object {$_.samaccountname -match $lyncuser} if ($founduser) { "The user exists" } else { "The user does not exist" }

    }



    Please remember, if you see a post that helped you please click "Vote As Helpful" and if it answered your question please click "Mark As Answer". SWC Unified Communications

    This forum post is based upon my personal experience and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.


    Tuesday, March 24, 2015 5:44 PM

  • Any error messages or screen shots to help us better understand the issue?

    Thanks / rgds,


    TechNet/MSDN Forum Moderator - http://www.leedesmond.com

    Thursday, March 26, 2015 10:27 PM
    Moderator