PS2EXE and Active Directory Integration

2019-09-10 17:47发布

So I've tried wrapping one of my scripts into an exe using PS2EXE, and it works great! But for some reason, when using AD functions, it gives me a whole bunch of background text which makes interacting with the script nearly impossible! See the pictures below:

I've done my research, and have only found one other forum where anybody had this issue, and there was no resolution. This only seems to happen when using AD functions, and after importing the AD Module. I've tried resetting all of my error and warning action preferences and it does not affect this in any way. I think it's just informative, but it makes it difficult to see the text requiring acknowledgement or input unless I go back and change the foreground color on all of my write-host text.

Has anybody seen this before, or have any ideas on how to suppress the informative output?

Thanks!

1条回答
Emotional °昔
2楼-- · 2019-09-10 18:13

I am not familiar with PS2EXE but looking at the screenshot, I think it's echoing data from the progress stream. Two things I would recommend:

  1. If you're not using the AD drive (AD:> in PowerShell), disable it. It takes forever to load and that's what's generating the stuff on the screen. Put this line at the top of your script to do so:

$Env:ADPS_LoadDefaultDrive = 0

  1. You can hide progress info in general in your script by adding this line:

$ProgressPreference = SilentlyContinue

查看更多
登录 后发表回答