Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

AutopilotBranding/Bitdefender/BitdefenderSetup.cmd

AutopilotBranding/Bitdefender/
File renamed without changes.
3 changes: 3 additions & 0 deletions PPM/_actions/test.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
New-Item -ItemType Directory C:\temp\testing\ -Force
New-Item -ItemType Directory C:\temp\testin1\ -Force
New-Item -ItemType Directory C:\temp\testin2\ -Force
1 change: 1 addition & 0 deletions PPM/_actions/test2.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
New-Item -ItemType Directory C:\temp\testin2\ -Force
90 changes: 90 additions & 0 deletions PPM/init.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
######################################################################
# #
# Download and Unzip GitHub Repository #
# Author: Sandro Pereira\CJ COulter #
# #
######################################################################

New-Item -ItemType File -Path "$($env:ProgramData)\Microsoft\AutopilotBranding\PPM.log" -Force


Start-Transcript -Path "$($env:ProgramData)\Microsoft\AutopilotBranding\PPM.log"

function DownloadGitHubRepository
{
param(
[Parameter(Mandatory=$False)]
[string] $Name = "MEM-PPM",

[Parameter(Mandatory=$False)]
[string] $Author = "Grimothy" ,

[Parameter(Mandatory=$False)]
[string] $Branch = "Dev",

[Parameter(Mandatory=$False)]
[string] $Location = "$($env:ProgramData)\Microsoft\AutopilotBranding\scripts\PPM\_Extractions",

[Parameter(Mandatory=$False)]
[string] $weburi = "https://github.com/Grimothy/MEM-PPM/tree/main/_actions"

)

$RepositoryZipUrl = "https://api.github.com/repos/$Author/$Name/zipball/$Branch"

If ($(Invoke-WebRequest -Uri $weburi).StatusDescription -like "OK")
{

Write-Host -ForegroundColor Green "$weburi is Healthy"
Start-Sleep -Seconds 2
# Force to create a zip file
$ZipFile = "$location\$Name.zip"
New-Item $ZipFile -ItemType File -Force



# download the zip
Write-Host 'Starting downloading the GitHub Repository'
Invoke-RestMethod -Uri $RepositoryZipUrl -OutFile $ZipFile
Write-Host 'Download finished'

#Extract Zip File
Write-Host 'Starting unzipping the GitHub Repository locally'
Expand-Archive -Path $ZipFile -DestinationPath $location -Force
Write-Host 'Unzip finished'

# remove the zip file
Remove-Item -Path $ZipFile -Force

#Copy extracted items
$foldersource = Get-ChildItem -Recurse $Location | Where-Object {$_.BaseName -like "_actions"} -Verbose
#Copy-Item -Recurse $foldersource.FullName "$($env:ProgramData)\Microsoft\AutopilotBranding\scripts\PPM\_actions" -Force
Robocopy $foldersource.FullName "$($env:ProgramData)\Microsoft\AutopilotBranding\scripts\PPM\_actions" /MIR /FFT /Z /XA:H /W:5
#Remove extracted files
Remove-Item $Location -Recurse -Force




}else{

exit
}
}
DownloadGitHubRepository

#Beging processing Actions
Write-Host "Starting to process items in _actions folder"
$scripts = Get-ChildItem -Recurse "$($env:ProgramData)\Microsoft\AutopilotBranding\scripts\PPM\_actions\" |
Where-Object {($_.Extension -like "*ps1" -or $_.Extension -like "*bat") }
Set-ExecutionPolicy -ExecutionPolicy Bypass

Foreach ($i in $scripts) {

Write-Host "Processing script $i"
Start-Process powershell -WindowStyle Hidden $i.FullName

}

Stop-Transcript