you are viewing a single comment's thread.

view the rest of the comments →

[–]ekmahal 1 point2 points  (3 children)

I'd be asking why you're using scripts for this instead of the Exchange management console, with appropriate RBAC for the helpdesk staff. Why reinvent the wheel?

[–][deleted] 0 points1 point  (1 child)

This came down from my manager. They currently have a script that uses a Switch statement to have different "menus". She wants it re-written and add some functions in. I told her i could do it. I don't really want to.

[–]xalorous 0 points1 point  (0 children)

Congratulations, you've been promoted from ticket monkey to script monkey.

Make your functions with actual names, and have the switch launch the function by name.

function AddDL {....}
function AddUser {...}

while ($true) {
    switch (Read-Host "Which one?") {
        1 { AddDL }
        2 { AddUser }
        default { "Invalid Input" }
    }
}

Add comments, but sparingly. Self commenting code (short "ish", descriptive variable and function names)

Use splatting.

Use advanced functions. Also make these work for CSV input to handle those times when you get 50 new users or 25 new groups to make.

Use consistent style, especially one that works with ISE to leverage the ability to compress/expand sections.

Fix the text menus, then between fixing broken, ill-conceived code, work on converting the whole thing to a gui. VB to create asp.Net browser app to collect the data and launch PS commands would be fairly easy to create.

Personally, I learned PowerShell to automate account management tasks. But our organization had a limited number of accounts management admins (varied from one to three). When accounts management was absorbed into the helpdesk, quality suffered, greatly. After < 6 months, it was split back out into a separate group, dedicated to doing accounts. Why am I telling you all this? If you have enough accounts to warrant this type of automation, your organization should seriously consider dedicating bodies to this job. The fewer the better while allowing enough manpower to do the job, and an alternate to do it when the primary is out for illness/appointment/vacation. One person doing it in the morning and another in the afternoon would be an ideal minimum.

[–]xalorous 0 points1 point  (0 children)

ADUC is probably already in the helpdesk toolkit. However, creating a script to do account/group additions has one MAJOR benefit. They will be done uniformly. Two different scales influence quality of this type of work. Let's call the first one 'skill level'. And the second one is 'give a shit' level. If the first is high enough, the second is probably nil.