Hey everyone,
We are looking to add on some additional functionality to our AfterModify PS script but we keep running into this error now.
Exception:System.InvalidOperationException: The environment block used to start a process cannot be longer than 65535 bytes. Your environment block is 87811 bytes long. Remove some environment variables and try again.
at System.Diagnostics.EnvironmentBlock.ToByteArray(StringDictionary sd, Boolean unicode)
at System.CodeDom.Compiler.Executor.ExecWaitWithCaptureUnimpersonated(SafeUserTokenHandle userToken, String cmd, String currentDir, TempFileCollection tempFiles, String& outputName, String& errorName, String trueCmdLine)
at System.CodeDom.Compiler.Executor.ExecWaitWithCapture(SafeUserTokenHandle userToken, String cmd, String currentDir, TempFileCollection tempFiles, String& outputName, String& errorName, String trueCmdLine)
at Microsoft.CSharp.CSharpCodeGenerator.Compile(CompilerParameters options, String compilerDirectory, String compilerExe, String arguments, String& outputFile, Int32& nativeReturnValue, String trueArgs)
at Microsoft.CSharp.CSharpCodeGenerator.FromFileBatch(CompilerParameters options, String[] fileNames)
at Microsoft.CSharp.CSharpCodeGenerator.FromSourceBatch(CompilerParameters options, String[] sources)
at Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromSourceBatch(CompilerParameters options, String[] sources)
at Microsoft.PowerShell.Commands.NewWebServiceProxy.GenerateWebServiceProxyAssembly(String NameSpace, String ClassName)
at Microsoft.PowerShell.Commands.NewWebServiceProxy.BeginProcessing()
at System.Management.Automation.Cmdlet.DoBeginProcessing()
at System.Management.Automation.CommandProcessorBase.DoBegin()
2024-12-06 08:09:45 Exception Type:System.InvalidOperationException
2024-12-06 08:09:45 Error Message:The environment block used to start a process cannot be longer than 65535 bytes. Your environment block is 87811 bytes long. Remove some environment variables and try again.
2024-12-06 08:09:45 Stack Trace: at System.Diagnostics.EnvironmentBlock.ToByteArray(StringDictionary sd, Boolean unicode)
at System.CodeDom.Compiler.Executor.ExecWaitWithCaptureUnimpersonated(SafeUserTokenHandle userToken, String cmd, String currentDir, TempFileCollection tempFiles, String& outputName, String& errorName, String trueCmdLine)
at System.CodeDom.Compiler.Executor.ExecWaitWithCapture(SafeUserTokenHandle userToken, String cmd, String currentDir, TempFileCollection tempFiles, String& outputName, String& errorName, String trueCmdLine)
at Microsoft.CSharp.CSharpCodeGenerator.Compile(CompilerParameters options, String compilerDirectory, String compilerExe, String arguments, String& outputFile, Int32& nativeReturnValue, String trueArgs)
at Microsoft.CSharp.CSharpCodeGenerator.FromFileBatch(CompilerParameters options, String[] fileNames)
at Microsoft.CSharp.CSharpCodeGenerator.FromSourceBatch(CompilerParameters options, String[] sources)
at Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromSourceBatch(CompilerParameters options, String[] sources)
at Microsoft.PowerShell.Commands.NewWebServiceProxy.GenerateWebServiceProxyAssembly(String NameSpace, String ClassName)
at Microsoft.PowerShell.Commands.NewWebServiceProxy.BeginProcessing()
at System.Management.Automation.Cmdlet.DoBeginProcessing()
at System.Management.Automation.CommandProcessorBase.DoBegin()
The only other post I could fine was this one, which points to a .NET limitation, but it unfortunately didn’t have a solution.
We identified the cmdlet that seems to be causing this issue to occur and it is New-WebServiceProxy
. When we invoke this cmdlet, the response from the WS is quite large and that seems to be what is causing the environment block to get too large, but I am not sure how to reduce it for subsequent operations.
For some additional context, we are trying to call the IBM ITIM Web Services (SOAP) API to disable accounts upon termination. There is a REST API, but this doesn’t offer the functionality we need (disabling accounts). We might be able to build an ISC Web Services connector, but we were just looking to at least cover account disablements through this script since we already had the PS script.
Has anybody else run into this error before with the IQService or have any thoughts on how to fix/avoid it?
Thank you,
- Zach