Link to home
Create AccountLog in
Powershell

Powershell

--

Questions

--

Followers

Top Experts

Avatar of David Johnson, CD
David Johnson, CD🇨🇦

clear-host doesn't close Write-Progress
here is my Powershell default configuration in which I set up my PowerShell ise.. while it is adding in the modules I have a progress bar running lines 23-26 and after they are loaded I do a clear-host in line 41 which should close the progress bar.. but User generated image
$time = Get-Date 
$user = get-content env:username
Write-Output ( 'Hi, '+ $user +' Welcome Back! It is now '+$time)
$mydocuments = [environment]::getfolderpath('mydocuments')
$mytemp = '$mydocuments\windowsPowerShell\ScriptScratch'
$mydoc = $mydocuments + '\WindowsPowerShell\Scripts\'
Set-Variable -name HOME -value $mydoc -Force
write-output('Enumerating Modules')
$modules = get-module -listavailable
Write-Output ('There are ' + {0} + ' Available' -f $modules.count)
$modules.name
Write-Output ('Hang on While I import modules')
Write-Output ('Importing ' + {0} +' Modules' -f $modules.Count)
if ([System.Windows.Input.Keyboard]::IsKeyDown('Ctrl') -eq $false)
{
 
$counter = 0
foreach ($module in $modules) 
    { 
    $counter ++
    $total = $modules.Count
    $activity = "Importing Module: $module.name "
    Write-Progress -Activity $activity `
        -status "Module: $counter of $total" `
        -percentComplete ($counter / $modules.count*100)
    import-module -name $module.Name -erroraction SilentlyContinue -WarningAction SilentlyContinue
    }
#
  Start-Steroids
}
#Leave any comments with the # sign
#Install Quest Active Directory CMDLets
Write-Output 'Installing Quest Active Directory Tools.  Please wait...'
Add-PSSnapin Quest.ActiveRoles.ADManagement -ErrorAction SilentlyContinue
Write-Output 'Installing Exchange Management Tools.  Please wait...'
Add-PSSnapin Microsoft.Exchange.Management.Powershell.Admin -ErrorAction SilentlyContinue
Write-Output 'Installing MDT Tools... Please wait..'
Add-PSSnapIn Microsoft.BDD.PSSnapIn -ErrorAction SilentlyContinue
Write-Output 'Installing TFS Tools... Please wait..'
Add-PSSnapin Microsoft.TeamFoundation.PowerShell -ErrorAction Continue
Clear-Host
#TFS only on Windows 10
$version = get-wmiobject -class win32_operatingSystem | select-object version
if ($version.version -gt '10.0.0') {
    get-tfsserver -Name 'http://localhost:8080/tfs/Windows Powershell'
    #Script Browser Begin
    #Version: 1.3.2
    Add-Type -Path 'C:\Program Files (x86)\Microsoft Corporation\Microsoft Script Browser\System.Windows.Interactivity.dll'
    Add-Type -Path 'C:\Program Files (x86)\Microsoft Corporation\Microsoft Script Browser\ScriptBrowser.dll'
    Add-Type -Path 'C:\Program Files (x86)\Microsoft Corporation\Microsoft Script Browser\BestPractices.dll'
    $scriptBrowser = $psISE.CurrentPowerShellTab.VerticalAddOnTools.Add('Script Browser', [ScriptExplorer.Views.MainView], $true)
    $scriptAnalyzer = $psISE.CurrentPowerShellTab.VerticalAddOnTools.Add('Script Analyzer', [BestPractices.Views.BestPracticesView], $true)
    $psISE.CurrentPowerShellTab.VisibleVerticalAddOnTools.SelectedAddOnTool = $scriptBrowser
    #Script Browser End
    }
$time2 = Get-Date
$time3 = $time2 - $time
Write-Output ('It took  ' + $time3.Minutes.ToString() + ' Minutes and ' + $time3.seconds.ToString() + ' Seconds to load the '+ $modules.Count + ' Modules')
Write-Output ('The Current Time is:' +$time2)
cd $mydoc

Open in new window

Zero AI Policy

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


ASKER CERTIFIED SOLUTION
Avatar of oBdAoBdA

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
Create Account

Avatar of David Johnson, CDDavid Johnson, CD🇨🇦

ASKER

Thank you, I didn't know about that and it was bugging me for a while

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.

Powershell

Powershell

--

Questions

--

Followers

Top Experts

Windows PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language built on the .NET Framework. PowerShell provides full access to the Component Object Model (COM) and Windows Management Instrumentation (WMI), enabling administrators to perform administrative tasks on both local and remote Windows systems as well as WS-Management and Common Information Model (CIM) enabling management of remote Linux systems and network devices.