Created
April 28, 2022 17:48
-
-
Save AF250329/9b01b47771bffbe1a88ef05166b3893b to your computer and use it in GitHub Desktop.
Start-Job: Call another functions in a script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Base-Function { | |
PARAM( | |
[string] | |
$PathToFile | |
) | |
if (Test-Path -Path $PathToFile) { | |
Write-Host "Exist" | |
} | |
} | |
function CopyFile { | |
PARAM( | |
[string] | |
$SourcePath, | |
[string] | |
$TargetPath | |
) | |
Base-Function -PathToFile $SourcePath | |
Base-Function -PathToFile $TargetPath | |
Write-Host "I will copy file from $SourcePath to $TargetPath" | |
} | |
function Main-Function { | |
$copyFileArgs = @{ | |
"SourcePath" = "C:\Windows\notepad.exe" | |
"TargetPath" = "C:\Temp\notepad.exe" | |
} | |
Start-Job -ScriptBlock ${Function:CopyFile} -ArgumentList $copyFileArgs | |
} | |
Main-Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment