-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsetFSLogixOneDrive.ps1
executable file
·100 lines (92 loc) · 3.62 KB
/
setFSLogixOneDrive.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
param (
[string]$connectionString = $(throw "-connectionString is required."),
[string]$tennantId = $(throw "-tennantId is required.")
)
mkdir .\temp
cd .\temp
#Download fxlogix
try {
Invoke-WebRequest 'https://aka.ms/fslogix_download' -OutFile '.\fslogix.zip'
Expand-Archive '.\fslogix.zip'
$FsLogixInstallFile = Get-ChildItem -Path .\fslogix -Recurse -Include 'FSLogixAppsSetup.exe' | where {$_.FullName -match 'x64'}
"Downloaded FSLogix"
}
catch {
Throw "Failed to download FSLogix"
}
#Install fxlogix
try {
Start-Process -FilePath $FsLogixInstallFile -ArgumentList "/quiet /norestart" -Wait
"Installed FSLogix"
}
catch {
Throw "FSLogix not installed $_"
}
#Download PSTools
try {
Invoke-WebRequest 'https://download.sysinternals.com/files/PSTools.zip' -OutFile PSTools.zip
Expand-Archive PSTools.zip
"Downloaded PSTools"
}
catch {
Throw "Failed to download PSTools"
}
#Add secure key to credential manager
if ((Test-Path ".\PSTools\PsExec.exe") -and (Test-Path "C:\Program Files\FSLogix\Apps\frx.exe")){
try {
.\PSTools\PsExec.exe -s -accepteula "C:\Program Files\FSLogix\Apps\frx.exe" add-secure-key -key='connectionString' -value="$connectionString"
}
catch {
"Error adding key: $_"
}
}
else{
"not both exist"
}
#Configure FXLogix
if(Test-Path HKLM:\Software\FSLogix\Profiles){
New-ItemProperty -Path "HKLM:\Software\FSLogix\Profiles" `
-Name "Enabled" `
-PropertyType:DWord `
-Value 1 -Force
New-ItemProperty -Path "HKLM:\Software\FSLogix\Profiles" `
-Name "CCDLocations" `
-PropertyType:String `
-Value "type=azure,connectionString=|fslogix/connectionString|" -Force
New-ItemProperty -Path "HKLM:\Software\FSLogix\Profiles" `
-Name "VolumeType" `
-PropertyType:String -Value vhdx -Force
New-ItemProperty -Path "HKLM:\Software\FSLogix\Profiles" `
-Name "DeleteLocalProfileWhenVHDShouldApply" `
-PropertyType:dword `
-Value 1 -Force
New-ItemProperty -Path "HKLM:\Software\FSLogix\Profiles" `
-Name "FlipFlopProfileDirectoryName" `
-PropertyType:dword `
-Value 1 -Force
}
#Silently move Windows known folders to OneDrive
$HKLMregistryPath = 'HKLM:\SOFTWARE\Policies\Microsoft\OneDrive'
if(!(Test-Path HKLM:\SOFTWARE\Microsoft\OneDrive)){
Invoke-WebRequest 'https://go.microsoft.com/fwlink/p/?LinkID=2182910' -OutFile OneDriveSetup.exe
Start-Process -FilePath ./OneDriveSetup.exe -ArgumentList "/allusers /silent" -Wait
$oneDrivePath = 'C:\Program Files\Microsoft OneDrive\OneDrive.exe'
if(Test-Path "C:\Program Files (x86)\Microsoft OneDrive\OneDrive.exe"){ $oneDrivePath = "C:\Program Files (x86)\Microsoft OneDrive\OneDrive.exe"}
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" -Name "OneDrive" -PropertyType:String -Value $oneDrivePath -Force
}
if(!(Test-Path $HKLMregistryPath)){New-Item -Path $HKLMregistryPath -Force > $null}
New-ItemProperty -Path $HKLMregistryPath -Name 'SilentAccountConfig' -PropertyType:DWord -Value '1' -Force
New-ItemProperty -Path $HKLMregistryPath -Name "KFMSilentOptIn" -PropertyType:String -Value $tennantId -Force
New-ItemProperty -Path $HKLMregistryPath -Name 'FilesOnDemandEnabled' -PropertyType:DWord -Value '1' -Force
try {
Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile .\AzureCLI.msi
Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet'
rm .\AzureCLI.msi
"Installed AzureCLI"
}
catch {
Throw "Failed to install AzureCLI"
}
cd ..
Remove-Item -Recurse -Force .\temp
Remove-Item -Force $MyInvocation.MyCommand.Path