Function ported from Powershell 5 to Powershell 7 fails with “object reference not set to an instance of an object”

前端 未结 1 766
失恋的感觉
失恋的感觉 2021-01-29 03:48

Following code works as expected in powershell 5.1:

function Get-Say([String] $Message, [String] $Voice = "Microsoft Irina Desktop") {
    Add-Type -Ass         


        
相关标签:
1条回答
  • 2021-01-29 04:25

    This is a known issue and is due to the fact that some of the functionality required is not present in .NET Core, which PS v7 is built on. Looks like a bug was raised but it was closed without a fix:

    System.Speech.Synthesis.SpeechSynthesizer Speak method throws Object reference not set to an instance of an object." in PowerShell 6.1.2

    0 讨论(0)
提交回复
热议问题