Convert PowerShell to C##
$10-30 CAD
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"
Project ID: #6255529
About the project
Awarded to:
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?
13 freelancers are bidding on average $26 for this job
Hi, I think I can do it:-)! I have a lot of experience in C# and VB.NET development. Best regards:-)
7 years in C# development i'll do now if you hire me and send it in some hours Please contact me soon
I can write C# code for mentioned 3 steps. I would like to work on your project. Thanks . . . .
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