Friday, October 10, 2025
HomePowershellPerform can't be created as a result of operate capability 4096 has...

Perform can’t be created as a result of operate capability 4096 has been exceeded for this scope


It appears Home windows PowerShell has few built-in variables that outline what number of capabilities, aliases, and variables you may have earlier than stopping you from utilizing extra. You may confirm this with helpful command Get-Variable Max*Depend.

As you may see above, Aliases, Drives, Errors, Capabilities, Historical past, and Variables all have their most values set. After so a few years I’ve spent utilizing PowerShell, I’ve by no means exceeded these values. I assume it is the primary time for the whole lot. Happily, it is a straightforward repair. We have to change most values to one thing sane.

$MaximumFunctionCount = 8192
$MaximumVariableCount = 8192

After utilizing these two traces of code earlier than working my time-consuming report – my issues have been NOT solved! After investigation, I noticed that I used to be connecting to Trade which triggers imports of instructions contained in the module scope and never as a part of the International scope. This implies I want to alter it as a part of the module and ensure to focus on the Script scope.

if ($PSVersionTable.PSEdition -eq 'Desktop') {
    $Script:MaximumFunctionCount = 18000
    $Script:MaximumVariableCount = 18000
}
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments