-
Notifications
You must be signed in to change notification settings - Fork 0
/
Office 2021.ps1
57 lines (46 loc) · 1.38 KB
/
Office 2021.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
cls
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
If (($currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) -eq $false){
Write-Host "Please run with administrator privileges"
Write-Host "Exiting..."
Start-Sleep 2
exit
}
Else{}
$ARCH = (wmic os get OSArchitecture)[2]
$KMS = Read-Host -Prompt "Set the KMS server(Leave blank for default)"
If ($KMS -ieq ""){
$KMS="s8.uk.to"
}
If ($ARCH = "64-bit"){
cls
Write-Host "64-bit system detected"
Write-Host " "
pause
cd "$env:ProgramFiles\Microsoft Office\Office16"
}
Else{
cls
Write-Host "32-bit system detected"
Write-Host " "
pause
cd "$env:ProgramFiles(x86)\Microsoft Office\Office16"
}
$DIR = "C:\Program Files\Microsoft Office\root\Licenses16\"
$List = Get-ChildItem -Path "C:\Program Files\Microsoft Office\root\Licenses16\*" -Include ProPlus2021VL_KMS*.xrm-ms | select-object -expandproperty Name
$CharArray = $List.Split(" ")
Foreach ($i in $CharArray){
$Item = $DIR + $i
cscript ospp.vbs /inslic:$Item
}
cscript ospp.vbs /setprt:1688
cscript ospp.vbs /unpkey:6F7TH
cscript ospp.vbs /inpkey:FXYTK-NJJ8C-GB6DW-3DYQT-6F7TH
cscript ospp.vbs /sethst:$KMS
cscript ospp.vbs /act
Start-Sleep 3
cd $env:USERPROFILE\Desktop
cls
Write-Host "Exiting..."
Start-Sleep 3
exit