Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
DeploymentBunny committed Nov 21, 2016
1 parent 634edb9 commit d988ab9
Show file tree
Hide file tree
Showing 2 changed files with 166 additions and 177 deletions.
179 changes: 166 additions & 13 deletions Tools/Install-Wrapper/Invoke-Install.ps1
Original file line number Diff line number Diff line change
@@ -1,13 +1,168 @@
<#
Generic installer Wrapper
<#
Install Wrapper 2.0
Author: Mikael Nystrom
http://www.deploymentbunny.com
#>

[cmdletbinding(SupportsShouldProcess=$True)]
Param
(
$Role="None"
Param(
)

Function Get-VIAOSVersion([ref]$OSv){
$OS = Get-WmiObject -Class Win32_OperatingSystem
Switch -Regex ($OS.Version)
{
"6.1"
{If($OS.ProductType -eq 1)
{$OSv.value = "Windows 7 SP1"}
Else
{$OSv.value = "Windows Server 2008 R2"}
}
"6.2"
{If($OS.ProductType -eq 1)
{$OSv.value = "Windows 8"}
Else
{$OSv.value = "Windows Server 2012"}
}
"6.3"
{If($OS.ProductType -eq 1)
{$OSv.value = "Windows 8.1"}
Else
{$OSv.value = "Windows Server 2012 R2"}
}
"10"
{If($OS.ProductType -eq 1)
{$OSv.value = "Windows 10"}
Else
{$OSv.value = "Windows Server 2016"}
}
DEFAULT { "Version not listed" }
}
}
Function Import-VIASMSTSENV{
try{
$tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
Write-Output "$ScriptName - tsenv is $tsenv "
$MDTIntegration = $true

#$tsenv.GetVariables() | % { Write-Output "$ScriptName - $_ = $($tsenv.Value($_))" }
}
catch{
Write-Output "$ScriptName - Unable to load Microsoft.SMS.TSEnvironment"
Write-Output "$ScriptName - Running in standalonemode"
$MDTIntegration = $false
}
Finally{
if ($MDTIntegration -eq $true){
$Logpath = $tsenv.Value("LogPath")
$LogFile = $Logpath + "\" + "$ScriptName.txt"
}
Else{
$Logpath = $env:TEMP
$LogFile = $Logpath + "\" + "$ScriptName.txt"
}
}
Return $MDTIntegration
}
Function Start-VIALogging{
Start-Transcript -path $LogFile -Force
}
Function Stop-VIALogging{
Stop-Transcript
}
Function Invoke-VIAExe{
[CmdletBinding(SupportsShouldProcess=$true)]

param(
[parameter(mandatory=$true,position=0)]
[ValidateNotNullOrEmpty()]
[string]
$Executable,

[parameter(mandatory=$false,position=1)]
[string]
$Arguments
)

if($Arguments -eq "")
{
Write-Verbose "Running Start-Process -FilePath $Executable -ArgumentList $Arguments -NoNewWindow -Wait -Passthru"
$ReturnFromEXE = Start-Process -FilePath $Executable -NoNewWindow -Wait -Passthru
}else{
Write-Verbose "Running Start-Process -FilePath $Executable -ArgumentList $Arguments -NoNewWindow -Wait -Passthru"
$ReturnFromEXE = Start-Process -FilePath $Executable -ArgumentList $Arguments -NoNewWindow -Wait -Passthru
}
Write-Verbose "Returncode is $($ReturnFromEXE.ExitCode)"
Return $ReturnFromEXE.ExitCode
}
Function Invoke-VIAMsi{
[CmdletBinding(SupportsShouldProcess=$true)]

param(
[parameter(mandatory=$true,position=0)]
[ValidateNotNullOrEmpty()]
[string]
$MSI,

[parameter(mandatory=$false,position=1)]
[string]
$Arguments
)

#Set MSIArgs
$MSIArgs = "/i " + $MSI + " " + $Arguments

if($Arguments -eq "")
{
$MSIArgs = "/i " + $MSI


}
else
{
$MSIArgs = "/i " + $MSI + " " + $Arguments

}
Write-Verbose "Running Start-Process -FilePath msiexec.exe -ArgumentList $MSIArgs -NoNewWindow -Wait -Passthru"
$ReturnFromEXE = Start-Process -FilePath msiexec.exe -ArgumentList $MSIArgs -NoNewWindow -Wait -Passthru
Write-Verbose "Returncode is $($ReturnFromEXE.ExitCode)"
Return $ReturnFromEXE.ExitCode
}
Function Invoke-VIAMsu{
[CmdletBinding(SupportsShouldProcess=$true)]

param(
[parameter(mandatory=$true,position=0)]
[ValidateNotNullOrEmpty()]
[string]
$MSU,

[parameter(mandatory=$false,position=1)]
[string]
$Arguments
)

#Set MSIArgs
$MSUArgs = $MSU + " " + $Arguments

if($Arguments -eq "")
{
$MSUArgs = $MSU


}
else
{
$MSUArgs = $MSU + " " + $Arguments

}

Write-Verbose "Running Start-Process -FilePath wusa.exe -ArgumentList $MSUArgs -NoNewWindow -Wait -Passthru"
$ReturnFromEXE = Start-Process -FilePath wusa.exe -ArgumentList $MSUArgs -NoNewWindow -Wait -Passthru
Write-Verbose "Returncode is $($ReturnFromEXE.ExitCode)"
Return $ReturnFromEXE.ExitCode
}

# Set Vars
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$ScriptName = Split-Path -Leaf $MyInvocation.MyCommand.Path
Expand All @@ -17,19 +172,16 @@ $LANG = (Get-Culture).Name
$OSV = $Null
$ARCHITECTURE = $env:PROCESSOR_ARCHITECTURE

#Import function library
Import-Module "$ScriptDir\VIAInstall.psm1" -ErrorAction Stop -WarningAction Stop

#Try to Import SMSTSEnv
. Import-SMSTSENV
. Import-VIASMSTSENV

#Start Transcript Logging
. Start-Logging
. Start-VIALogging

#Detect current OS Version
. Get-OSVersion -osv ([ref]$osv)
. Get-VIAOSVersion -osv ([ref]$osv)

#Output base info
#Output more info
Write-Output ""
Write-Output "$ScriptName - ScriptDir: $ScriptDir"
Write-Output "$ScriptName - SourceRoot: $SOURCEROOT"
Expand All @@ -54,10 +206,11 @@ if($MDTIntegration -eq "YES"){
Write-Output "$ScriptName - OSDComputername: $TSOSDComputerName"
}


#Custom Code Starts--------------------------------------



#Custom Code Ends--------------------------------------

. Stop-Logging
. Stop-VIALogging
164 changes: 0 additions & 164 deletions Tools/Install-Wrapper/VIAInstall.psm1

This file was deleted.

0 comments on commit d988ab9

Please sign in to comment.