When I try to open PowerShell in my server it shows below error on loading:
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C :\Windows\System32\WindowsPowerShell\v1.0\types.ps1xml: The file was skipped because of the followin g validation exception: File C:\Windows\System32\WindowsPowerShell\v1.0\types.ps1xml cannot be loade d because its operation is blocked by software restriction policies, such as those created by using Group Policy.. Errors occurred while loading the format data file: Microsoft.PowerShell.Core, , C:\Windows\System32 \WindowsPowerShell\v1.0\DotNetTypes.format.ps1xml: The file was skipped because of the following val idation exception: File C:\Windows\System32\WindowsPowerShell\v1.0\DotNetTypes.format.ps1xml cannot be loaded because its operation is blocked by software restriction policies, such as those created b y using Group Policy.. Errors occurred while loading the format data file: Microsoft.PowerShell.Core, , C:\Windows\System32 \WindowsPowerShell\v1.0\FileSystem.format.ps1xml: The file was skipped because of the following vali dation exception: File C:\Windows\System32\WindowsPowerShell\v1.0\FileSystem.format.ps1xml cannot be loaded because its operation is blocked by software restriction policies, such as those created by using Group Policy.. Errors occurred while loading the format data file: Microsoft.PowerShell.Core, , C:\Windows\System32 \WindowsPowerShell\v1.0\PowerShellCore.format.ps1xml: The file was skipped because of the following validation exception: File C:\Windows\System32\WindowsPowerShell\v1.0\PowerShellCore.format.ps1xml c annot be loaded because its operation is blocked by software restriction policies, such as those cre ated by using Group Policy..
The 'set-variable' command was found in the module 'Microsoft.PowerShell.Utility', but the module could not be loaded.For more information, run 'Import-Module Microsoft.PowerShell.Utility'.At line:0 char:0
Rest of the logged in users are able to run scripts but i'm unable to.
When I try to run any cmdlet for example
write-host 'test'
I get an error like this
writeErrorStream : True Exception : System.Management.Automation.CommandNotFoundException: The 'write-host' command was found in the module 'Microsoft.PowerShell.Utility', but the module could not be loaded. For more information, run 'Import-Module Microsoft.PowerShell.Utility'. ---> System.Management.Automation.CmdletInvocationException: File C:\windows\system32\windowspowershell\v1.0\Modules\Microsoft.PowerShell.Utility\Microsoft.PowerShell.Utility.psm1 cannot be loaded because its operation is blocked by software restriction policies, such as those created by using Group Policy. ---> System.Management.Automation.PSSecurityException: File C:\windows\system32\windowspowershell\v1.0\Modules\Microsoft.PowerShell.Utility\Microsoft.PowerShell.Utility.psm1 cannot be loaded because its operation is blocked by software restriction policies, such as those created by using Group Policy. ---> System.UnauthorizedAccessException: File C:\windows\system32\windowspowershell\v1.0\Modules\Microsoft.PowerShell.Utility\Microsoft.PowerShell.Utility.psm1 cannot be loaded because its operation is blocked by software restriction policies, such as those created by using Group Policy. --- End of inner exception stack trace --- at System.Management.Automation.AuthorizationManager.ShouldRunInternal(CommandInfo commandInfo, CommandOrigin origin, PSHost host) at Microsoft.PowerShell.Commands.ModuleCmdletBase.GetScriptInfoForFile(String fileName, String& scriptName, Boolean checkExecutionPolicy) at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModule(PSModuleInfo parentModule, String fileName, String moduleBase, String prefix, SessionState ss, Object privateData, ImportModuleOptions& options, ManifestProcessingFlags manifestProcessingFlags, Boolean& found, Boolean& moduleFileFound) at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModuleNamedInManifest(PSModuleInfo parentModule, ModuleSpecification moduleSpecification, String moduleBase, Boolean searchModulePath, String prefix, SessionState ss, ImportModuleOptions options, ManifestProcessingFlags manifestProcessingFlags, Boolean loadTypesFiles, Boolean loadFormatFiles, Object privateData, Boolean& found, String shortModuleName) at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModuleManifest(String moduleManifestPath, ExternalScriptInfo scriptInfo, Hashtable data, Hashtable localizedData, ManifestProcessingFlags manifestProcessingFlags, Version version, Version requiredVersion, Nullable
1 requiredModuleGuid, ImportModuleOptions& options, Boolean& containedErrors) at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModuleManifest(ExternalScriptInfo scriptInfo, ManifestProcessingFlags manifestProcessingFlags, Version version, Version requiredVersion, Nullable
1 requiredModuleGuid, ImportModuleOptions& options) at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModule(PSModuleInfo parentModule, String fileName, String moduleBase, String prefix, SessionState ss, Object privateData, ImportModuleOptions& options, ManifestProcessingFlags manifestProcessingFlags, Boolean& found, Boolean& moduleFileFound) at Microsoft.PowerShell.Commands.ImportModuleCommand.ImportModule_LocallyViaName(ImportModuleOptions importModuleOptions, String name) at Microsoft.PowerShell.Commands.ImportModuleCommand.ProcessRecord() at System.Management.Automation.CommandProcessor.ProcessRecord() --- End of inner exception stack trace --- at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input) at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke) at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection1 input, PSDataCollection
1 output, PSInvocationSettings settings) at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection1 input, PSDataCollection
1 output, PSInvocationSettings settings) at System.Management.Automation.PowerShell.InvokeT at System.Management.Automation.CommandDiscovery.AutoloadSpecifiedModule(String moduleName, ExecutionContext context, SessionStateEntryVisibility visibility, Exception& exception) --- End of inner exception stack trace --- at System.Management.Automation.CommandDiscovery.TryModuleAutoDiscovery(String commandName, ExecutionContext context, String originalCommandName, CommandOrigin commandOrigin, SearchResolutionOptions searchResolutionOptions, CommandTypes commandTypes, Exception& lastError) at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandTypes commandTypes, SearchResolutionOptions searchResolutionOptions, CommandOrigin commandOrigin, ExecutionContext context) at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(String commandName, CommandOrigin commandOrigin, Nullable1 useLocalScope) at System.Management.Automation.ExecutionContext.CreateCommand(String command, Boolean dotSource) at System.Management.Automation.PipelineOps.AddCommand(PipelineProcessor pipe, CommandParameterInternal[] commandElements, CommandBaseAst commandBaseAst, CommandRedirection[] redirections, ExecutionContext context) at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext) at System.Management.Automation.Interpreter.ActionCallInstruction
6.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) TargetObject : write-host CategoryInfo : ObjectNotFound: (write-host:String) [], CommandNotFoundException FullyQualifiedErrorId : CouldNotAutoloadMatchingModule ErrorDetails
: InvocationInfo : System.Management.Automation.InvocationInfo ScriptStackTrace : at , : line 1 PipelineIterationInfo : {}
please suggest me a solution to overcome this error.
sfc /scannow
? that might help, as your system appears as good as dead – 4c74356b41