1
+ # Script to accomplish some of the common PowerShell tasks to administer Live@edu domains
2
+
3
+ # ######### FUNCTION DEFINITIONS ##########
4
+ # #########################################
5
+ # Give the user a list of tasks he/she may wish to accomplish
6
+ function ListActions
7
+ {
8
+ Write-Host " What would you like to do?"
9
+ Write-Host " 1. Change a user's password"
10
+ Write-Host " 2. Change a WindowsLiveID"
11
+ Write-Host " 3. Change a Primary Email Address"
12
+ Write-Host " 4. Create a new User Account"
13
+ Write-Host " 5. Quit"
14
+ }
15
+
16
+ function ChangePassword
17
+ {
18
+ # Script to change a user's password
19
+ $PasswordUser = Read-Host - prompt " Enter the user's WindowsLiveID: "
20
+ $NewPassword = Read-Host - prompt " Enter the usere's new password: " - AsSecureString
21
+ Set-Mailbox $PasswordUser - Password $NewPassword
22
+ }
23
+
24
+ function ChangeWLID
25
+ {
26
+ # Script to change a WindowsLiveID
27
+ $WLIDUser = Read-Host - prompt " Enter the user's current WindowsLiveID: "
28
+ $NewWLID = Read-Host - prompt " Enter the user's new WindowsLiveID: "
29
+ Set-Mailbox $WLIDUser - WindowsLiveID $NewWLID
30
+ }
31
+
32
+ function ChangeEmail
33
+ {
34
+ # Script to change a primary email address
35
+ $WLIDUser = Read-Host - prompt " Enter the user's WindowsLiveID: "
36
+ $NewEmail = Read-Host - prompt " Enter the user's new Primary Email Address: "
37
+ Set-Mailbox $WLIDUser - EmailAddresses SMTP:$NewEmail , $WLIDUser
38
+ }
39
+
40
+ function CreateNew
41
+ {
42
+ # Script to create a new user account
43
+ $FullName = Read-Host - prompt " Enter the full name: "
44
+ $NewPassword = Read-Host - prompt " Enter the new Password: " - AsSecureString
45
+ $NewWLID = Read-Host - prompt " Enter the new WindowsLiveID: "
46
+ $FirstName = Read-Host - prompt " Enter the first name: "
47
+ $LastName = Read-Host - prompt " Enter the last name: "
48
+ New-Mailbox - Name " $FullName " - Password $NewPassword - WindowsLiveID $NewWLID - ResetPasswordOnNextLogon $false - FirstName $FirstName - LastName $LastName - DisplayName " $FullName "
49
+ }
50
+
51
+ function Quit
52
+ {
53
+ # Remove the cloud-based session from the client-side session
54
+ Remove-PSSession $session
55
+ }
56
+
57
+ # ######### INTERACTIVE PORTION ##########
58
+ # Prompt the user for their Live@edu administrative WindowsLiveID & Password
59
+ $LiveCredential = Get-Credential
60
+
61
+ # Create a new cloud-based session using the credentials the user just provided
62
+ $Session = New-PSSession - ConfigurationName Microsoft.Exchange - ConnectionUri https:// ps.outlook.com / powershell/ - Credential $LiveCredential - Authentication Basic - AllowRedirection
63
+
64
+ # Import cloud-based $session into the client-side session
65
+ Import-PSSession $Session
66
+
67
+ # List all the available script actions, and get the user's choice
68
+ while ( $UserTask -ne 5 )
69
+ {
70
+ ListActions
71
+ $UserTask = Read-Host
72
+ if ( $UserTask -eq 1 ){ ChangePassword }
73
+ if ( $UserTask -eq 2 ){ ChangeWLID }
74
+ if ( $UserTask -eq 3 ){ ChangeEmail }
75
+ if ( $UserTask -eq 4 ){ CreateNew }
76
+ else { Write-Host " Please enter a number, 1-5" }
77
+ }
78
+ if ( $UserTask = 5 ){ Quit }
0 commit comments