RunPrograms/RunPrograms.psm1

<#
.SYNOPSIS
 
Gets the Processes that starts when the Computer starts.
 
.DESCRIPTION
 
The Get-LocalRuns cmdlet gets the Processes which running when the computer starts.
This Processes are Running over the System Level
 
.EXAMPLE
PS> Get-LocalRuns
 The Local Machine's Run :
  
 The Service : BtServer
 the Path is : "C:\Program Files (x86)\REALTEK\Realtek Bluetooth\BTServer.exe"
#>


Function Get-LocalRuns {    
    $x = Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\"
    
    $y = $x | gm | where -Property membertype -NE method
    
    $yt = $y | select -expandProperty name

    $data = $null
    $yy = $null
    $Count = 0
    while ($Count -ine $yt.Count){
    if (($yt[$Count] -Cnotlike "PS*") -eq "True")
    {
        [System.Array]$yy += $yt[$Count]
    }
    $Count++
    }

    $Count = 0
    while ($Count -ine $yy.Count){
    [System.Array]$data += Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\" | Get-ItemPropertyValue -Name $yy[$Count].ToString()
    $Count++
    }

    Write-Host " The Local Machine's Run : "
    $Count = 0
    while ($Count -ine $data.count) {
        
        Write-Host " "
        Write-Host " The Service : " $yy[$Count]
        Write-Host " the Path is : " $data[$count]
        $count++
    }
}

<#
.SYNOPSIS
 
Gets the Processes that starts when the Computer starts.
 
.DESCRIPTION
 
The Get-CurrentRuns cmdlet gets the Processes which running when the computer starts.
This Processes are Running over the Current User Level
 
.EXAMPLE
PS> Get-CurrentRuns
 The Current User Machine's Run :
  
 The Service : OneDrive
 the Path is : "C:\Users\Hp\AppData\Local\Microsoft\OneDrive\OneDrive.exe" /background
#>


Function Get-CurrentRuns {    
    $x = Get-ItemProperty "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\"
    
    $y = $x | gm | where -Property membertype -NE method
    
    $yt = $y | select -expandProperty name

    $data = $null
    $yy = $null
    $Count = 0
    while ($Count -ine $yt.Count){
    if (($yt[$Count] -Cnotlike "PS*") -eq "True")
    {
        [System.Array]$yy += $yt[$Count]
    }
    $Count++
    }

    $Count = 0
    while ($Count -ine $yy.Count){
    [System.Array]$data += Get-ItemProperty "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\" | Get-ItemPropertyValue -Name $yy[$Count].ToString()
    $Count++
    }

    Write-Host " The Current User Machine's Run : "
    $Count = 0
    while ($Count -ine $data.count) {
        
        Write-Host " "
        Write-Host " The Service : " $yy[$Count]
        Write-Host " the Path is : " $data[$count]
        $count++
    }
}