Created
July 22, 2017 20:14
-
-
Save MSAdministrator/d9fe0d7c94825112da3e373123e28ecb to your computer and use it in GitHub Desktop.
Convert-SabaToCampus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.Synopsis | |
This function will convert a Saba CSV for University Campus | |
.DESCRIPTION | |
This function will import a CSV, modify the values, and export it to a new CSV. | |
We rename the following headers: | |
Person EMPID to EMPID | |
Completed Courses (Transcript) Ended/Completed On Date to Completed On Date | |
Course Course ID to Course ID | |
.EXAMPLE | |
C:\> Convert-SabaToCampus -InFile C:\users\user\desktop\infile.csv -OutFile C:\users\user\desktop\outfile.csv | |
#> | |
function Convert-SabaToCampus | |
{ | |
[CmdletBinding(DefaultParameterSetName='Parameter Set 1', | |
SupportsShouldProcess=$true, | |
PositionalBinding=$false, | |
HelpUri = 'http://www.microsoft.com/', | |
ConfirmImpact='Medium')] | |
[Alias()] | |
[OutputType()] | |
Param | |
( | |
# Param1 help description | |
[Parameter(Mandatory=$true, | |
ValueFromPipeline=$true, | |
ValueFromPipelineByPropertyName=$true, | |
ValueFromRemainingArguments=$false, | |
Position=0, | |
ParameterSetName='Parameter Set 1')] | |
[ValidateNotNull()] | |
[ValidateNotNullOrEmpty()] | |
[Alias("CSV")] | |
$InFile, | |
# Param1 help description | |
[Parameter(Mandatory=$true, | |
ValueFromPipelineByPropertyName=$true, | |
ValueFromRemainingArguments=$false, | |
Position=1, | |
ParameterSetName='Parameter Set 1')] | |
[ValidateNotNull()] | |
[ValidateNotNullOrEmpty()] | |
$OutFile | |
) | |
Begin | |
{ | |
$ReturnObject = @() | |
$DataIn = Import-Csv $InFile | |
} | |
Process | |
{ | |
foreach ($d in $DataIn) | |
{ | |
if ($pscmdlet.ShouldProcess("Target", "Operation")) | |
{ | |
$props = @{ | |
EMPID = $d.'Person EMPID' | |
'Completed On Date' = [DateTime]::Parse($d.'Completed Courses (Transcript) Ended/Completed On Date').ToString('MM/dd/yyyy') | |
'Course ID' = $d.'Course Course ID' | |
} | |
$tempObj = New-Object -TypeName PSCustomObject -Property $props | |
$ReturnObject += $tempObj | |
} | |
} | |
} | |
End | |
{ | |
$returnobject | Export-Csv -Path $OutFile -Force -NoTypeInformation | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment