A few scripts to set, copy and check the Pager attribute in ActiveDirectory, very usefull for SMSPasscode

$members = Get-ADGroupMember "HSH-SMS With License"

foreach ($member in $members) {
$user = Get-ADUser $member -Properties pager
$pager = $user.pager
if ($pager -eq $null)
    {
    write-host "pager for $user is blank"
    }
                            }

 

$members = Get-ADGroupMember "HSH-SMS Without License"

foreach ($member in $members) {
$user = Get-ADUser $member -Properties pager
$pager = $user.pager
if ($pager -eq $null)
    {
    write-host "pager for $user is blank"
    $user.pager = "12345678"
    Set-ADUser -instance $user
    }
                            }

 

$members = Get-ADGroupMember "HSH-SMS With License"
foreach ($member in $members) {
$user = Get-ADUser $member -Properties pager,mobile
$pager = $user.pager

if ($pager -ne "12345678")
    {
    
    $user.mobile = "+45$pager" #set mobile as pager number with +45 in front
    $user.SamAccountName #output user 
    $user.mobile  #output mobile number
    Set-ADUser -instance $user #write the attribute to AD
    }
                            }

 

$source = "Skriv gruppe 1"
$destination = "Skriv gruppe2"

$members = Get-ADGroupMember -Identity $source
foreach ($member in $members){
Add-ADGroupMember -identity $destination -members $member
}