Foley Posted December 1, 2016 #1 Share Posted December 1, 2016 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 More sharing options...
Foley Posted December 5, 2016 Author #2 Share Posted December 5, 2016 Push, no one? Link to comment Share on other sites More sharing options...
Most Valued User Sebastian Dreier Posted December 6, 2016 Most Valued User #3 Share Posted December 6, 2016 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 More sharing options...
Foley Posted December 6, 2016 Author #4 Share Posted December 6, 2016 In order to get the right information, how can i tell ps to only view the users that have IM set active userdata.m_bUseIMClientAllowed = 1 only show those Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.