-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathecsm-dataswap-365.ps1
64 lines (56 loc) · 2.27 KB
/
ecsm-dataswap-365.ps1
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#
<#
.SYNOPSIS
Copy an O365 attribute to another field
.DESCRIPTION
This script copies the data from a user defined to another user defined field
.NOTES
Email: helpdesk@exclaimer.com
Date: 31st August 2016
.USAGE
As the attributes cannot be specified using variables you will need to do the following to tailor the script to your use
- Replace all instances of <field1> with the field you have data you want copying
- Replace all instances of <field2> with the field you wish to copy to
- You can further filter the Get-User command that obtains the user information with the -filter parameter. Examples of this below
- Get-User -Filter "HomePhone -like '*'"
.PRODUCTS
Exclaimer Cloud - Sigonatures for Office 365
.REQUIREMENTS
- Global Administrator Account
#>
function basic-auth-connect {
$LiveCred = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection
Import-PSSession $Session
}
function modern-auth-mfa-connect {
Import-Module ExchangeOnlineManagement
$upn = Read-Host ("Enter the UPN for your Global Administrator")
Connect-ExchangeOnline -UserPrincipalName $upn
}
function modern-auth-no-mfa-connect {
Import-Module ExchangeOnlineManagement
$LiveCred = Get-Credential
Connect-ExchangeOnline -Credential $LiveCred
}
$authtype = Read-Host ("Do you have basic auth enabled? Y/n")
If ($authtype -eq "y") {
basic-auth-connect
}
Else {
$mfa = Read-Host ("Do you have MFA enabled? Y/n")
if ($mfa -eq "y") {
modern-auth-mfa-connect
}
Else {
modern-auth-no-mfa-connect
}
}
$users = Get-User | Select UserPrincipalName,"<field1>","<field2>" | Export-CSV -Path $env:APPDATA\Users.csv -NoTypeInformation
$out = Get-User | Select UserPrincipalName,"<field1>","<field2>"
Write-Host ("These are the users that are going to be altered. There is a CSV of this outputted to %appdata%\Users.csv")
Write-Output $Out
Write-host ("")
$confirm = Read-Host ("Are you sure you want to make these changes? y/N")
if ($confirm -eq "y" -or "yes") {
Import-CSV $env:appdata\users.csv | foreach { Set-User $_.UserPrincipalName -"<field2>" $_."<field1>" } }