WhereScape User Group – Thank you!

Thank you. Please find below the code.

#=====================================================
# Input variables 
#=====================================================
$ProjectName					= "Star Schema"															                          #The name of the WhereScape Red Project.
$WhereScapeRedEXE     = "C:\Program Files\WhereScape\RED\med.exe"                     #The program file can chnage every now and again.

#=====================================================  
# Control variables 
#=====================================================
$PS_STEP 						        = 100
$ODBCSource						      = ${env:WSL_META_DSN}                                         	#Sets the Data Warehouse ODBC
$DateStr 						        = Get-Date -format yyyyMMdd                                    	#Sets the current date
$DocumentationRootFolder		= "C:\Temp\WhereScapeREDDocumentation"				        #Root Folder of the Documentation Set --${env:WSL_WORKDIR}
$ProjectFolder					    = "$DocumentationRootFolder\$ProjectName"		                    #The name of the WhereScape Red Project 
$PS_STATUS                  = 0                                                             #Used to retun the status of the script
$RESULT_MSG                 = ""                                                            #Collects the results

$PS_STEP = 200
#Checks if the Root Folder exists, If not, creates it
if (-not (Test-Path -LiteralPath $DocumentationRootFolder)) {    
    TRY {
        New-Item -Path $DocumentationRootFolder -ItemType Directory -ErrorAction Stop | Out-Null #-Force
				$RESULT_MSG = -join($RESULT_MSG,"Successfully created directory '$DocumentationRootFolder'.")
    }
    CATCH {
        Write-Error -Message "Unable to create directory '$DocumentationRootFolder'. Error was: $_" -ErrorAction Stop
    } 
}

$PS_STEP = 250   
# Creates the Root Folder, Deletes if already exists
TRY {
  Remove-Item -Recurse -Force "$ProjectFolder" -ErrorAction Ignore
  New-Item -Path $ProjectFolder -ItemType Directory -ErrorAction Stop | Out-Null #-Force
	$RESULT_MSG = -join($RESULT_MSG,"Successfully recreated directory '$ProjectFolder'.")
}
CATCH {
  Write-Error -Message "Unable to create directory '$ProjectFolder'. Error was: $_" -ErrorAction Stop	
}

$PS_STEP = 900
#WhereScape program to produce the documentation
TRY
{
     $output = & "$WhereScapeRedEXE" /BD /C $ODBCSource /A "64" /D $ProjectFolder /G $ProjectName /S 99   | Out-String
     $RESULT_MSG = -join($RESULT_MSG,"Generated Documentation for $ProjectName.")
     $PS_STATUS = 1
}
CATCH {
     $RESULT_MSG = -join($RESULT_MSG,"Error! $output")
     $PS_STATUS = -3
}

Write-Output $PS_STATUS;  
Write-Output $RESULT_MSG;