44 lines
1.2 KiB
PowerShell
44 lines
1.2 KiB
PowerShell
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 -SessionOption (New-PSSessionOption -NoMachineProfile) -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"
|
|
}
|
|
}
|
|
|
|
|