0

I've a need to change the "DisableFormatUpdates" session state value within my powershell. I've figured out how to retrieve the initial session state:

[System.Management.Automation.Runspaces.Runspace]::DefaultRunspace.InitialSessionState

DisableFormatUpdates : True

Which returns the value as expected.

However I don't understand how to set this value to False, so that I can complete an import of a module. It appears that the runspace is being set by SMA, but I need to reset this value for a module that we're required to load.

Any help would be appreciated, as I'm definitely out of my element on setting this within the context of my powershell workflow.

Falcones
  • 109
  • 1
  • 5
  • 15

1 Answers1

0

Create the sessionstate object and then set the property to $true or $false

PS C:\> $sessionstate = [system.management.automation.runspaces.initialsessionstate]::CreateDefault()
PS C:\> $sessionstate.DisableFormatUpdates = $true
PS C:\> $sessionstate.DisableFormatUpdates
True
PS C:\> $sessionstate.DisableFormatUpdates = $false
PS C:\> $sessionstate.DisableFormatUpdates
False
brendan62269
  • 1,046
  • 1
  • 9
  • 12
  • 1
    Thank you sir! I did in fact figure this out after much annoyance. I assumed it had to be a boolean set in C# to set the value and I was wrong. Much appreciated! – Falcones Sep 12 '17 at 19:18