private/Install.ps1
function Install-Features { [CmdletBinding( SupportsShouldProcess = $true )] param( [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [array]$Features ) $InstalledFeatures = Get-WindowsFeature | Where-Object InstallState -eq "Installed" foreach ($Feature in $Features) { if (!($InstalledFeatures.Name -match $Feature)) { Write-Host "Installing $Feature" Install-WindowsFeature $Feature } else { Write-Host "Feature $Feature is already installed" } } } Function Install-NiniteApps { [CmdletBinding( SupportsShouldProcess = $true )] param( [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [array]$Apps ) Write-Host "Downloading Ninite ..." $ofs = '-' $niniteurl = "https://ninite.com/" + $Apps + "/ninite.exe" $output = (Join-Path $InstallPath "\download\ninite.exe") if (Test-Path $Output) { Write-Verbose -Message "File alreday exist" } Invoke-WebRequest $niniteurl -OutFile $output & $output } Function Install-ChocoApps { [CmdletBinding( SupportsShouldProcess = $true )] param( [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [array]$Apps ) If (!(Test-Path -Path "$env:ProgramData\Chocolatey")) { Set-ExecutionPolicy Bypass -Scope Process -Force; Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) } choco install $Apps -y } Function Copy-FileApp { [CmdletBinding( SupportsShouldProcess = $true )] param( [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [string]$Path, [Parameter(Mandatory = $false)] [ValidateNotNullOrEmpty()] [bool]$DesktopLink = $false ) $OutputFile = Split-Path $Path -leaf $Output = (Join-Path $BaseFolder ("\data\" + $OutputFile)) Write-Host "Downloading from $($Path)" if (Test-Path $Output) { Write-Verbose -Message "File alreday exist" } Start-BitsTransfer -Source $Path -Destination $Output if ($DesktopLink -eq $true) { $ShortcutFile = "$env:Public\Desktop\" + $OutputFile.name + ".lnk" $WScriptShell = New-Object -ComObject WScript.Shell $Shortcut = $WScriptShell.CreateShortcut($ShortcutFile) $Shortcut.TargetPath = $Output $Shortcut.Save() Write-Host "Shortcut created" } } Function Install-ExeApp { [CmdletBinding( SupportsShouldProcess = $true )] param( [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [string]$Path, [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [string]$SetupArgs ) $OutputFile = Split-Path $Path -leaf $Output = (Join-Path $BaseFolder ("\download\" + $OutputFile)) Write-Host "Downloading from $($Path)" if (Test-Path $Output) { Write-Verbose -Message "File alreday exist" } Start-BitsTransfer -Source $Path -Destination $Output } Function Install-MsiApp { [CmdletBinding( SupportsShouldProcess = $true )] param( [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [string]$Path, [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [string]$SetupArgs ) $OutputFile = Split-Path $Path -leaf $Output = (Join-Path $BaseFolder ("\download\" + $OutputFile)) Write-Host "Downloading from $($Path)" if (Test-Path $Output) { Write-Verbose -Message "File alreday exist" } Start-BitsTransfer -Source $Path -Destination $Output } |