Is there a way to hide all the commands out puts and the popup windows of my script to format a USB disk.
I have used ( | Out-Null ) it help’t a little but it didn’t hide everything
Either should work, there are possibly ways to incorperate it into the PS Script itself, but i imagine it will pop up ever so briefly if this is the case.
Put it at the top of your Script, but you will briefly (a second) see a window appear, it’s probably the closest you are going to get to a hidden window.
Add-Type -Name win -MemberDefinition '[DllImport("user32.dll")] public static extern bool ShowWindow(int handle, int state);' -Namespace native
[native.win]::ShowWindow(([System.Diagnostics.Process]::GetCurrentProcess() | Get-Process).MainWindowHandle,0)
An empty pipe element is not allowed.
+ CategoryInfo : ParserError: ( [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : EmptyPipeElement
Now i didn’t get error message and i didn’t get windows popups, but the script didn’t work correctly, it deleted the partition and it didn’t create the new partition.