Functions/Install-Patches.ps1
|
function Install-Patches { <# .SYNOPSIS Will install patches in the local patches folder. .DESCRIPTION Installes patches in the LocalPatches config setting path (default is C:\Patches.) .PARAMETER ComputerName Specifies the name of one or more computers to install patches on. .EXAMPLE C:\PS>Install-Patches Will install patches in the LocalPatches config setting path (default is C:\Patches.) .EXAMPLE C:\PS>Install-Patches -ComputerName COMP1,COMP2 Will install patches in the LocalPatches config setting path (default is C:\Patches) on COMP1 and COMP2. .NOTES Author: Skyler Hart Created: 2017-03-25 08:30:23 Last Edit: 2021-08-12 00:36:14 Keywords: Requires: -RunAsAdministrator .LINK https://wanderingstag.github.io #> [Diagnostics.CodeAnalysis.SuppressMessageAttribute( "PSUseSingularNouns", "", Justification = "Expresses exactly what the function does." )] [Diagnostics.CodeAnalysis.SuppressMessageAttribute( "PSAvoidGlobalVars", "", Justification = "Have tried other methods and they do not work consistently." )] [CmdletBinding()] [Alias('Install-Updates')] Param ( [Parameter( Mandatory=$false, Position=0 )] [Alias('Host','Name','Computer','CN')] [string[]]$ComputerName = "$env:COMPUTERNAME" ) $config = $Global:WSToolsConfig $Patches = $config.LocalPatches $fp = $PSScriptRoot.Substring(0,($PSScriptRoot.Length-15)) + "\InstallRemote.ps1" if ($ComputerName -eq $env:COMPUTERNAME) { Copy-Item -Path $fp -Destination $Patches & "$Patches\InstallRemote.ps1" } else { Invoke-Command -ComputerName $ComputerName -FilePath $fp -ErrorAction Stop #DevSkim: ignore DS104456 } }#install patches |