Get-PC/Private/InstallNet35.ps1

44 lines
1.2 KiB
PowerShell
Raw Normal View History

2024-06-11 18:27:55 +00:00
function Get-InstallNet35 {
<#
.SYNOPSIS
This function takes a hostname and silently installs .Net 3.5 on target computer
.DESCRIPTION
Use this function to install .Net 3.5 onto a remote computer without interrupting the user.
Function has been connected to Get-PC and can be run with Get-PC Hostname -InstallNet35
.NOTES
Version: 1.0
Author: Jake Castadio
Creation Date: 1/16/2023
Purpose/Change: Created to assist with legacy app installs
.Example
Get-PC AEPIS00000 -InstallNet35
#>
[CmdletBinding()]
param (
[Parameter(Mandatory)]
[string]$HostName
)
if(Test-Connection -ComputerName $HostName -Count 1) {
Invoke-Command -ComputerName $HostName -ScriptBlock {
Enable-WindowsOptionalFeature -Online -FeatureName NetFx3 -Source \\shscm01\packages\Microsoft\dotNet\3.5 -LimitAccess -All
} -AsJob -JobName installNet
Wait-Job -Name installNet
Remove-Job -Name installNet
} else {
Write-Host "Unable to enable .Net 3.5, workstation may be offline"
}
}