Get-WeightData.ps1

function Get-WeightData {
<#
.SYNOPSIS
    
.DESCRIPTION
   Long description
.EXAMPLE
     
.FUNCTIONALITY
    
 
#>


   [Alias('Wget')]
   [CmdletBinding(
        DefaultParameterSetName = 'ParameterName'
    )]

   param (

        [Parameter( 
            Mandatory=$true,
            ValueFromPipeline=$true,
            Position = 0
        )]
        [SupportsWildcards()]
        [string] $Week 
        )
        
   try{
           
      $OutputData = Import-Csv -Path $env:HOMEDRIVE\Users\$env:USERNAME\Desktop\TESTTESTTEST.csv 
      
  
   if ($Week -eq '*'){

      Write-Verbose -Message "Gathering data from all weeks"
      $OutputData | Where-Object -Property 'Week' | Format-Table -Property Date, Week, Weight, Bodyfat, Hydration, Muscle -ErrorAction Stop
      Write-Verbose -Message "Gathered data from all weeks and presented it to the user"
}
   else {

      Write-Verbose -Message "Gathering data from week$($Week)"
      $OutputData | Where-Object -Property 'Week' -EQ $Week | Format-Table -Property Date, Week, Weight, Bodyfat, Hydration, Muscle -ErrorAction Stop
      Write-Verbose -Message "Gathered data from week$($Week) and presented it to the user"
}
   if ($Week -notin $OutputData.week) {
      
      Write-Warning "Cannot get the data for 'Week$($Week)', beacuse the specified week does not exist" 
}
}
   catch  {
  
      Write-Error "Cannot get the data for week$($Week), beacuse the specified week does not exist" 
           
}
       
       
}       




# random'{0:2N}' -f $OutputData
# Kanske till compare : Compare-Object -ReferenceObject $userinput -DifferenseObject $Userinput2