Convert PowerShell to C##

Completed Posted Jul 30, 2014 Paid on delivery
Completed Paid on delivery

I have a 60 line PowerShell script that I need converted into C#. You just need to write the code and test it.

I will paste the PowerShell code here so you can see exactly what needs to be done. The script performs the following:

1) Looks for all files in a folder called "inbox" (this is just a folder on C:\Inbox)

2) For each file, replace spaces in the name with underscores, move the file to C:\Stage, then launch a powershell process

3) Logs its actions to a CSV file

------------------------------------------------

## DEFINE FUNCTIONS

function fcnLogEvent($strEventDescription,$strEventLevel) {

$strDateTime = Get-Date -Format "MM/dd/yyyy hh:mm:ss:ffff"

$strEventDescription = $strEventDescription + " "

$strEventDescription = $[url removed, login to view](85,".")

$strLogLine = $strDateTime + "," + $strEventDescription + " " + $strEventLevel

try {

if ($debugLevel -eq "1") {

write-host $strLogLine

add-content ".\[url removed, login to view]" -value $strLogLine

}

} catch {

}

}

function fcnMoveFileToStage($strFile) {

$strFileName = $[url removed, login to view]

try {

Move-Item "..\inbox\$strFileName" "..\stage\$strFileName"

fcnLogEvent "Moving File $strFileName" "Information"

} catch {

fcnLogEvent "Moving File $strFileName" "Error"

}

return $strFileName

}

function fcnLaunchFileEscort($strFileName) {

try {

$strExecutable = "[url removed, login to view]"

$strArguments = "-file .\[url removed, login to view]", "$strFileName"

$objProcess = start-process $strExecutable $strArguments -PassThru -WindowStyle Hidden

fcnLogEvent "Starting file escort for $strFileName" "Information"

} catch {

fcnLogEvent "Starting file escort for $strFileName" "Error"

}

}

## SCRIPT START

fcnLogEvent "Scanning inbox" "Information"

## RENAME SPACES TO UNDERSCORES IN FILE NAMES

dir "..\inbox" | Rename-Item -NewName { $[url removed, login to view] -replace ' ','_' }

## GET FILES IN INBOX

try {

$arrFiles = Get-ChildItem -Path "..\inbox" –File

} catch {

fcnLogEvent "Unable to scan inbox" "Error"

}

## PROCESS EACH FILE

if ($[url removed, login to view] -gt 0) {

$intFileCount = $[url removed, login to view]

fcnLogEvent "Found $intFileCount files in inbox" "Information"

foreach ($objFile in $arrFiles) {

$strStageFileName = fcnMoveFileToStage $objFile

fcnLaunchFileEscort $strStageFileName

}

} else {

fcnLogEvent "Found 0 files in inbox" "Information"

}

## EXIT

fcnLogEvent "Process complete. Exiting" "Information"

C# Programming

Project ID: #6255529

About the project

13 proposals Remote project Active Jul 31, 2014

Awarded to:

DavidJRG

I can complete this in a couple of hours. Will you be needing any visual feedback or you're planning to run this with the scheduler?

$20 CAD in 1 day
(6 Reviews)
4.0

13 freelancers are bidding on average $26 for this job

vano101

A proposal has not yet been provided

$25 CAD in 2 days
(215 Reviews)
6.0
rinsadsl

A proposal has not yet been provided

$34 CAD in 1 day
(10 Reviews)
4.7
netcoder

Hi, I think I can do it:-)! I have a lot of experience in C# and VB.NET development. Best regards:-)

$30 CAD in 1 day
(17 Reviews)
4.3
sby

7 years in C# development i'll do now if you hire me and send it in some hours Please contact me soon

$30 CAD in 1 day
(6 Reviews)
3.5
cliscwang

A proposal has not yet been provided

$20 CAD in 1 day
(4 Reviews)
3.2
aruny308

I can write C# code for mentioned 3 steps. I would like to work on your project. Thanks . . . .

$17 CAD in 1 day
(3 Reviews)
1.5
hemalpatel

I am Hemal Patel, B.E. Computer Engineer, having 4 years of experience on Microsoft technologies for developing software for different domains. Since 2010, I have served as a software engineer for my previous company, More

$30 CAD in 1 day
(2 Reviews)
0.5
j0hnjay

A proposal has not yet been provided

$25 CAD in 3 days
(0 Reviews)
0.0