Skip to main content
deleted 1 character in body
Source Link
RiverHeart
  • 1.1k
  • 12
  • 21

Odd you're the only person who seems to have noticed this issue.

I ran into this while calling one script from another in Powershell ISE. The script I was calling had $ErrorActionPreference = 'Stop' defined inside but whatwas ignored.

I tried to find source code online and failing to do so I went to look at the module files in C:\Windows\System32\WindowsPowerShell\v1.0\Modules\SmbShare and discovered that New-SmbShare and family are CIM-based Cmdlet Definition XML (CDXML) cmdlets (that I'd not heard of before).

After looking into it, it seems to be an issue of variable scoping with certain"script" modules. The functions of the module can't see $ErrorActionPreference. Setting $Global:ErrorActionPreference = 'Stop' gives the correct behavior as does setting -ErrorAction Stop directly on the cmdlet.

I believe this thread represents the ongoing discussion of the issue.

Odd you're the only person who seems to have noticed this issue.

I ran into this while calling one script from another in Powershell ISE. The script I was calling had $ErrorActionPreference = 'Stop' defined inside but what ignored.

I tried to find source code online and failing to do so I went to look at the module files in C:\Windows\System32\WindowsPowerShell\v1.0\Modules\SmbShare and discovered that New-SmbShare and family are CIM-based Cmdlet Definition XML (CDXML) cmdlets (that I'd not heard of before).

After looking into it, it seems to be an issue of variable scoping with certain modules. Setting $Global:ErrorActionPreference = 'Stop' gives the correct behavior as does setting -ErrorAction Stop directly on the cmdlet.

I believe this thread represents the ongoing discussion of the issue.

Odd you're the only person who seems to have noticed this issue.

I ran into this while calling one script from another in Powershell ISE. The script I was calling had $ErrorActionPreference = 'Stop' defined inside but was ignored.

I tried to find source code online and failing to do so I went to look at the module files in C:\Windows\System32\WindowsPowerShell\v1.0\Modules\SmbShare and discovered that New-SmbShare and family are CIM-based Cmdlet Definition XML (CDXML) cmdlets (that I'd not heard of before).

After looking into it, it seems to be an issue of variable scoping with "script" modules. The functions of the module can't see $ErrorActionPreference. Setting $Global:ErrorActionPreference = 'Stop' gives the correct behavior as does setting -ErrorAction Stop directly on the cmdlet.

I believe this thread represents the ongoing discussion of the issue.

Source Link
RiverHeart
  • 1.1k
  • 12
  • 21

Odd you're the only person who seems to have noticed this issue.

I ran into this while calling one script from another in Powershell ISE. The script I was calling had $ErrorActionPreference = 'Stop' defined inside but what ignored.

I tried to find source code online and failing to do so I went to look at the module files in C:\Windows\System32\WindowsPowerShell\v1.0\Modules\SmbShare and discovered that New-SmbShare and family are CIM-based Cmdlet Definition XML (CDXML) cmdlets (that I'd not heard of before).

After looking into it, it seems to be an issue of variable scoping with certain modules. Setting $Global:ErrorActionPreference = 'Stop' gives the correct behavior as does setting -ErrorAction Stop directly on the cmdlet.

I believe this thread represents the ongoing discussion of the issue.