Jump to content

Swyx Instant Messaging Function /Powershell


Foley

Recommended Posts

Hey,
i would like to write a Script that checks if the Users have the rights to use the instant messaging function.
I already did something looking like this.
 

Connect-IpPbx
# Get All User objects
$usernames = Get-IpPbxUser

foreach ($username in $usernames) {
   # Get user data
  $userData = Get-IpPbxUserData -username $username.name
  foreach ($username in $usernames) {

   "$username = " + $username.length
where ($userdata.m_bUseIMClientAllowed = (0))
 }
 }

any tipps? i want the shell to show me the name of the user, not an id or something and  if the m_bUseIMClientAllowed  ist on or off 
and i want it to be for every user, at the moment he just gives me back all users as id and a 1 that does not refer to the m_bUseIMClientAllowed as it seems from manually checking the swyxware administration.

Best regards, Dennis

 

Link to comment
Share on other sites


  • Most Valued User

Hello RandomSwyxUser,

 

I just had a quick look on your code. I recommend not to use the classic "foreach" in Powershell. This often leads to problems like this. I re-wrote your script and added some useful notes:

 

# Connect to local SwyxWare via Windows Authentication
Connect-IpPbx

# Get all users
Get-IpPbxUser | ForEach-Object {
    
    $userEntry = $_
    $userData = Get-IpPbxUserData -UserEntry $userEntry

    # This is a console output only -> cannot be used as return value
    Write-Host "$($userEntry.Name): $($userData.m_bUseIMClientAllowed)"

    # This is a return value and can be redirected into a variable
    #"$($userEntry.Name): $($userData.m_bUseIMClientAllowed)"

    # If you want to change the settings just modify the
    # $userData object and save it with Set-IpPbxUserData
    #Set-IpPbxUserData -UserEntry $userEntry -UserData $userData   
}

Kind regards

 

Sebastian Dreier

Link to comment
Share on other sites


Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and have taken note of our Privacy Policy.
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.