cEPRSRenameFile.psm1

enum Ensure
{
  Absent
  Present
  
}

[DscResource()]
class cEPRSRenameFile 
{
    [DscProperty(Key)] [String] $FilePath
    [DscProperty(Key)] [String] $OldFileName
    [DscProperty(Key)] [String] $NewFileName


  [cEPRSRenameFile] Get()
  {
     $Output = @{
                   FilePath = $this.FilePath
                   OldFileName = $this.OldFileName
                   NewFileName = $this.NewFileName
             
                }

                return $Output
   
  }

  [bool] Test()
  {
        if(Test-Path -isvalid "$($this.FilePath)\$($this.OldFileName)")
        {
         $result = $false
        }
        else
        {
          Write-Verbose "Specified file path does not exists. please pass valid file name and path"
          $result = $true
        }

        return $result
  }

  [void] Set()
  {
      try
      {
        Write-Verbose "Rename the file $($this.OldFileName) with $($this.NewFileName)."
        Rename-Item -Path "$($this.FilePath)\$($this.OldFileName)" -NewName "$($this.NewFileName)"
      }
      catch [System.Exception]
      {
        Write-Verbose $_.exception.message
      }
  }
  
}