Hi,
I want to put this command Get-HotFix KB3133977,KB3123479 -ComputerName machine1,machine2 in a function ... I tried this but it didn't work:
function Get-KBUpdates
{
param (
[string]$machines,
[string]$updates
)
$machines = Get-Content "c:\machines.txt"
$updates = Get-Content "c:\kbupdates.txt"
}
Get-HotFix $updates -ComputerName $machines
Help with function
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: Help with function
You are never calling your function and the "Get-HoFix" is not inside the function.
Start by reviewing this: https://technet.microsoft.com/en-us/lib ... 47829.aspx
Start by reviewing this: https://technet.microsoft.com/en-us/lib ... 47829.aspx
- dan.potter
- Posts: 709
- Last visit: Wed Nov 14, 2018 11:39 am
Re: Help with function
you have it backwards, array of machines goes outside the function. get-hotfix goes inside the function.ipessa100 wrote:Hi,
I want to put this command Get-HotFix KB3133977,KB3123479 -ComputerName machine1,machine2 in a function ... I tried this but it didn't work:
function Get-KBUpdates
{
param (
[string]$machines,
[string]$updates
)
$machines = Get-Content "c:\machines.txt"
$updates = Get-Content "c:\kbupdates.txt"
}
Get-HotFix $updates -ComputerName $machines
Play with this.
function Get-KBUpdates
{
param($computername)
get-hotfix... $computername
}
Get-KBUpdates $machines