You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Get's the functions called in a script and the the file containing those definitions
5
+
6
+
.DESCRIPTION
7
+
8
+
9
+
.PARAMETERFunctionName
10
+
The root function name you're wanting to process
11
+
12
+
.PARAMETERFunctionPaths
13
+
An object linking a function's name to the the file containing it's definition.
14
+
Is built by the first call, and then passed to later calls.
15
+
16
+
.PARAMETERModulePath
17
+
Path to the root of the powershell module you're analyzing
18
+
19
+
.PARAMETERDepth
20
+
How deep to recurse into the function calls.
21
+
Default is 1. This will just load the functions called within the first function. Higher numbers increase the level of recurions, increasing the number of function definitions retrieved, and slowing down the Chronometer run
22
+
0 - Will only load the definition of the root function
Will scan all the ps1 files in c:\dbatools\Module for function definitions, and then will scan the definition of
33
+
Restore-DbaDatabase for function calls. As depth is set to 1, it will then add the definitions of those called functions
34
+
from within the module to the Chronometer path. Higher depth values will scan for the definition of functions called in
35
+
the next tier of functions recursively.
36
+
37
+
.NOTES
38
+
Original Author: Stuart Moore (@napalmgram), https://stuart-moore.com
39
+
Source tracked at https://github.com/Stuart-Moore/VariousHelperFunctions/blob/master/Get-FunctionCalls.ps1
40
+
Written as a helper function to Kevin Marquette's Chronometer module (https://github.com/KevinMarquette/Chronometer)
41
+
42
+
This parses the function to be analysed for it's definition and other functions it calls, so that an entire
43
+
stack can be monitored without needin to manually build up the path or adding every file in the module and
44
+
killing performance
45
+
46
+
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
47
+
48
+
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
49
+
50
+
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
51
+
#>
52
+
[CmdletBinding()]
53
+
param (
54
+
[string[]]$FunctionName,
55
+
[object[]]$FunctionPaths,
56
+
[String]$ModulePath,
57
+
[int]$depth=1
58
+
)
59
+
if ($FunctionPaths-eq$null)
60
+
{
61
+
Write-Verbose"$FunctionName - Need to populate the paths to Function calls"
0 commit comments