I am running a PowerShell script with around 10,000 lines of code, and I noticed that Event ID 4104 is being generated during the execution. In each Event ID 4104 entry, I see the following message:
"Creating Scriptblock text (12 of 12): ..."
I have a few questions regarding this:
What is a Scriptblock in PowerShell? I understand that PowerShell executes code within Scriptblocks, but I'm not entirely sure about the detailed working and purpose of a Scriptblock. Can someone clarify this?
What is the basis for the Scriptblock being divided into "12"? I’m seeing "Creating Scriptblock text (12 of 12)" in the event. How are Scriptblocks divided into multiple parts, and why is it showing "12" here? Does it refer to the number of segments in the script or something else?
What is the maximum size of a Scriptblock in PowerShell? Is there any limit to the size of a Scriptblock, and if so, what’s the maximum allowed size? Is this related to the division into parts?