powershell
sethayes
·
step02
·
Powershell
·
Total Size: 4.74 KB
·
·
Created: 5 years ago
·
Edited: 5 years ago
[bool]$restart = $false
$Log = "C:\Users\Public\Log.txt"
filter timestamp {"$Get-Date -Format G) | $_"}
Function InstallNET45andWMF5 {
$os = (Get-WmiObject Win32_OperatingSystem).Version
$bit = (Get-WmiObject Win32_OperatingSystem).OSArchitecture
$wmf = $PSVersionTable.PSVersion.Major
$net = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full" -Name Release).Release
Function Install-NET45 {
(New-Object System.Net.WebClient).DownloadFile("https://lt.msinetworks.com/labtech/Transfer/Utilities/dotnetfx45_full_x86_x64.exe","C:\Users\Public\dotNET.exe")
cmd.exe /c "C:\Users\Public\dotNET.exe /q /norestart"
Write-Output ".NET 4.5 Has Been Installed" | timestamp
Write-Output ".NET 4.5 Has Been Installed" | timestamp | Out-File $Log -Append
}
Function Install-WMFx86 {
If ($os -like "6.1.7*") {
(New-Object System.Net.WebClient).DownloadFile("https://lt.msinetworks.com/labtech/Transfer/Utilities/WMF/5.0/Win7-KB3134760-x86.msu","C:\Users\Public\WMF5.msu")
cmd.exe /c "wusa.exe C:\Users\Public\WMF5.msu /quiet /norestart"
[bool]$restart = $true
Write-Output "WMF 5.0 Has Been Installed" | timestamp
Write-Output "WMF 5.0 Has Been Installed" | timestamp | Out-File $Log -Append
}
}
Function Install-WMFx64 {
If ($os -like "6.1.7*") {
(New-Object System.Net.WebClient).DownloadFile("https://lt.msinetworks.com/labtech/Transfer/Utilites/WMF/5.0/Win7AndW2K8R2-KB3134760-x64.msu","C:\Users\Public\WMF5.msu")
cmd.exe /c "wusa.exe C:\Users\Public\WMF5.msu /quiet /norestart"
[bool]$restart = $true
Write-Output "WMF 5.0 Has Been Installed" | timestamp
Write-Output "WMF 5.0 Has Been Installed" | timestamp | Out-File $Log -Append
}
ElseIf ($os -like "6.3.9*") {
(New-Object System.Net.WebClient).DownloadFile("https://lt.msinetworks.com/labtech/Transfer/Utilites/WMF/5.0/Win8.1AndW2K12R2-KB3134758-x64.msu","C:\Users\Public\WMF5.msu")
cmd.exe /c "wusa.exe C:\Users\Public\WMF5.msu /quiet /norestart"
[bool]$restart = $true
Write-Output "WMF 5.0 Has Been Installed" | timestamp
Write-Output "WMF 5.0 Has Been Installed" | timestamp | Out-File $Log -Append
}
}
If ($wmf -ge "5") {
Write-Output "PowerShell 5.0 or Better Already Installed" | timestamp
Write-Output "PowerShell 5.0 or Better Already Installed" | timestamp | Out-File $Log -Append
}
ElseIf ($net -lt "378389") {
Write-Output ".NET Framework 4.5 or Better NOT Detected. Installing Now..." | timestamp
Write-Output ".NET Framework 4.5 or Better NOT Detected. Installing Now..." | timestamp | Out-File $Log -Append
Install-NET45 | Out-File $Log -Append
If ($bit -eq "32-bit") {
Write-Output ".NET Framework 4.5 or Better Detected, but WMF/PowerShell 5.0 is NOT. Installing Now..." | timestamp
Write-Output ".NET Framework 4.5 or Better Detected, but WMF/PowerShell 5.0 is NOT. Installing Now..." | timestamp | Out-File $Log -Append
Install-WMFx86
}
Else {
Write-Output ".NET Framework 4.5 or Better Detected, but WMF/PowerShell 5.0 is NOT. Installing Now..." | timestamp
Write-Output ".NET Framework 4.5 or Better Detected, but WMF/PowerShell 5.0 is NOT. Installing Now..." | timestamp | Out-File $Log -Append
Install-WMFx64
}
}
Else {
If ($bit -eq "32-bit") {
Write-Output ".NET Framework 4.5 or Better Detected, but WMF/PowerShell 5.0 is NOT. Installing Now..." | timestamp
Write-Output ".NET Framework 4.5 or Better Detected, but WMF/PowerShell 5.0 is NOT. Installing Now..." | timestamp | Out-File $Log -Append
Install-WMFx86
}
Else {
Write-Output ".NET Framework 4.5 or Better Detected, but WMF/PowerShell 5.0 is NOT. Installing Now..." | timestamp
Write-Output ".NET Framework 4.5 or Better Detected, but WMF/PowerShell 5.0 is NOT. Installing Now..." | timestamp | Out-File $Log -Append
Install-WMFx64
}
}
}
InstallNET45andWMF5
If ([bool]$restart) {
If (Test-Path C:\Users\Public\step03.ps1) {
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" -Name "ScriptStep" -Value "C:\Windows\System32\WindowsPowerShell\v1.0\Powershell.exe -File 'C:\Users\Public\step03.ps1'"
}
Restart-Computer -Force -Confirm:$false
}
Else {
If (Test-Path C:\Users\Public\step03.ps1) {
& "C:\Users\Public\step03.ps1"
}
}
1 bit
•
743 views
Are you sure you want to delete?