Posted On June 17, 2020

PowerShell: Encapsulating Function Inside a Function and Inside an Invoke-Command or Job

kimconnect 0 comments
blog.KimConnect.com >> Codes >> PowerShell: Encapsulating Function Inside a Function and Inside an Invoke-Command or Job
$domain='google.com'

function pingSomething($x){
    $result=ping $x
    function getTraceroute($y){
        pathping $y
    }
    $result+=getTraceroute $x
    return $result
}

$job=Start-Job -ScriptBlock {
    param($importedFunction,$params)
[ScriptBlock]::Create($importedFunction).invoke($params)
} -Args ${function:pingSomething},$domain
    
Wait-Job $job|out-null 
Receive-Job $job  

Leave a Reply

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

Related Post

Credit_Invoice_Reprints_ZZ6_7_8.bat

fsguiapp.exe -cm:\mfgsys\fs.cfg -iZZ1{TAB}y2k99{CR}bexe{ESC}zz6{CR}M:\cabsauto\timeout 15fsguiapp.exe -cm:\mfgsys\fs.cfg -iZZ2{TAB}y2k99{CR}bexe{ESC}zz7{CR}M:\cabsauto\timeout 15fsguiapp.exe -cm:\mfgsys\fs.cfg -iZZ3{TAB}y2k99{CR}bexe{ESC}zz8{CR}rem M:\cabsauto\timeout 15rem fsguiapp.exe -s -cm:\mfgsys\fs.cfg -iZZ4{TAB}y2k99{CR}bexe{ESC}zz4{CR}

RDP Gateway with MFA

Step 1: Install RDS Gateway   Prerequisites: 1. Enable Power Shell Remoting  2. SSL Certs…

PowerShell: Windows System Discovery – Deprecated

<# windows-localhost-discovery-v0.11.ps1 Purpose: scan the local or remote Windows machine for general system resources, security…
Other project: DragonCoin.com