Hide powershell output

Option 1: Pipe it to Out-Null

New-Item -Path c:\temp\foo -ItemType Directory | Out-Null
Test-Path c:\temp\foo

Option 2: assign to $null (faster than option 1)

$null = New-Item -Path c:\temp\foo -ItemType Directory
Test-Path c:\temp\foo

Option 3: cast to [void] (also faster than option 1)

[void](New-Item -Path c:\temp\foo -ItemType Directory)
Test-Path c:\temp\foo

See also: What’s the better (cleaner) way to ignore output in PowerShell?

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)