My setup:
One Powershell script with a menu. Upon selecting a a menu item, a specific Powershell script is run assigned to that menu item. I'm attempting to make this second Powershell script run silently as in - nothing is shown in the main Powershell script.
Bonus: The full setup I'm looking at is:
- User runs Powershell script
- User selects a menu item (this executes another Powershell script)
- The information in the other Powershell script is not shown to the user
- After the second Powershell script has been executed, the user is shown a line of text such as: "Script has been run successfully"
What I've tried: Adding the following code to each secondary script
$t = '[DllImport("user32.dll")] public static extern bool ShowWindow(int handle, int state);'
add-type -name win -member $t -namespace native
[native.win]::ShowWindow(([System.Diagnostics.Process]::GetCurrentProcess() | Get-Process).MainWindowHandle, 0)
Unfortunately this closes the main Powershell window which isn't what I desire.