I need to define a container in powershell which cannot be modify able once it is created. I know there is a way, by which variables can be created as hidden in current run space but still somehow that is also not safe for my problem.
I want to create some write protected and hidden variable in such a way, once it is initialised, it shouldn't be replaceable. I would like to have dictionary that shouldn't be replaced. It have values those must be added within it but dictionary instance itself should be replaceable itself.
SessionState.PSVariable.Set(new PSVariable(paramContainerName, new Dictionary<string, PSObject>(), ScopedItemOptions.Private | ScopedItemOptions.ReadOnly))
Above can easily be replaced. Somebody can replace above dictionary by
$paramContainerName = [] in the powershell script or at terminal. Is there any way by which we can stop this.