Forum Discussion

ADumith's avatar
ADumith
Iron Contributor
Dec 16, 2021
Solved

Working with functions

Hello everyone!

 

I have a script that has three processes and I want to create a function for each process and then from the same script call each function. Is that possible? How do I do it?

 

Example:

 

$computers=@('a','b','c','d','e')

ForEach ($pc in $computers)
{
ClossingApps -ComputerName $pc
RemovingApps -ComputerName $pc
InstallingApps -ComputerName $pc
}

function ClossingApps {
param (
$ComputerName
)

Write-Output "Closing"
}

function RemovingApps {
param (
$ComputerName
)
Write-Output "Removing"
}

function InstallingApps {
param (
$ComputerName
)
Write-Output "Installing"
}

 

Thank you

Resources