diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/write.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/write.cs index c372985ecb..3518eabc39 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/write.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/write.cs @@ -165,6 +165,7 @@ namespace Microsoft.PowerShell.Commands /// [Parameter(Position = 0, Mandatory = true, ValueFromPipeline = true)] [Alias("Msg", "Message")] + [AllowNull] public object MessageData { get; set; } /// diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Write-Stream.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Write-Stream.Tests.ps1 index d0520124f2..19c23d90e6 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Write-Stream.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Write-Stream.Tests.ps1 @@ -114,5 +114,12 @@ Describe "Stream writer tests" -Tags "CI" { $result.Count | Should -Be $returnCount (Compare-Object $result $returnValue -SyncWindow 0).length | Should -Be 0 } + + It "Write-Information accepts `$Null" { + $streamPath = Join-Path $testdrive information.txt + $null | Write-Information -Tags myTag -ErrorAction Stop -InformationAction SilentlyContinue -InformationVariable i + $i.Tags | Should -BeExactly "myTag" + $i.MessageData | Should -Be $null + } } }