EvotecIT / ADEssentials

PowerShell Active Directory helper functions to manage healthy Active Directory
MIT License
429 stars 51 forks source link

no commands exist in some functions #7

Closed ironbe4rd closed 4 years ago

ironbe4rd commented 4 years ago

you dont even have a command in these functions to get the data. get-winadproxyaddresses Get-WinADUserPrincipalName

perhaps others as well im not going to go through all of them

PrzemyslawKlys commented 4 years ago

Can you be more specific - where exactly are you looking?

Published version when I search for: Get-WinADProxyAddresses

GitHub version:

https://github.com/EvotecIT/ADEssentials/blob/cb2f48d20c6a8623589b22f882d508b7a8510395/Public/Get-WinADProxyAddresses.ps1#L1-L71

So where do you miss things or what is not working for you?

PrzemyslawKlys commented 4 years ago

Unless you're looking for a use case:

$ADUsers = Get-ADUser -Filter * -Properties ProxyAddresses
foreach ($User in $ADUsers) {
    Get-WinADProxyAddresses -ADUser $User
}
$ADUsers = Get-ADUser -Filter * -Properties ProxyAddresses
foreach ($User in $ADUsers) {
    Get-WinADProxyAddresses -ADUser $User -RemovePrefix
}
PrzemyslawKlys commented 4 years ago

Not all commands are publicly usable, I use them in other cases, that may not be obvious at first sight.

ironbe4rd commented 4 years ago

Ah i see now what you mean. That is how i ended up using it anyway. Usually with these functions I would expect the actual commands to get the property to be in the Function, here you are just formatting the data.

PrzemyslawKlys commented 4 years ago

Well, I don't know what use case there may be for you. In this case, I'm requesting all users, but in others, I may request just couple of users that require fixing. When there are too many variables in place I usually just create helper function rather than do it all for me. In other cases, there's a full "fix it for me please".

ironbe4rd commented 4 years ago

While I have you. How do you use repair-winademailaddress?

I keep getting cannot find object on the username.

On Fri, Aug 14, 2020, 9:28 AM Przemysław Kłys notifications@github.com wrote:

Well, I don't know what use case there may be for you. In this case, I'm requesting all users, but in others, I may request just couple of users that require fixing. When there are too many variables in place I usually just create helper function rather than do it all for me. In other cases, there's a full "fix it for me please".

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/EvotecIT/ADEssentials/issues/7#issuecomment-674074638, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANYW63OH5UIJME2F7EHGGBDSAU3XJANCNFSM4P7O7MPQ .

PrzemyslawKlys commented 4 years ago

Lemme fix this one. I see an edge case I've not thought of on this one.

PrzemyslawKlys commented 4 years ago

This would be your use case

# Get a user
$User = Get-ADUser 'testing1' -Properties ProxyAddresses, EmailAddress
# You can optionally verify how it looks like or what is set
#Get-WinADProxyAddresses -ADUser $User | Format-Table
# Fix primary email address - it will be added to primary email field + proxy address as primary, existing addresses will be rearanged
Repair-WinADEmailAddress -ADUser $User -ToEmail 'testing2@evotec.xyz' -Display -WhatIf | Format-Table

-WhatIf shows what will happen -Display will give you an output like this:

image

For example:

# Get a user
$User = Get-ADUser 'testing1' -Properties ProxyAddresses, EmailAddress
# You can optionally verify how it looks like or what is set
#Get-WinADProxyAddresses -ADUser $User | Format-Table
# Fix primary email address - it will be added to primary email field + proxy address as primary, existing addresses will be rearanged
Repair-WinADEmailAddress -ADUser $User -ToEmail 'testing2@evotec.be' -Display -WhatIf | Format-Table

image

Without WHATIF

image

PrzemyslawKlys commented 4 years ago

Update-Module ADEssentials. I've released one with fixes.

ironbe4rd commented 4 years ago

Thanks updates are greatly appreciated!

On Fri, Aug 14, 2020, 4:48 PM Przemysław Kłys notifications@github.com wrote:

Closed #7 https://github.com/EvotecIT/ADEssentials/issues/7.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/EvotecIT/ADEssentials/issues/7#event-3657651295, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANYW63I7K4QOOZTKJGB2P6LSAWPLTANCNFSM4P7O7MPQ .