cEPRSSSIS.psm1
[DscResource()]class cEPRSCopyDTSXSSIS { [DscProperty()]$FilePath [DscProperty(Key)][string]$FileName [DscProperty()]$DestinationPath [DscProperty()]$DTUtilPath [cEPRSCopyDTSXSSIS]Get() { $FileContent = Get-Item -Path "$($this.FilePath)\$($this.FileName)" $this.FilePath = $FileContent.FullName return $this } [bool]Test() { if(Test-Path "$($this.DTUtilPath)\dtutil.exe") { if(Test-Path "$($this.FilePath)\$($this.FileName)") { $result = $false } else { Write-Warning "$($this.FilePath)\$($this.FileName) doesn't exist... Please check the path" Write-Verbose "$($this.FilePath)\$($this.FileName) doesn't exist... Please check the path" $result = $true } } else { Write-Warning "$($this.DTUtilPath) doesn't exist... Please check the path" Write-Verbose "$($this.DTUtilPath) doesn't exist... Please check the path" $result = $true } return $result } Set() { Write-Verbose "Set-Location $($this.DTUtilPath)" Set-Location "$($this.DTUtilPath)" .\dtutil.exe "/FExists SQL;\$($this.DestinationFolder)" if($env:LASTEXITCODE -eq $true) { .\dtutil.exe "/FCreate SQL;\;$($this.DestinationFolder)" } Write-Verbose "--------------------------------------------------------------" Write-Verbose "Copying '$($this.FilePath)\$($this.FileName)' package to SQL integration services." Write-Verbose "--------------------------------------------------------------" $File=$this.FileName.split('.')[0] $Fullpath="$($this.FilePath)"+'\'+"$($this.FileName)" .\dtutil.exe "/FILE $Fullpath /COPY SQL;\$($this.DestinationFolder)\$File /QUIET" } } |