-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstall-BGinfo.ps1
More file actions
80 lines (62 loc) · 2.24 KB
/
Install-BGinfo.ps1
File metadata and controls
80 lines (62 loc) · 2.24 KB
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
#Start Logging
$logdir = 'C:\AzurePowershellLogs\'
$logfile = 'DeployBGinfo.txt'
$fulllogpath = $logdir+$logfile
if($(test-path -Path $logdir)-eq $false){
$LogOutput = "Creating folder for log: $logdir"
New-Item -Path $logdir -ItemType Directory -ErrorAction Stop
}
else{
$LogOutput = "Folder already Exists: $logdir"
}
Start-Transcript -Path $fulllogpath
Write-Host $LogOutput
##DEPOLY BGINFO WITH CUSTOM CONFIG IN INTUNE
#HardCoded
$URL = "https://download.sysinternals.com/files/BGInfo.zip"
$BGIURL = "https://github.com/spicyfeast/mhc/raw/main/MHC.bgi"
$installfolder = "C:\BGinfo\"
$ZipDownload = "BGInfo.zip"
$BGICONFIG = "MHC.bgi"
$exe = "Bginfo.exe"
$InstallerPath = $installfolder + $ZipDownload
$BGIPATH = $installfolder + $BGICONFIG
$exepath = $installfolder + $exe
$bgInfoRegPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
$bgInfoRegkey = "BgInfo"
$bgInfoRegType = "String"
$bgInfoRegkeyValue = "$exepath $BGIPATH /timer:0 /nolicprompt"
$regKeyExists = (Get-Item $bgInfoRegPath -EA Ignore).Property -contains $bgInfoRegkey
#Check for Folder
Write-Output "Checking for folder $installfolder"
if (-not (Test-Path $installfolder)) {
# Destination path does not exist, let's create it
try {
New-Item -Path $installfolder -ItemType Directory -ErrorAction Stop
Write-Output "Created folder $installfolder"
} catch {
throw "Could not create path '$installfolder'!"
}
}
##DOWNLOAD BGInfo
Write-Output "Downloading $URL..."
Invoke-WebRequest -Uri $URL -OutFile $InstallerPath
Write-Output "Downloaded $InstallerPath"
##Download CONFIG
Write-Output "Downloading $BGIURL..."
Invoke-WebRequest -Uri $BGIURL -OutFile $BGIPATH
Write-Output "Downloaded $BGIPATH"
#EXTRACT
Write-Output "Unziping $InstallerPath to $installfolder"
Expand-Archive -LiteralPath $InstallerPath -DestinationPath $installfolder
#Create BgInfo Registry Key to AutoStart
If ($regKeyExists -eq $True){
Write-Host "Reg Key Already exists"
}Else{
Write-Host "Creating Reg Key"
New-ItemProperty -Path $bgInfoRegPath -Name $bgInfoRegkey -PropertyType $bgInfoRegType -Value $bgInfoRegkeyValue
}
## Run BgInfo
Write-Host "Running $exe"
C:\BGInfo\Bginfo.exe C:\BGInfo\MHC.bgi /timer:0 /nolicprompt /silent
Stop-Transcript