# directory where my scripts are stored
$psdir="C:\Util"
Get-ChildItem "${psdir}\*.ps1"
Cd \util
get-service nscp
get-service teamviewer
$PSVersionTable.PSVersion
Write-Host "Welcome to Tom's Custom PowerShell Environment"
All works fine
Now I want to add this
Import-Module VMware.PowerCLI So it loads every time I start powershell
Since the import-module takes awhile to load I would like to put a progress bar on the screen
just as an aside: properly installed modules do autoload if needed since Powershell version 3.0. And even if you want to make sure a script does not run without a desired module you could use the #requires statement at the beginning of your script.
In your for loop the Import-Module command blocks anything else until it’s finished loading the module. Then it writes the Progress, continues with the next iteration of the loop and tries to import the module again. And again and again and again … and this 100 times.
You should have read the help for Import-Module completely. Then you’d know that you can use the parameter -Verbose to ask the cmdlet to show a progress.
Why don’t you click on the link I posted and read the documentation?
Tom … it cannot work this way at all … never.
You would need to offload the task of loading the module and parse the verbose output to get a progress bar. I’d recommend to save your energy for something really useful.