I am not a programmer, just trying to grab code from here and there to enable or disable skypeB users in bulk to make the job a bit easier and faster.
wrote the code below, but lines 41-43 are not working in the script. They work individually if I run them from the ps> prompt.
Any help will be appreciated. Script is still not completed do do other things as well. Hopefully when completed, I can post the final script here :?) don't pay any attention to the commented lines, that is just information to keep me calm...
#sAMAccountName,mail,msRTCSIPLine,ConferencingPolicy,RegistrarPool,LineURI,sipaddress,action
$UserList = Import-CSV "$PSScriptRoot\Skypebuserlist.csv"
#$category = "user"
#$name = "uid"
#$data = "sharifm*"
#$attributes = @("givenName", "mail", "manager")
#$attributes = @("mail","givenName","sn","msRTCSIP-Line","uid")
#$attribute ="givenName"
##$Header = $attributes -join','
#Write-Host $Header
#$lines = @()
#$lines += $Header
#$results = @()
foreach ($user in $UserList) {
Write-Host ("The User {0} with Phone ({1}) and Action = {2}" -f $user.sAMAccountName, $user.mail, $user.RegistrarPool, $user.sipaddress, $user.ConferencingPolicy, $user.msRTCSIPLine, $user.action)
$poolName = (Get-CsUser | Group-Object RegistrarPool | sort-object count | select-object -first 1).Name
if ($user.action -eq "disable")
{
Write-Host "disable account"
Write-Host Get-CsUser $user.sAMAccountName
if (Get-CsUser $user.sAMAccountName){
disable-CsUser $user.sAMAccountName
}
else
{
Write-Host "not found"
}
}
else
{
Write-Host ("Enable account for POOL {0} " -f $poolName)
if ($user.msRTCSIPLine) {
Write-Host "has phone"
Enable-CsUser -Identity "$user.sAMAccountName" -RegistrarPool "$poolName" -SipAddress "sip:$user.sipaddress"
Set-CsUser $user.sAMAccountName -EnterpriseVoiceEnabled $True -Confirm:$True
Set-csuser $user.sAMAccountName -LineURI $user.msRTCSIPLine
}
else{
Write-Host "does not have phone"
}
}
Write-Host "-----------------------------------------------------------------------------"
}
Write-Host
Write-Host "File Done"
Write-Host