Posted On March 29, 2019

How to Call Functions or Pass Function as Argument

kimconnect 0 comments
blog.KimConnect.com >> Codes >> How to Call Functions or Pass Function as Argument
cls
 
function listClusters{
    # List all Clusters in this Domain
    $items=get-cluster -domain (get-addomain)
    $global:clusters=$items
}
 
function show{
    Param($callFunction)
    invoke-command (Get-Item “function:$callFunction”).ScriptBlock
    if ($clusters){$count=$clusters.count; $global:list=$clusters; $global:nodes=””}
    if ($nodes){$count=$nodes.count; $global:list=$nodes}
    
    $show=”`n————————————————–`n    There are $count items in this Collection: `n————————————————–`n”
        for ($row=0;$row -le $count-1;$row++){
            $server=$list[$row]
            $show += “$row”  + “: ” + “$server” + “`n”
            }                
    return $show
}
 
show -callFunction listClusters

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

PowerShell: Execute as System Elevated Session with a Domain Administrator account

Part 1: Relaunch script in the context of Elevated System privileges: ############# Ensure that Program…

PowerShell: Download Dot Net 4.7.2

# Illustration: download Dot Net 4.7 Run-time from behind a proxy and showing progress barfunction…

The 5 Rules of Thumb of Business Presentation (To Attract Investors)

I'm noting this here so that I can revisit these bullet points in the future...…
Other project: DragonCoin.com