-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExchangePowershell.psm1
49 lines (37 loc) · 1.4 KB
/
ExchangePowershell.psm1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# PS is: Dynamically typed
# Connecting
Connect-ExchangeOnline -UserPrincipalName [email protected]
# Print a variable (like an array of objects)
$mysteryVariable.GetType
# Creating data types
$singleValue = "Hello, World!" # string
$array = @("Item1", "Item2", "Item3") # Array of strings
$object = [PSCustomObject]@{Name="John"; Age=30} # This is a custom object
$arrayOfObjects = @(
[PSCustomObject]@{Name="John"; Age=30},
[PSCustomObject]@{Name="Jane"; Age=25}
)
# Getting data type
$mystery
# Print an array of objects formatted as a list
$variable | Format-List
# Get attributes from an arrray of objects
$someArray | Get-Member
# Get users
$users = Get-Mailbox -ResultSize Unlimited
# Filter our users with certain domains
$excludedDomains = @("[email protected], [email protected]")
$filteredUsers = $users | Where-Object {
$userDomain = $_.UserPrincipalName.Split('@')[1]
-not ($excludedDomains -contains $userDomain)
}
# Printing the addresses of above
$filteredUsers.UserPrincipalName
# Get a mailbox config
Get-MailboxRegionalConfiguration -Identity "[email protected]"
# See it as a list
Get-MailboxRegionalConfiguration -Identity "[email protected]" | Format-List
# Get a list of mailbox properties
Get-MailboxRegionalConfiguration -Identity "[email protected]" | Get-Member
# Set a mailbox config
Set-MailboxRegionalConfiguration -Identity "[email protected]" -TimeZone "Atlantic Standard Time"