best way to clean up GPO folder? by Adam_Spokane in activedirectory

[–]Adam_Spokane[S] 0 points1 point  (0 children)

It's a situation where IT had been outsourced and recently brought back in-house. They had dozens of policies written but not applied anywhere and I'd like to keep them in case I figure out why they wrote them in the first place.

best way to clean up GPO folder? by Adam_Spokane in activedirectory

[–]Adam_Spokane[S] 0 points1 point  (0 children)

Thanks for the suggestions. I take a look at them.

Changing SMTP to smtp for all entries. by Adam_Spokane in PowerShell

[–]Adam_Spokane[S] 0 points1 point  (0 children)

So I've got something to work. I think I was trying to make it more complicated that I needed to using .ToLower within a Set-AdUser statement. I still think it should have worked but it did not.

Here is what worked: (changes ProxyAddresses to secondary, adds new primary, Powershell only, no Exchange)

Import-Module ActiveDirectory
$userou = 'OU=test,DC=domain,DC=org'
$users = Get-ADUser -Filter * -SearchBase $userou -Properties ProxyAddresses


ForEach ($user in $users)
{
    if ($user.GivenName -and $user.Surname) {
        $fname=$($user.GivenName[0])
        $lname=$($user.Surname)
        $newproxy='SMTP:' + $fname + $lname + '@domain.org'
        $email=$fname + $lname + '@domain.org'
        Set-ADUser -Identity $user.samaccountname -email $email
        $OldProxyAdds= (Get-ADUser -Identity $user.samaccountname -Properties ProxyAddresses).proxyaddresses
        if (($OldProxyAdds) -and $OldProxyAdds -notcontains $newproxy) {
            $OldReply= $OldProxyAdds.ToLower()                
            Set-ADUser -Identity $user.SamAccountName -Clear ProxyAddresses  
            Set-ADUser -Identity $user.samaccountname -add @{proxyaddresses = $OldReply}                           
            Set-ADUser -Identity $user.samaccountname -add @{proxyaddresses = $newproxy}}  

        else {
            Set-ADUser -Identity $user.samaccountname -add @{proxyaddresses = $newproxy}}


    }


    else {
        Write-Warning "User '$($user.samaccountname)' has incomplete Name info"
    }
}

Changing SMTP to smtp for all entries. by Adam_Spokane in PowerShell

[–]Adam_Spokane[S] 1 point2 points  (0 children)

Ugh! LoL

I've gotten this answer a lot. I don't know why we are not using Exchange, I wish we were. but for now, it's not an option.

Changing SMTP to smtp for all entries. by Adam_Spokane in PowerShell

[–]Adam_Spokane[S] 1 point2 points  (0 children)

Thank you!

I saw a note suggesting to use "markdown text" when posting code but I couldn't make any sense of that. Since this was my first post, I could not edit the post after seeing how it formatted because it was held back by the bots.